Improve memory navigation and data handling in memory widgets
This commit is contained in:
@@ -40,43 +40,32 @@ class _AllMemoriesPageState extends State<AllMemoriesPage>
|
||||
body: PageView.builder(
|
||||
controller: pageController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
hitTestBehavior: HitTestBehavior.translucent,
|
||||
itemCount: widget.allMemories.length,
|
||||
itemBuilder: (context, index) {
|
||||
return AnimatedBuilder(
|
||||
animation: pageController,
|
||||
builder: (context, child) {
|
||||
double value = 1.0;
|
||||
if (pageController.position.haveDimensions) {
|
||||
value = pageController.page! - index;
|
||||
value = (1 - (value.abs() * 0.5)).clamp(0.0, 1.0);
|
||||
}
|
||||
return Transform.scale(
|
||||
scale: value,
|
||||
child: Opacity(
|
||||
opacity: value,
|
||||
child: FullScreenMemoryDataUpdater(
|
||||
initialIndex: _getNextMemoryIndex(index),
|
||||
memories: widget.allMemories[index],
|
||||
child: FullScreenMemory(
|
||||
widget.allTitles[index],
|
||||
_getNextMemoryIndex(index),
|
||||
onNextMemory: index < widget.allMemories.length - 1
|
||||
? () => pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
)
|
||||
: null,
|
||||
onPreviousMemory: index > 0
|
||||
? () => pageController.previousPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
final initialMemoryIndex = _getNextMemoryIndex(index);
|
||||
if (widget.allMemories[index].isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return FullScreenMemoryDataUpdater(
|
||||
initialIndex: initialMemoryIndex,
|
||||
memories: widget.allMemories[index],
|
||||
child: FullScreenMemory(
|
||||
widget.allTitles[index],
|
||||
initialMemoryIndex,
|
||||
onNextMemory: index < widget.allMemories.length - 1
|
||||
? () => pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
)
|
||||
: null,
|
||||
onPreviousMemory: index > 0
|
||||
? () => pageController.previousPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -137,6 +137,8 @@ class _MemoriesWidgetState extends State<MemoriesWidget> {
|
||||
maxHeight: _maxHeight,
|
||||
maxWidth: _maxWidth,
|
||||
title: collatedMemories[itemIndex].$2,
|
||||
allTitle: collatedMemories.map((e) => e.$2).toList(),
|
||||
currentMemoryIndex: itemIndex,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -4,8 +4,7 @@ import "package:photos/models/memories/memory.dart";
|
||||
import "package:photos/theme/colors.dart";
|
||||
import "package:photos/theme/effects.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
// import "package:photos/ui/home/memories/full_screen_memory.dart";
|
||||
import "package:photos/ui/home/memories/temp.dart";
|
||||
import "package:photos/ui/home/memories/all_memories_page.dart";
|
||||
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
|
||||
import "package:photos/utils/navigation_util.dart";
|
||||
|
||||
@@ -19,6 +18,8 @@ class MemoryCoverWidget extends StatefulWidget {
|
||||
static const aspectRatio = 0.68;
|
||||
static const horizontalPadding = 2.5;
|
||||
final String title;
|
||||
final List<String> allTitle;
|
||||
final int currentMemoryIndex;
|
||||
|
||||
const MemoryCoverWidget({
|
||||
required this.memories,
|
||||
@@ -27,6 +28,8 @@ class MemoryCoverWidget extends StatefulWidget {
|
||||
required this.maxHeight,
|
||||
required this.maxWidth,
|
||||
required this.title,
|
||||
required this.allTitle,
|
||||
required this.currentMemoryIndex,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -59,19 +62,13 @@ class _MemoryCoverWidgetState extends State<MemoryCoverWidget> {
|
||||
horizontal: MemoryCoverWidget.horizontalPadding,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
onTap: () async {
|
||||
await routeToPage(
|
||||
context,
|
||||
// FullScreenMemoryDataUpdater(
|
||||
// initialIndex: index,
|
||||
// memories: widget.memories,
|
||||
// child: FullScreenMemory(title, index),
|
||||
// ),
|
||||
// forceCustomPageRoute: true,
|
||||
TempPage(
|
||||
AllMemoriesPage(
|
||||
initialPageIndex: widget.currentMemoryIndex,
|
||||
allMemories: widget.allMemories,
|
||||
page: widget.allMemories.length,
|
||||
initialIndex: index,
|
||||
allTitles: widget.allTitle,
|
||||
),
|
||||
);
|
||||
setState(() {});
|
||||
|
||||
Reference in New Issue
Block a user