filter grid scaling: grid with spacing
This commit is contained in:
parent
f86eb078a4
commit
548d723223
4 changed files with 22 additions and 9 deletions
|
@ -48,7 +48,7 @@ class CatalogMetadata {
|
||||||
this.xmpTitleDescription,
|
this.xmpTitleDescription,
|
||||||
double latitude,
|
double latitude,
|
||||||
double longitude,
|
double longitude,
|
||||||
})
|
})
|
||||||
// Geocoder throws an IllegalArgumentException when a coordinate has a funky values like 1.7056881853375E7
|
// Geocoder throws an IllegalArgumentException when a coordinate has a funky values like 1.7056881853375E7
|
||||||
: latitude = latitude == null || latitude < -90.0 || latitude > 90.0 ? null : latitude,
|
: latitude = latitude == null || latitude < -90.0 || latitude > 90.0 ? null : latitude,
|
||||||
longitude = longitude == null || longitude < -180.0 || longitude > 180.0 ? null : longitude;
|
longitude = longitude == null || longitude < -180.0 || longitude > 180.0 ? null : longitude;
|
||||||
|
|
|
@ -92,6 +92,7 @@ class _GridScaleGestureDetectorState<T> extends State<GridScaleGestureDetector<T
|
||||||
builder: (extent) => widget.scaledBuilder(_metadata.item, extent),
|
builder: (extent) => widget.scaledBuilder(_metadata.item, extent),
|
||||||
center: thumbnailCenter,
|
center: thumbnailCenter,
|
||||||
gridWidth: gridWidth,
|
gridWidth: gridWidth,
|
||||||
|
spacing: tileExtentManager.spacing,
|
||||||
scaledExtentNotifier: _scaledExtentNotifier,
|
scaledExtentNotifier: _scaledExtentNotifier,
|
||||||
showScaledGrid: widget.showScaledGrid,
|
showScaledGrid: widget.showScaledGrid,
|
||||||
),
|
),
|
||||||
|
@ -157,6 +158,7 @@ class ScaleOverlay extends StatefulWidget {
|
||||||
final Widget Function(double extent) builder;
|
final Widget Function(double extent) builder;
|
||||||
final Offset center;
|
final Offset center;
|
||||||
final double gridWidth;
|
final double gridWidth;
|
||||||
|
final double spacing;
|
||||||
final ValueNotifier<double> scaledExtentNotifier;
|
final ValueNotifier<double> scaledExtentNotifier;
|
||||||
final bool showScaledGrid;
|
final bool showScaledGrid;
|
||||||
|
|
||||||
|
@ -164,6 +166,7 @@ class ScaleOverlay extends StatefulWidget {
|
||||||
@required this.builder,
|
@required this.builder,
|
||||||
@required this.center,
|
@required this.center,
|
||||||
@required this.gridWidth,
|
@required this.gridWidth,
|
||||||
|
@required this.spacing,
|
||||||
@required this.scaledExtentNotifier,
|
@required this.scaledExtentNotifier,
|
||||||
@required this.showScaledGrid,
|
@required this.showScaledGrid,
|
||||||
});
|
});
|
||||||
|
@ -243,6 +246,7 @@ class _ScaleOverlayState extends State<ScaleOverlay> {
|
||||||
painter: GridPainter(
|
painter: GridPainter(
|
||||||
center: clampedCenter,
|
center: clampedCenter,
|
||||||
extent: extent,
|
extent: extent,
|
||||||
|
spacing: widget.spacing,
|
||||||
),
|
),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
@ -258,11 +262,12 @@ class _ScaleOverlayState extends State<ScaleOverlay> {
|
||||||
|
|
||||||
class GridPainter extends CustomPainter {
|
class GridPainter extends CustomPainter {
|
||||||
final Offset center;
|
final Offset center;
|
||||||
final double extent;
|
final double extent, spacing;
|
||||||
|
|
||||||
const GridPainter({
|
const GridPainter({
|
||||||
@required this.center,
|
@required this.center,
|
||||||
@required this.extent,
|
@required this.extent,
|
||||||
|
@required this.spacing,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -271,7 +276,7 @@ class GridPainter extends CustomPainter {
|
||||||
..strokeWidth = DecoratedThumbnail.borderWidth
|
..strokeWidth = DecoratedThumbnail.borderWidth
|
||||||
..shader = ui.Gradient.radial(
|
..shader = ui.Gradient.radial(
|
||||||
center,
|
center,
|
||||||
size.width / 2,
|
size.width * .7,
|
||||||
[
|
[
|
||||||
DecoratedThumbnail.borderColor,
|
DecoratedThumbnail.borderColor,
|
||||||
Colors.transparent,
|
Colors.transparent,
|
||||||
|
@ -281,10 +286,18 @@ class GridPainter extends CustomPainter {
|
||||||
1,
|
1,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
void draw(Offset topLeft) {
|
||||||
|
for (var i = -2; i <= 3; i++) {
|
||||||
|
final ref = (extent + spacing) * i;
|
||||||
|
canvas.drawLine(Offset(0, topLeft.dy + ref), Offset(size.width, topLeft.dy + ref), paint);
|
||||||
|
canvas.drawLine(Offset(topLeft.dx + ref, 0), Offset(topLeft.dx + ref, size.height), paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final topLeft = center.translate(-extent / 2, -extent / 2);
|
final topLeft = center.translate(-extent / 2, -extent / 2);
|
||||||
for (var i = -1; i <= 2; i++) {
|
draw(topLeft);
|
||||||
canvas.drawLine(Offset(0, topLeft.dy + extent * i), Offset(size.width, topLeft.dy + extent * i), paint);
|
if (spacing > 0) {
|
||||||
canvas.drawLine(Offset(topLeft.dx + extent * i, 0), Offset(topLeft.dx + extent * i, size.height), paint);
|
draw(topLeft.translate(-spacing, -spacing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class DecoratedFilterChip extends StatelessWidget {
|
||||||
Widget _buildDetails(CollectionFilter filter) {
|
Widget _buildDetails(CollectionFilter filter) {
|
||||||
final padding = min<double>(8.0, extent / 16);
|
final padding = min<double>(8.0, extent / 16);
|
||||||
final iconSize = min<double>(14.0, extent / 8);
|
final iconSize = min<double>(14.0, extent / 8);
|
||||||
final fontSize = min<double>(14.0, (extent / 6).roundToDouble());
|
final fontSize = min<double>(14.0, extent / 6);
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
@ -84,13 +84,13 @@ class DecoratedFilterChip extends StatelessWidget {
|
||||||
if (filter is AlbumFilter && androidFileUtils.isOnRemovableStorage(filter.album))
|
if (filter is AlbumFilter && androidFileUtils.isOnRemovableStorage(filter.album))
|
||||||
AnimatedPadding(
|
AnimatedPadding(
|
||||||
padding: EdgeInsets.only(right: padding),
|
padding: EdgeInsets.only(right: padding),
|
||||||
|
duration: Durations.chipDecorationAnimation,
|
||||||
child: DecoratedIcon(
|
child: DecoratedIcon(
|
||||||
AIcons.removableStorage,
|
AIcons.removableStorage,
|
||||||
color: FilterGridPage.detailColor,
|
color: FilterGridPage.detailColor,
|
||||||
shadows: [Constants.embossShadow],
|
shadows: [Constants.embossShadow],
|
||||||
size: iconSize,
|
size: iconSize,
|
||||||
),
|
),
|
||||||
duration: Durations.chipDecorationAnimation,
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${source.count(filter)}',
|
'${source.count(filter)}',
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FilterGridPage<T extends CollectionFilter> extends StatelessWidget {
|
||||||
scrollableKey: _scrollableKey,
|
scrollableKey: _scrollableKey,
|
||||||
appBarHeightNotifier: _appBarHeightNotifier,
|
appBarHeightNotifier: _appBarHeightNotifier,
|
||||||
viewportSize: viewportSize,
|
viewportSize: viewportSize,
|
||||||
showScaledGrid: false,
|
showScaledGrid: true,
|
||||||
scaledBuilder: (item, extent) {
|
scaledBuilder: (item, extent) {
|
||||||
final filter = item.filter;
|
final filter = item.filter;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
|
Loading…
Reference in a new issue