mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
fix: handle back gesture in multi selection mode (#20356)
* fix: handle back gesture in multi selection mode # Conflicts: # mobile/lib/presentation/widgets/timeline/timeline.widget.dart * remove null-aware element because Isar * chore: set sqlite busy_timeout to 500ms (#20358) fix: add busy_timeout pragma Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
e52b9d15b5
commit
34974b036c
@ -109,6 +109,7 @@ class Drift extends $Drift implements IDatabaseRepository {
|
|||||||
await customStatement('PRAGMA foreign_keys = ON');
|
await customStatement('PRAGMA foreign_keys = ON');
|
||||||
await customStatement('PRAGMA synchronous = NORMAL');
|
await customStatement('PRAGMA synchronous = NORMAL');
|
||||||
await customStatement('PRAGMA journal_mode = WAL');
|
await customStatement('PRAGMA journal_mode = WAL');
|
||||||
|
await customStatement('PRAGMA busy_timeout = 500');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -155,79 +155,69 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
|
|||||||
final asyncSegments = ref.watch(timelineSegmentProvider);
|
final asyncSegments = ref.watch(timelineSegmentProvider);
|
||||||
final maxHeight = ref.watch(timelineArgsProvider.select((args) => args.maxHeight));
|
final maxHeight = ref.watch(timelineArgsProvider.select((args) => args.maxHeight));
|
||||||
final isSelectionMode = ref.watch(multiSelectProvider.select((s) => s.forceEnable));
|
final isSelectionMode = ref.watch(multiSelectProvider.select((s) => s.forceEnable));
|
||||||
|
final isMultiSelectEnabled = ref.watch(multiSelectProvider.select((s) => s.isEnabled));
|
||||||
|
|
||||||
return asyncSegments.widgetWhen(
|
return PopScope(
|
||||||
onData: (segments) {
|
canPop: !isMultiSelectEnabled,
|
||||||
final childCount = (segments.lastOrNull?.lastIndex ?? -1) + 1;
|
onPopInvokedWithResult: (_, __) {
|
||||||
final double appBarExpandedHeight = widget.appBar != null && widget.appBar is MesmerizingSliverAppBar ? 200 : 0;
|
if (isMultiSelectEnabled) {
|
||||||
final topPadding = context.padding.top + (widget.appBar == null ? 0 : kToolbarHeight) + 10;
|
ref.read(multiSelectProvider.notifier).reset();
|
||||||
|
}
|
||||||
const scrubberBottomPadding = 100.0;
|
|
||||||
final bottomPadding = context.padding.bottom + (widget.appBar == null ? 0 : scrubberBottomPadding);
|
|
||||||
|
|
||||||
return PrimaryScrollController(
|
|
||||||
controller: _scrollController,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Scrubber(
|
|
||||||
layoutSegments: segments,
|
|
||||||
timelineHeight: maxHeight,
|
|
||||||
topPadding: topPadding,
|
|
||||||
bottomPadding: bottomPadding,
|
|
||||||
monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
|
|
||||||
child: CustomScrollView(
|
|
||||||
primary: true,
|
|
||||||
cacheExtent: 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SliverPadding(padding: EdgeInsets.only(bottom: scrubberBottomPadding)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!isSelectionMode) ...[
|
|
||||||
Consumer(
|
|
||||||
builder: (_, consumerRef, child) {
|
|
||||||
final isMultiSelectEnabled = consumerRef.watch(multiSelectProvider.select((s) => s.isEnabled));
|
|
||||||
|
|
||||||
if (isMultiSelectEnabled) {
|
|
||||||
return child!;
|
|
||||||
}
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
},
|
|
||||||
child: const Positioned(top: 60, left: 25, child: _MultiSelectStatusButton()),
|
|
||||||
),
|
|
||||||
if (widget.bottomSheet != null)
|
|
||||||
Consumer(
|
|
||||||
builder: (_, consumerRef, child) {
|
|
||||||
final isMultiSelectEnabled = consumerRef.watch(multiSelectProvider.select((s) => s.isEnabled));
|
|
||||||
|
|
||||||
if (isMultiSelectEnabled) {
|
|
||||||
return child!;
|
|
||||||
}
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
},
|
|
||||||
child: widget.bottomSheet,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
child: asyncSegments.widgetWhen(
|
||||||
|
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 scrubberBottomPadding = 100.0;
|
||||||
|
final bottomPadding = context.padding.bottom + (widget.appBar == null ? 0 : scrubberBottomPadding);
|
||||||
|
|
||||||
|
return PrimaryScrollController(
|
||||||
|
controller: _scrollController,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Scrubber(
|
||||||
|
layoutSegments: segments,
|
||||||
|
timelineHeight: maxHeight,
|
||||||
|
topPadding: topPadding,
|
||||||
|
bottomPadding: bottomPadding,
|
||||||
|
monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
|
||||||
|
child: CustomScrollView(
|
||||||
|
primary: true,
|
||||||
|
cacheExtent: 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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SliverPadding(padding: EdgeInsets.only(bottom: scrubberBottomPadding)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isSelectionMode && isMultiSelectEnabled) ...[
|
||||||
|
const Positioned(top: 60, left: 25, child: _MultiSelectStatusButton()),
|
||||||
|
if (widget.bottomSheet != null) widget.bottomSheet!,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user