fixes
This commit is contained in:
parent
38c71aa073
commit
3db806eabe
3 changed files with 24 additions and 36 deletions
|
@ -450,13 +450,14 @@ class _CollectionScrollViewState extends State<_CollectionScrollView> {
|
||||||
final crumbs = <double, String>{};
|
final crumbs = <double, String>{};
|
||||||
if (sectionLayouts.length <= 1) return crumbs;
|
if (sectionLayouts.length <= 1) return crumbs;
|
||||||
|
|
||||||
|
final maxOffset = sectionLayouts.last.maxOffset;
|
||||||
void addAlbums(CollectionLens collection, List<SectionLayout> sectionLayouts, Map<double, String> crumbs) {
|
void addAlbums(CollectionLens collection, List<SectionLayout> sectionLayouts, Map<double, String> crumbs) {
|
||||||
final source = collection.source;
|
final source = collection.source;
|
||||||
sectionLayouts.forEach((section) {
|
sectionLayouts.forEach((section) {
|
||||||
final directory = (section.sectionKey as EntryAlbumSectionKey).directory;
|
final directory = (section.sectionKey as EntryAlbumSectionKey).directory;
|
||||||
if (directory != null) {
|
if (directory != null) {
|
||||||
final label = source.getAlbumDisplayName(context, directory);
|
final label = source.getAlbumDisplayName(context, directory);
|
||||||
crumbs[section.minOffset] = label;
|
crumbs[section.minOffset / maxOffset] = label;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -484,7 +485,7 @@ class _CollectionScrollViewState extends State<_CollectionScrollView> {
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
final label = dateFormat.format(date);
|
final label = dateFormat.format(date);
|
||||||
if (label != lastLabel) {
|
if (label != lastLabel) {
|
||||||
crumbs[section.minOffset] = label;
|
crumbs[section.minOffset / maxOffset] = label;
|
||||||
lastLabel = label;
|
lastLabel = label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,11 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
late AnimationController _labelAnimationController;
|
late AnimationController _labelAnimationController;
|
||||||
late Animation<double> _labelAnimation;
|
late Animation<double> _labelAnimation;
|
||||||
Timer? _fadeoutTimer;
|
Timer? _fadeoutTimer;
|
||||||
Map<double, String>? _modelCrumbs;
|
Map<double, String>? _percentCrumbs;
|
||||||
final List<_Crumb> _viewportCrumbs = [];
|
final Map<double, String> _viewportCrumbs = {};
|
||||||
|
|
||||||
static const crumbPadding = 30.0;
|
static const double crumbPadding = 30;
|
||||||
static const crumbOffsetRatioThreshold = 10;
|
static const double crumbMinViewportRatio = 4;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -185,7 +185,7 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
|
||||||
if (oldWidget.crumbsBuilder != widget.crumbsBuilder) {
|
if (oldWidget.crumbsBuilder != widget.crumbsBuilder) {
|
||||||
_modelCrumbs = null;
|
_percentCrumbs = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +218,12 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
if (_isDragInProcess)
|
if (_isDragInProcess)
|
||||||
..._viewportCrumbs.map((crumb) {
|
..._viewportCrumbs.entries.map((kv) {
|
||||||
|
final offset = kv.key;
|
||||||
|
final label = kv.value;
|
||||||
return Positioned.directional(
|
return Positioned.directional(
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
top: crumb.labelOffset,
|
top: offset,
|
||||||
end: DraggableScrollbar.labelThumbPadding + widget.scrollThumbSize.width,
|
end: DraggableScrollbar.labelThumbPadding + widget.scrollThumbSize.width,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.padding,
|
padding: widget.padding,
|
||||||
|
@ -231,7 +233,7 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
child: ScrollLabel(
|
child: ScrollLabel(
|
||||||
animation: kAlwaysCompleteAnimation,
|
animation: kAlwaysCompleteAnimation,
|
||||||
backgroundColor: widget.backgroundColor,
|
backgroundColor: widget.backgroundColor,
|
||||||
child: widget.crumbTextBuilder(crumb.label),
|
child: widget.crumbTextBuilder(label),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -349,24 +351,18 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
_viewportCrumbs.clear();
|
_viewportCrumbs.clear();
|
||||||
final crumbsBuilder = widget.crumbsBuilder;
|
final crumbsBuilder = widget.crumbsBuilder;
|
||||||
if (crumbsBuilder != null) {
|
if (crumbsBuilder != null) {
|
||||||
|
final maxOffset = thumbMaxScrollExtent;
|
||||||
final position = controller.position;
|
final position = controller.position;
|
||||||
final contentHeight = position.maxScrollExtent + thumbMaxScrollExtent + position.viewportDimension;
|
if (position.maxScrollExtent / position.viewportDimension > crumbMinViewportRatio) {
|
||||||
final ratio = contentHeight / scrollBarHeight;
|
|
||||||
if (ratio > crumbOffsetRatioThreshold) {
|
|
||||||
final maxLabelOffset = scrollBarHeight - widget.scrollThumbSize.height;
|
|
||||||
double lastLabelOffset = -crumbPadding;
|
double lastLabelOffset = -crumbPadding;
|
||||||
_modelCrumbs ??= crumbsBuilder();
|
_percentCrumbs ??= crumbsBuilder();
|
||||||
_modelCrumbs!.entries.forEach((kv) {
|
_percentCrumbs!.entries.forEach((kv) {
|
||||||
final viewOffset = kv.key;
|
final percent = kv.key;
|
||||||
final label = kv.value;
|
final label = kv.value;
|
||||||
final labelOffset = (viewOffset / ratio).roundToDouble();
|
final labelOffset = percent * maxOffset;
|
||||||
if (labelOffset >= lastLabelOffset + crumbPadding && labelOffset < maxLabelOffset) {
|
if (labelOffset >= lastLabelOffset + crumbPadding) {
|
||||||
lastLabelOffset = labelOffset;
|
lastLabelOffset = labelOffset;
|
||||||
_viewportCrumbs.add(_Crumb(
|
_viewportCrumbs[labelOffset] = label;
|
||||||
viewOffset: viewOffset,
|
|
||||||
labelOffset: labelOffset,
|
|
||||||
label: label,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// hide lonesome crumb, whether it is because of a single section,
|
// hide lonesome crumb, whether it is because of a single section,
|
||||||
|
@ -379,17 +375,6 @@ class _DraggableScrollbarState extends State<DraggableScrollbar> with TickerProv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Crumb {
|
|
||||||
final double viewOffset, labelOffset;
|
|
||||||
final String label;
|
|
||||||
|
|
||||||
const _Crumb({
|
|
||||||
required this.viewOffset,
|
|
||||||
required this.labelOffset,
|
|
||||||
required this.label,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
///This cut 2 lines in arrow shape
|
///This cut 2 lines in arrow shape
|
||||||
class ArrowClipper extends CustomClipper<Path> {
|
class ArrowClipper extends CustomClipper<Path> {
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -16,6 +16,7 @@ import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class AppBottomNavBar extends StatelessWidget {
|
class AppBottomNavBar extends StatelessWidget {
|
||||||
final Stream<DraggableScrollBarEvent> events;
|
final Stream<DraggableScrollBarEvent> events;
|
||||||
|
|
||||||
// collection loaded in the `CollectionPage`, if any
|
// collection loaded in the `CollectionPage`, if any
|
||||||
final CollectionLens? currentCollection;
|
final CollectionLens? currentCollection;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ class AppBottomNavBar extends StatelessWidget {
|
||||||
|
|
||||||
final blurred = context.select<Settings, bool>((s) => s.enableOverlayBlurEffect);
|
final blurred = context.select<Settings, bool>((s) => s.enableOverlayBlurEffect);
|
||||||
final showVideo = context.select<Settings, bool>((s) => !s.hiddenFilters.contains(MimeFilter.video));
|
final showVideo = context.select<Settings, bool>((s) => !s.hiddenFilters.contains(MimeFilter.video));
|
||||||
|
final backgroundColor = Theme.of(context).canvasColor;
|
||||||
|
|
||||||
final items = [
|
final items = [
|
||||||
const AvesBottomNavItem(route: CollectionPage.routeName),
|
const AvesBottomNavItem(route: CollectionPage.routeName),
|
||||||
|
@ -58,7 +60,7 @@ class AppBottomNavBar extends StatelessWidget {
|
||||||
onTap: (index) => _goTo(context, items, index),
|
onTap: (index) => _goTo(context, items, index),
|
||||||
currentIndex: _getCurrentIndex(context, items),
|
currentIndex: _getCurrentIndex(context, items),
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
backgroundColor: Theme.of(context).canvasColor.withOpacity(.85),
|
backgroundColor: blurred ? backgroundColor.withOpacity(.85) : backgroundColor,
|
||||||
showSelectedLabels: false,
|
showSelectedLabels: false,
|
||||||
showUnselectedLabels: false,
|
showUnselectedLabels: false,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue