High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: do not exit search screen on back during multiselect (#30689)
Yaros44a938475896
diff --git a/mobile/lib/presentation/widgets/timeline/timeline.widget.dart b/mobile/lib/presentation/widgets/timeline/timeline.widget.dartindex 0387cbf597..868edba64d 100644--- a/mobile/lib/presentation/widgets/timeline/timeline.widget.dart+++ b/mobile/lib/presentation/widgets/timeline/timeline.widget.dart@@ -413,127 +413,136 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> with WidgetsBiref.read(multiSelectProvider.notifier).reset();}},- child: PrimaryScrollController(- controller: _scrollController,- child: Scaffold(- // This removes the built in Scaffold `handleStatusBarTap` implementation, preventing duplicate- // events when we provide our own- primary: false,- resizeToAvoidBottomInset: false,- floatingActionButton: const DownloadStatusFloatingButton(),- body: asyncSegments.widgetWhen(- onLoading: widget.loadingWidget != null ? () => widget.loadingWidget! : null,- onData: (segments) {- final childCount = (segments.lastOrNull?.lastIndex ?? -1) + 1;- final double appBarExpandedHeight = widget.appBar != null && widget.appBar is MesmerizingSliverAppBar- ? 200- : 0;- final topPadding = context.padding.top + (widget.appBar == null ? 0 : kToolbarHeight) + 10;-- const bottomSheetOpenModifier = 120.0;- final contentBottomPadding =- context.padding.bottom + (isMultiSelectEnabled ? bottomSheetOpenModifier : 0);- final scrubberBottomPadding = contentBottomPadding + kScrubberThumbHeight;-- final grid = CustomScrollView(- primary: true,- physics: _scrollPhysics,- scrollCacheExtent: .pixels(maxHeight * 2),- slivers: [- if (isSelectionMode) const SelectionSliverAppBar() else if (widget.appBar != null) widget.appBar!,- if (widget.topSliverWidget != null) widget.topSliverWidget!,- _SliverSegmentedList(- segments: segments,- delegate: SliverChildBuilderDelegate(- (ctx, index) {- if (index >= childCount) {- return null;- }- final segment = segments.findByIndex(index);- return segment?.builder(ctx, index) ?? const SizedBox.shrink();- },- childCount: childCount,- addAutomaticKeepAlives: false,- // We add repaint boundary around tiles, so skip the auto boundaries- addRepaintBoundaries: false,+ child: BackButtonListener(+ onBackButtonPressed: () async {+ if (!isMultiSelectEnabled) {+ return false;+ }+ ref.read(multiSelectProvider.notifier).reset();+ return true;+ },+ child: PrimaryScrollController(+ controller: _scrollController,+ child: Scaffold(+ // This removes the built in Scaffold `handleStatusBarTap` implementation, preventing duplicate+ // events when we provide our own+ primary: false,+ resizeToAvoidBottomInset: false,+ floatingActionButton: const DownloadStatusFloatingButton(),+ body: asyncSegments.widgetWhen(+ onLoading: widget.loadingWidget != null ? () => widget.loadingWidget! : null,+ onData: (segments) {+ final childCount = (segments.lastOrNull?.lastIndex ?? -1) + 1;+ final double appBarExpandedHeight = widget.appBar != null && widget.appBar is MesmerizingSliverAppBar+ ? 200+ : 0;+ final topPadding = context.padding.top + (widget.appBar == null ? 0 : kToolbarHeight) + 10;++ const bottomSheetOpenModifier = 120.0;+ final contentBottomPadding =+ context.padding.bottom + (isMultiSelectEnabled ? bottomSheetOpenModifier : 0);+ final scrubberBottomPadding = contentBottomPadding + kScrubberThumbHeight;++ final grid = CustomScrollView(+ primary: true,+ physics: _scrollPhysics,+ scrollCacheExtent: .pixels(maxHeight * 2),+ slivers: [+ if (isSelectionMode) const SelectionSliverAppBar() else if (widget.appBar != null) widget.appBar!,+ if (widget.topSliverWidget != null) widget.topSliverWidget!,+ _SliverSegmentedList(+ segments: segments,+ delegate: SliverChildBuilderDelegate(+ (ctx, index) {+ if (index >= childCount) {+ return null;+ }+ final segment = segments.findByIndex(index);+ return segment?.builder(ctx, index) ?? const SizedBox.shrink();+ },+ childCount: childCount,+ addAutomaticKeepAlives: false,+ // We add repaint boundary around tiles, so skip the auto boundaries+ addRepaintBoundaries: false,+ ),),- ),- if (widget.bottomSliverWidget != null) widget.bottomSliverWidget!,- SliverPadding(padding: EdgeInsets.only(bottom: contentBottomPadding)),- ],- );-- final Widget timeline;- if (widget.withScrubber) {- timeline = Scrubber(- snapToMonth: widget.snapToMonth,- layoutSegments: segments,- timelineHeight: maxHeight,- topPadding: topPadding,- bottomPadding: scrubberBottomPadding,- monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,- hasAppBar: widget.appBar != null,- child: grid,+ if (widget.bottomSliverWidget != null) widget.bottomSliverWidget!,+ SliverPadding(padding: EdgeInsets.only(bottom: contentBottomPadding)),+ ],);- } else {- timeline = grid;- }-- return RawGestureDetector(- gestures: {- CustomScaleGestureRecognizer: GestureRecognizerFactoryWithHandlers<CustomScaleGestureRecognizer>(- () => CustomScaleGestureRecognizer(),- (CustomScaleGestureRecognizer scale) {- scale.onStart = (details) {- _baseScaleFactor = _scaleFactor;- };-- scale.onUpdate = (details) {- final newScaleFactor = math.max(math.min(5.0, _baseScaleFactor * details.scale), 1.0);- final newPerRow = 7 - newScaleFactor.toInt();-- if (newPerRow != _perRow) {- final targetAssetIndex = _getCurrentAssetIndex(segments);- setState(() {- _scaleFactor = newScaleFactor;- _perRow = newPerRow;- _restoreAssetIndex = targetAssetIndex;- });-- unawaited(ref.read(settingsProvider).write(.timelineTilesPerRow, _perRow));- }- };- },- ),- },- child: TimelineDragRegion(- onStart: !isReadonlyModeEnabled ? _setDragStartIndex : null,- onAssetEnter: _handleDragAssetEnter,- onEnd: !isReadonlyModeEnabled ? _stopDrag : null,- onScroll: (direction) => unawaited(_dragScroll(direction)),- onScrollStart: () {- // Minimize the bottom sheet when drag selection starts- ref.read(timelineStateProvider.notifier).setScrolling(true);++ final Widget timeline;+ if (widget.withScrubber) {+ timeline = Scrubber(+ snapToMonth: widget.snapToMonth,+ layoutSegments: segments,+ timelineHeight: maxHeight,+ topPadding: topPadding,+ bottomPadding: scrubberBottomPadding,+ monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,+ hasAppBar: widget.appBar != null,+ child: grid,+ );+ } else {+ timeline = grid;+ }++ return RawGestureDetector(+ gestures: {+ CustomScaleGestureRecognizer: GestureRecognizerFactoryWithHandlers<CustomScaleGestureRecognizer>(+ () => CustomScaleGestureRecognizer(),+ (CustomScaleGestureRecognizer scale) {+ scale.onStart = (details) {+ _baseScaleFactor = _scaleFactor;+ };++ scale.onUpdate = (details) {+ final newScaleFactor = math.max(math.min(5.0, _baseScaleFactor * details.scale), 1.0);+ final newPerRow = 7 - newScaleFactor.toInt();++ if (newPerRow != _perRow) {+ final targetAssetIndex = _getCurrentAssetIndex(segments);+ setState(() {+ _scaleFactor = newScaleFactor;+ _perRow = newPerRow;+ _restoreAssetIndex = targetAssetIndex;+ });++ unawaited(ref.read(settingsProvider).write(.timelineTilesPerRow, _perRow));+ }+ };+ },+ ),},- child: Stack(- clipBehavior: Clip.none,- children: [- timeline,- if (isBottomWidgetVisible)- Positioned(- top: MediaQuery.paddingOf(context).top,- left: 25,- child: const SizedBox(- height: kToolbarHeight,- child: Center(child: _MultiSelectStatusButton()),+ child: TimelineDragRegion(+ onStart: !isReadonlyModeEnabled ? _setDragStartIndex : null,+ onAssetEnter: _handleDragAssetEnter,+ onEnd: !isReadonlyModeEnabled ? _stopDrag : null,+ onScroll: (direction) => unawaited(_dragScroll(direction)),+ onScrollStart: () {+ // Minimize the bottom sheet when drag selection starts+ ref.read(timelineStateProvider.notifier).setScrolling(true);+ },+ child: Stack(+ clipBehavior: Clip.none,+ children: [+ timeline,+ if (isBottomWidgetVisible)+ Positioned(+ top: MediaQuery.paddingOf(context).top,+ left: 25,+ child: const SizedBox(+ height: kToolbarHeight,+ child: Center(child: _MultiSelectStatusButton()),+ ),),- ),- if (isBottomWidgetVisible) widget.bottomSheet!,- ],+ if (isBottomWidgetVisible) widget.bottomSheet!,+ ],+ ),),- ),- );- },+ );+ },+ ),),),),diff --git a/mobile/test/presentation/widgets/timeline/timeline_args_test.dart b/mobile/test/presentation/widgets/timeline/timeline_args_test.dartindex 439ae9ecf1..82dfdacb78 100644--- a/mobile/test/presentation/widgets/timeline/timeline_args_test.dart+++ b/mobile/test/presentation/widgets/timeline/timeline_args_test.dart@@ -54,6 +54,27 @@ class _CountingBucketService implements TimelineService {dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);}+// The timeline embeds a [BackButtonListener], which resolves its dispatcher via+// `Router.of(context)` and throws without a [Router] ancestor. The running app always has one+// (via `MaterialApp.router`); these tests use a plain [MaterialApp], so supply a minimal Router.+class _StubRouterDelegate extends RouterDelegate<void> with ChangeNotifier {+ _StubRouterDelegate(this.child);++ final Widget child;++ @override+ Widget build(BuildContext context) => child;++ @override+ Future<bool> popRoute() => Future.value(false);++ @override+ Future<void> setNewRoutePath(void configuration) => Future.value();+}++Widget _withRouter(Widget child) =>+ Router<void>(routerDelegate: _StubRouterDelegate(child), backButtonDispatcher: RootBackButtonDispatcher());+void main() {testWidgets('timeline args follow constraints after a zero-sized first frame while buckets are still loading', (tester,@@ -76,7 +97,7 @@ void main() {timelineServiceProvider.overrideWithValue(_FrozenBucketService()),appConfigProvider.overrideWithValue(const AppConfig()),],- child: MaterialApp(home: Timeline(withScrubber: false, readOnly: true, loadingWidget: probe)),+ child: MaterialApp(home: _withRouter(Timeline(withScrubber: false, readOnly: true, loadingWidget: probe))),),);await tester.pump();@@ -117,11 +138,13 @@ void main() {appConfigProvider.overrideWithValue(const AppConfig()),],child: MaterialApp(- home: Timeline(- withScrubber: false,- readOnly: true,- appBar: const SliverToBoxAdapter(child: SizedBox.shrink()),- topSliverWidget: probe,+ home: _withRouter(+ Timeline(+ withScrubber: false,+ readOnly: true,+ appBar: const SliverToBoxAdapter(child: SizedBox.shrink()),+ topSliverWidget: probe,+ ),),),),@@ -160,7 +183,7 @@ void main() {timelineServiceProvider.overrideWithValue(service),appConfigProvider.overrideWithValue(const AppConfig()),],- child: MaterialApp(home: Timeline(withScrubber: false, readOnly: true, loadingWidget: probe)),+ child: MaterialApp(home: _withRouter(Timeline(withScrubber: false, readOnly: true, loadingWidget: probe))),),);await tester.pump();