Skip to content

Commit 7b83b7b

Browse files
authored
fix: don't show remove from album action from the main timeline (#20757)
* fix: don't show remove from album action from the main timeline * pr feedback
1 parent a896c5a commit 7b83b7b

File tree

3 files changed

+96
-84
lines changed

3 files changed

+96
-84
lines changed

mobile/lib/presentation/pages/drift_remote_album.page.dart

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:immich_mobile/presentation/widgets/bottom_sheet/remote_album_bot
1010
import 'package:immich_mobile/presentation/widgets/remote_album/drift_album_option.widget.dart';
1111
import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart';
1212
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
13+
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
1314
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
1415
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
1516
import 'package:immich_mobile/providers/user.provider.dart';
@@ -215,22 +216,34 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
215216

216217
@override
217218
Widget build(BuildContext context) {
218-
return ProviderScope(
219-
overrides: [
220-
timelineServiceProvider.overrideWith((ref) {
221-
final timelineService = ref.watch(timelineFactoryProvider).remoteAlbum(albumId: _album.id);
222-
ref.onDispose(timelineService.dispose);
223-
return timelineService;
224-
}),
225-
],
226-
child: Timeline(
227-
appBar: RemoteAlbumSliverAppBar(
228-
icon: Icons.photo_album_outlined,
229-
onShowOptions: () => showOptionSheet(context),
230-
onToggleAlbumOrder: () => toggleAlbumOrder(),
231-
onEditTitle: () => showEditTitleAndDescription(context),
219+
return PopScope(
220+
onPopInvokedWithResult: (didPop, _) {
221+
if (didPop) {
222+
Future.microtask(() {
223+
if (mounted) {
224+
ref.read(currentRemoteAlbumProvider.notifier).dispose();
225+
ref.read(remoteAlbumProvider.notifier).refresh();
226+
}
227+
});
228+
}
229+
},
230+
child: ProviderScope(
231+
overrides: [
232+
timelineServiceProvider.overrideWith((ref) {
233+
final timelineService = ref.watch(timelineFactoryProvider).remoteAlbum(albumId: _album.id);
234+
ref.onDispose(timelineService.dispose);
235+
return timelineService;
236+
}),
237+
],
238+
child: Timeline(
239+
appBar: RemoteAlbumSliverAppBar(
240+
icon: Icons.photo_album_outlined,
241+
onShowOptions: () => showOptionSheet(context),
242+
onToggleAlbumOrder: () => toggleAlbumOrder(),
243+
onEditTitle: () => showEditTitleAndDescription(context),
244+
),
245+
bottomSheet: RemoteAlbumBottomSheet(album: _album),
232246
),
233-
bottomSheet: RemoteAlbumBottomSheet(album: _album),
234247
),
235248
);
236249
}

mobile/lib/providers/infrastructure/current_album.provider.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ class CurrentAlbumNotifier extends AutoDisposeNotifier<RemoteAlbum?> {
3131
void dispose() {
3232
_keepAliveLink?.close();
3333
_assetSubscription?.cancel();
34+
state = null;
3435
}
3536
}

mobile/lib/widgets/common/remote_album_sliver_app_bar.dart

Lines changed: 67 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
1414
import 'package:immich_mobile/extensions/datetime_extensions.dart';
1515
import 'package:immich_mobile/extensions/translate_extensions.dart';
1616
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
17-
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
1817
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
1918
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
2019
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
@@ -74,76 +73,75 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
7473
const Shadow(offset: Offset(0, 2), blurRadius: 0, color: Colors.transparent),
7574
];
7675

77-
return isMultiSelectEnabled
78-
? SliverToBoxAdapter(
79-
child: switch (_scrollProgress) {
80-
< 0.8 => const SizedBox(height: 120),
81-
_ => const SizedBox(height: 452),
82-
},
83-
)
84-
: SliverAppBar(
85-
expandedHeight: 400.0,
86-
floating: false,
87-
pinned: true,
88-
snap: false,
89-
elevation: 0,
90-
leading: IconButton(
91-
icon: Icon(
92-
Platform.isIOS ? Icons.arrow_back_ios_new_rounded : Icons.arrow_back,
93-
color: actionIconColor,
94-
shadows: actionIconShadows,
95-
),
96-
onPressed: () {
97-
ref.read(remoteAlbumProvider.notifier).refresh();
98-
context.navigateTo(const TabShellRoute(children: [DriftAlbumsRoute()]));
99-
},
76+
if (isMultiSelectEnabled) {
77+
return SliverToBoxAdapter(
78+
child: switch (_scrollProgress) {
79+
< 0.8 => const SizedBox(height: 120),
80+
_ => const SizedBox(height: 452),
81+
},
82+
);
83+
} else {
84+
return SliverAppBar(
85+
expandedHeight: 400.0,
86+
floating: false,
87+
pinned: true,
88+
snap: false,
89+
elevation: 0,
90+
leading: IconButton(
91+
icon: Icon(
92+
Platform.isIOS ? Icons.arrow_back_ios_new_rounded : Icons.arrow_back,
93+
color: actionIconColor,
94+
shadows: actionIconShadows,
95+
),
96+
onPressed: () => context.navigateTo(const TabShellRoute(children: [DriftAlbumsRoute()])),
97+
),
98+
actions: [
99+
if (widget.onToggleAlbumOrder != null)
100+
IconButton(
101+
icon: Icon(Icons.swap_vert_rounded, color: actionIconColor, shadows: actionIconShadows),
102+
onPressed: widget.onToggleAlbumOrder,
100103
),
101-
actions: [
102-
if (widget.onToggleAlbumOrder != null)
103-
IconButton(
104-
icon: Icon(Icons.swap_vert_rounded, color: actionIconColor, shadows: actionIconShadows),
105-
onPressed: widget.onToggleAlbumOrder,
106-
),
107-
if (widget.onShowOptions != null)
108-
IconButton(
109-
icon: Icon(Icons.more_vert, color: actionIconColor, shadows: actionIconShadows),
110-
onPressed: widget.onShowOptions,
111-
),
112-
],
113-
flexibleSpace: Builder(
114-
builder: (context) {
115-
final settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
116-
final scrollProgress = _calculateScrollProgress(settings);
117-
118-
// Update scroll progress for the leading button
119-
WidgetsBinding.instance.addPostFrameCallback((_) {
120-
if (mounted && _scrollProgress != scrollProgress) {
121-
setState(() {
122-
_scrollProgress = scrollProgress;
123-
});
124-
}
125-
});
126-
127-
return FlexibleSpaceBar(
128-
centerTitle: true,
129-
title: AnimatedSwitcher(
130-
duration: const Duration(milliseconds: 200),
131-
child: scrollProgress > 0.95
132-
? Text(
133-
currentAlbum.name,
134-
style: TextStyle(color: context.primaryColor, fontWeight: FontWeight.w600, fontSize: 18),
135-
)
136-
: null,
137-
),
138-
background: _ExpandedBackground(
139-
scrollProgress: scrollProgress,
140-
icon: widget.icon,
141-
onEditTitle: widget.onEditTitle,
142-
),
143-
);
144-
},
104+
if (widget.onShowOptions != null)
105+
IconButton(
106+
icon: Icon(Icons.more_vert, color: actionIconColor, shadows: actionIconShadows),
107+
onPressed: widget.onShowOptions,
145108
),
146-
);
109+
],
110+
flexibleSpace: Builder(
111+
builder: (context) {
112+
final settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
113+
final scrollProgress = _calculateScrollProgress(settings);
114+
115+
// Update scroll progress for the leading button
116+
WidgetsBinding.instance.addPostFrameCallback((_) {
117+
if (mounted && _scrollProgress != scrollProgress) {
118+
setState(() {
119+
_scrollProgress = scrollProgress;
120+
});
121+
}
122+
});
123+
124+
return FlexibleSpaceBar(
125+
centerTitle: true,
126+
title: AnimatedSwitcher(
127+
duration: const Duration(milliseconds: 200),
128+
child: scrollProgress > 0.95
129+
? Text(
130+
currentAlbum.name,
131+
style: TextStyle(color: context.primaryColor, fontWeight: FontWeight.w600, fontSize: 18),
132+
)
133+
: null,
134+
),
135+
background: _ExpandedBackground(
136+
scrollProgress: scrollProgress,
137+
icon: widget.icon,
138+
onEditTitle: widget.onEditTitle,
139+
),
140+
);
141+
},
142+
),
143+
);
144+
}
147145
}
148146
}
149147

0 commit comments

Comments
 (0)