Skip to content

Commit c5c9a52

Browse files
fix: remove drift map scrubber (#20723)
Co-authored-by: shenlong-tanwen <[email protected]>
1 parent 3cd7f5a commit c5c9a52

File tree

2 files changed

+52
-36
lines changed

2 files changed

+52
-36
lines changed

mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _ScopedMapTimeline extends StatelessWidget {
3636
return timelineService;
3737
}),
3838
],
39-
child: const Timeline(appBar: null, bottomSheet: null),
39+
child: const Timeline(appBar: null, bottomSheet: null, withScrubber: false),
4040
);
4141
}
4242
}

mobile/lib/presentation/widgets/timeline/timeline.widget.dart

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Timeline extends StatelessWidget {
3636
this.appBar = const ImmichSliverAppBar(floating: true, pinned: false, snap: false),
3737
this.bottomSheet = const GeneralBottomSheet(),
3838
this.groupBy,
39+
this.withScrubber = true,
3940
});
4041

4142
final Widget? topSliverWidget;
@@ -45,6 +46,7 @@ class Timeline extends StatelessWidget {
4546
final Widget? bottomSheet;
4647
final bool withStack;
4748
final GroupAssetsBy? groupBy;
49+
final bool withScrubber;
4850

4951
@override
5052
Widget build(BuildContext context) {
@@ -69,6 +71,7 @@ class Timeline extends StatelessWidget {
6971
topSliverWidgetHeight: topSliverWidgetHeight,
7072
appBar: appBar,
7173
bottomSheet: bottomSheet,
74+
withScrubber: withScrubber,
7275
),
7376
),
7477
),
@@ -77,12 +80,19 @@ class Timeline extends StatelessWidget {
7780
}
7881

7982
class _SliverTimeline extends ConsumerStatefulWidget {
80-
const _SliverTimeline({this.topSliverWidget, this.topSliverWidgetHeight, this.appBar, this.bottomSheet});
83+
const _SliverTimeline({
84+
this.topSliverWidget,
85+
this.topSliverWidgetHeight,
86+
this.appBar,
87+
this.bottomSheet,
88+
this.withScrubber = true,
89+
});
8190

8291
final Widget? topSliverWidget;
8392
final double? topSliverWidgetHeight;
8493
final Widget? appBar;
8594
final Widget? bottomSheet;
95+
final bool withScrubber;
8696

8797
@override
8898
ConsumerState createState() => _SliverTimelineState();
@@ -265,6 +275,45 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
265275
const scrubberBottomPadding = 100.0;
266276
final bottomPadding = context.padding.bottom + (widget.appBar == null ? 0 : scrubberBottomPadding);
267277

278+
final grid = CustomScrollView(
279+
primary: true,
280+
physics: _scrollPhysics,
281+
cacheExtent: maxHeight * 2,
282+
slivers: [
283+
if (isSelectionMode) const SelectionSliverAppBar() else if (widget.appBar != null) widget.appBar!,
284+
if (widget.topSliverWidget != null) widget.topSliverWidget!,
285+
_SliverSegmentedList(
286+
segments: segments,
287+
delegate: SliverChildBuilderDelegate(
288+
(ctx, index) {
289+
if (index >= childCount) return null;
290+
final segment = segments.findByIndex(index);
291+
return segment?.builder(ctx, index) ?? const SizedBox.shrink();
292+
},
293+
childCount: childCount,
294+
addAutomaticKeepAlives: false,
295+
// We add repaint boundary around tiles, so skip the auto boundaries
296+
addRepaintBoundaries: false,
297+
),
298+
),
299+
const SliverPadding(padding: EdgeInsets.only(bottom: scrubberBottomPadding)),
300+
],
301+
);
302+
303+
final Widget timeline;
304+
if (widget.withScrubber) {
305+
timeline = Scrubber(
306+
layoutSegments: segments,
307+
timelineHeight: maxHeight,
308+
topPadding: topPadding,
309+
bottomPadding: bottomPadding,
310+
monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
311+
child: grid,
312+
);
313+
} else {
314+
timeline = grid;
315+
}
316+
268317
return PrimaryScrollController(
269318
controller: _scrollController,
270319
child: RawGestureDetector(
@@ -303,40 +352,7 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
303352
},
304353
child: Stack(
305354
children: [
306-
Scrubber(
307-
layoutSegments: segments,
308-
timelineHeight: maxHeight,
309-
topPadding: topPadding,
310-
bottomPadding: bottomPadding,
311-
monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
312-
child: CustomScrollView(
313-
primary: true,
314-
physics: _scrollPhysics,
315-
cacheExtent: maxHeight * 2,
316-
slivers: [
317-
if (isSelectionMode)
318-
const SelectionSliverAppBar()
319-
else if (widget.appBar != null)
320-
widget.appBar!,
321-
if (widget.topSliverWidget != null) widget.topSliverWidget!,
322-
_SliverSegmentedList(
323-
segments: segments,
324-
delegate: SliverChildBuilderDelegate(
325-
(ctx, index) {
326-
if (index >= childCount) return null;
327-
final segment = segments.findByIndex(index);
328-
return segment?.builder(ctx, index) ?? const SizedBox.shrink();
329-
},
330-
childCount: childCount,
331-
addAutomaticKeepAlives: false,
332-
// We add repaint boundary around tiles, so skip the auto boundaries
333-
addRepaintBoundaries: false,
334-
),
335-
),
336-
const SliverPadding(padding: EdgeInsets.only(bottom: scrubberBottomPadding)),
337-
],
338-
),
339-
),
355+
timeline,
340356
if (!isSelectionMode && isMultiSelectEnabled) ...[
341357
const Positioned(top: 60, left: 25, child: _MultiSelectStatusButton()),
342358
if (widget.bottomSheet != null) widget.bottomSheet!,

0 commit comments

Comments
 (0)