mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
fix(mobile): Fixes immersive mode not ending for memory lane (#7767)
Fixes immersive mode not ending for memory lane
This commit is contained in:
parent
b7e5407822
commit
de28f83d0d
@ -39,11 +39,13 @@ class MemoryPage extends HookConsumerWidget {
|
|||||||
/// The main vertically scrolling page controller with each list of memories
|
/// The main vertically scrolling page controller with each list of memories
|
||||||
final memoryPageController = usePageController(initialPage: memoryIndex);
|
final memoryPageController = usePageController(initialPage: memoryIndex);
|
||||||
|
|
||||||
// The Page Controller that scrolls horizontally with all of the assets
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
// Memories is an immersive activity
|
// Memories is an immersive activity
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
return null;
|
return () {
|
||||||
|
// Clean up to normal edge to edge when we are done
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
toNextMemory() {
|
toNextMemory() {
|
||||||
@ -159,127 +161,121 @@ class MemoryPage extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: bgColor,
|
backgroundColor: bgColor,
|
||||||
body: PopScope(
|
body: SafeArea(
|
||||||
onPopInvoked: (didPop) {
|
child: PageView.builder(
|
||||||
// Remove immersive mode and go back to normal mode
|
physics: const BouncingScrollPhysics(
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
parent: AlwaysScrollableScrollPhysics(),
|
||||||
},
|
),
|
||||||
child: SafeArea(
|
scrollDirection: Axis.vertical,
|
||||||
child: PageView.builder(
|
controller: memoryPageController,
|
||||||
physics: const BouncingScrollPhysics(
|
onPageChanged: (pageNumber) {
|
||||||
parent: AlwaysScrollableScrollPhysics(),
|
HapticFeedback.mediumImpact();
|
||||||
),
|
if (pageNumber < memories.length) {
|
||||||
scrollDirection: Axis.vertical,
|
currentMemoryIndex.value = pageNumber;
|
||||||
controller: memoryPageController,
|
currentMemory.value = memories[pageNumber];
|
||||||
onPageChanged: (pageNumber) {
|
}
|
||||||
HapticFeedback.mediumImpact();
|
|
||||||
if (pageNumber < memories.length) {
|
|
||||||
currentMemoryIndex.value = pageNumber;
|
|
||||||
currentMemory.value = memories[pageNumber];
|
|
||||||
}
|
|
||||||
|
|
||||||
currentAssetPage.value = 0;
|
currentAssetPage.value = 0;
|
||||||
|
|
||||||
updateProgressText();
|
updateProgressText();
|
||||||
},
|
},
|
||||||
itemCount: memories.length + 1,
|
itemCount: memories.length + 1,
|
||||||
itemBuilder: (context, mIndex) {
|
itemBuilder: (context, mIndex) {
|
||||||
// Build last page
|
// Build last page
|
||||||
if (mIndex == memories.length) {
|
if (mIndex == memories.length) {
|
||||||
return MemoryEpilogue(
|
return MemoryEpilogue(
|
||||||
onStartOver: () => memoryPageController.animateToPage(
|
onStartOver: () => memoryPageController.animateToPage(
|
||||||
0,
|
0,
|
||||||
duration: const Duration(seconds: 1),
|
duration: const Duration(seconds: 1),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Build horizontal page
|
||||||
|
final assetController = memoryAssetPageControllers[mIndex];
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 24.0,
|
||||||
|
right: 24.0,
|
||||||
|
top: 8.0,
|
||||||
|
bottom: 2.0,
|
||||||
),
|
),
|
||||||
);
|
child: AnimatedBuilder(
|
||||||
}
|
animation: assetController,
|
||||||
// Build horizontal page
|
builder: (context, child) {
|
||||||
final assetController = memoryAssetPageControllers[mIndex];
|
double value = 0.0;
|
||||||
return Column(
|
if (assetController.hasClients) {
|
||||||
children: [
|
// We can only access [page] if this has clients
|
||||||
Padding(
|
value = assetController.page ?? 0;
|
||||||
padding: const EdgeInsets.only(
|
}
|
||||||
left: 24.0,
|
return MemoryProgressIndicator(
|
||||||
right: 24.0,
|
ticks: memories[mIndex].assets.length,
|
||||||
top: 8.0,
|
value: (value + 1) / memories[mIndex].assets.length,
|
||||||
bottom: 2.0,
|
);
|
||||||
),
|
},
|
||||||
child: AnimatedBuilder(
|
|
||||||
animation: assetController,
|
|
||||||
builder: (context, child) {
|
|
||||||
double value = 0.0;
|
|
||||||
if (assetController.hasClients) {
|
|
||||||
// We can only access [page] if this has clients
|
|
||||||
value = assetController.page ?? 0;
|
|
||||||
}
|
|
||||||
return MemoryProgressIndicator(
|
|
||||||
ticks: memories[mIndex].assets.length,
|
|
||||||
value: (value + 1) / memories[mIndex].assets.length,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Stack(
|
Expanded(
|
||||||
children: [
|
child: Stack(
|
||||||
PageView.builder(
|
children: [
|
||||||
physics: const BouncingScrollPhysics(
|
PageView.builder(
|
||||||
parent: AlwaysScrollableScrollPhysics(),
|
physics: const BouncingScrollPhysics(
|
||||||
),
|
parent: AlwaysScrollableScrollPhysics(),
|
||||||
controller: assetController,
|
),
|
||||||
onPageChanged: onAssetChanged,
|
controller: assetController,
|
||||||
scrollDirection: Axis.horizontal,
|
onPageChanged: onAssetChanged,
|
||||||
itemCount: memories[mIndex].assets.length,
|
scrollDirection: Axis.horizontal,
|
||||||
itemBuilder: (context, index) {
|
itemCount: memories[mIndex].assets.length,
|
||||||
final asset = memories[mIndex].assets[index];
|
itemBuilder: (context, index) {
|
||||||
return GestureDetector(
|
final asset = memories[mIndex].assets[index];
|
||||||
behavior: HitTestBehavior.translucent,
|
return GestureDetector(
|
||||||
onTap: () {
|
behavior: HitTestBehavior.translucent,
|
||||||
toNextAsset(index);
|
onTap: () {
|
||||||
},
|
toNextAsset(index);
|
||||||
child: Container(
|
},
|
||||||
color: Colors.black,
|
child: Container(
|
||||||
child: MemoryCard(
|
color: Colors.black,
|
||||||
asset: asset,
|
child: MemoryCard(
|
||||||
title: memories[mIndex].title,
|
asset: asset,
|
||||||
showTitle: index == 0,
|
title: memories[mIndex].title,
|
||||||
),
|
showTitle: index == 0,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 8,
|
||||||
|
left: 8,
|
||||||
|
child: MaterialButton(
|
||||||
|
minWidth: 0,
|
||||||
|
onPressed: () {
|
||||||
|
// auto_route doesn't invoke pop scope, so
|
||||||
|
// turn off full screen mode here
|
||||||
|
// https://github.com/Milad-Akarie/auto_route_library/issues/1799
|
||||||
|
context.popRoute();
|
||||||
|
SystemChrome.setEnabledSystemUIMode(
|
||||||
|
SystemUiMode.edgeToEdge,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
shape: const CircleBorder(),
|
||||||
Positioned(
|
color: Colors.white.withOpacity(0.2),
|
||||||
top: 8,
|
elevation: 0,
|
||||||
left: 8,
|
child: const Icon(
|
||||||
child: MaterialButton(
|
Icons.close_rounded,
|
||||||
minWidth: 0,
|
color: Colors.white,
|
||||||
onPressed: () {
|
|
||||||
// auto_route doesn't invoke pop scope, so
|
|
||||||
// turn off full screen mode here
|
|
||||||
// https://github.com/Milad-Akarie/auto_route_library/issues/1799
|
|
||||||
context.popRoute();
|
|
||||||
SystemChrome.setEnabledSystemUIMode(
|
|
||||||
SystemUiMode.edgeToEdge,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
color: Colors.white.withOpacity(0.2),
|
|
||||||
elevation: 0,
|
|
||||||
child: const Icon(
|
|
||||||
Icons.close_rounded,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
MemoryBottomInfo(memory: memories[mIndex]),
|
),
|
||||||
],
|
MemoryBottomInfo(memory: memories[mIndex]),
|
||||||
);
|
],
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user