mirror of
https://github.com/immich-app/immich.git
synced 2025-01-21 03:02:44 +01:00
fix(mobile): AssetCount reset and Elliptical progress in Memories (#3355)
* fix: Constraint CircularProgressIndicator in Memories * fix(mobile): Asset count reset when scroll cancelled midway in Memories
This commit is contained in:
parent
b48d5cab22
commit
c0bee2a6b7
2 changed files with 69 additions and 51 deletions
|
@ -22,6 +22,7 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
final memoryPageController = usePageController(initialPage: memoryIndex);
|
final memoryPageController = usePageController(initialPage: memoryIndex);
|
||||||
final memoryAssetPageController = usePageController();
|
final memoryAssetPageController = usePageController();
|
||||||
final currentMemory = useState(memories[memoryIndex]);
|
final currentMemory = useState(memories[memoryIndex]);
|
||||||
|
final previousMemoryIndex = useState(memoryIndex);
|
||||||
final currentAssetPage = useState(0);
|
final currentAssetPage = useState(0);
|
||||||
final assetProgress = useState(
|
final assetProgress = useState(
|
||||||
"${currentAssetPage.value + 1}|${currentMemory.value.assets.length}",
|
"${currentAssetPage.value + 1}|${currentMemory.value.assets.length}",
|
||||||
|
@ -48,21 +49,13 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
"${currentAssetPage.value + 1}|${currentMemory.value.assets.length}";
|
"${currentAssetPage.value + 1}|${currentMemory.value.assets.length}";
|
||||||
}
|
}
|
||||||
|
|
||||||
onMemoryChanged(int otherIndex) {
|
|
||||||
HapticFeedback.mediumImpact();
|
|
||||||
currentMemory.value = memories[otherIndex];
|
|
||||||
currentAssetPage.value = 0;
|
|
||||||
updateProgressText();
|
|
||||||
}
|
|
||||||
|
|
||||||
onAssetChanged(int otherIndex) {
|
onAssetChanged(int otherIndex) {
|
||||||
HapticFeedback.selectionClick();
|
HapticFeedback.selectionClick();
|
||||||
|
|
||||||
currentAssetPage.value = otherIndex;
|
currentAssetPage.value = otherIndex;
|
||||||
updateProgressText();
|
updateProgressText();
|
||||||
}
|
}
|
||||||
|
|
||||||
buildBottomInfo() {
|
buildBottomInfo(Memory memory) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@ -71,7 +64,7 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
currentMemory.value.title,
|
memory.title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey[400],
|
color: Colors.grey[400],
|
||||||
fontSize: 11.0,
|
fontSize: 11.0,
|
||||||
|
@ -80,7 +73,7 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMMd().format(
|
DateFormat.yMMMMd().format(
|
||||||
currentMemory.value.assets[0].fileCreatedAt,
|
memory.assets[0].fileCreatedAt,
|
||||||
),
|
),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
@ -95,13 +88,34 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
/* Notification listener is used instead of OnPageChanged callback since OnPageChanged is called
|
||||||
|
* when the page in the **center** of the viewer changes. We want to reset currentAssetPage only when the final
|
||||||
|
* page during the end of scroll is different than the current page
|
||||||
|
*/
|
||||||
|
return NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (ScrollNotification notification) {
|
||||||
|
if (notification.depth == 0) {
|
||||||
|
var currentPageNumber = memoryPageController.page!.toInt();
|
||||||
|
currentMemory.value = memories[currentPageNumber];
|
||||||
|
if (notification is ScrollStartNotification) {
|
||||||
|
assetProgress.value = "";
|
||||||
|
} else if (notification is ScrollEndNotification) {
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
|
if (currentPageNumber != previousMemoryIndex.value) {
|
||||||
|
currentAssetPage.value = 0;
|
||||||
|
previousMemoryIndex.value = currentPageNumber;
|
||||||
|
}
|
||||||
|
updateProgressText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
backgroundColor: bgColor,
|
backgroundColor: bgColor,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: PageView.builder(
|
child: PageView.builder(
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
controller: memoryPageController,
|
controller: memoryPageController,
|
||||||
onPageChanged: onMemoryChanged,
|
|
||||||
itemCount: memories.length,
|
itemCount: memories.length,
|
||||||
itemBuilder: (context, mIndex) {
|
itemBuilder: (context, mIndex) {
|
||||||
// Build horizontal page
|
// Build horizontal page
|
||||||
|
@ -129,12 +143,13 @@ class MemoryPage extends HookConsumerWidget {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
buildBottomInfo(),
|
buildBottomInfo(memories[mIndex]),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,13 @@ class ImmichImage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Transform.scale(
|
return Transform.scale(
|
||||||
scale: 0.2,
|
scale: 2,
|
||||||
|
child: Center(
|
||||||
child: CircularProgressIndicator.adaptive(
|
child: CircularProgressIndicator.adaptive(
|
||||||
|
strokeWidth: 1,
|
||||||
value: downloadProgress.progress,
|
value: downloadProgress.progress,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
errorWidget: (context, url, error) {
|
errorWidget: (context, url, error) {
|
||||||
|
|
Loading…
Reference in a new issue