Memories: Switch to next/prev memory on tap' (#1114)
This commit is contained in:
commit
c744832890
2 changed files with 60 additions and 35 deletions
|
@ -276,43 +276,68 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
}
|
||||
|
||||
Widget _buildSwiper() {
|
||||
return ExtentsPageView.extents(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index < widget.memories.length - 1) {
|
||||
final nextFile = widget.memories[index + 1].file;
|
||||
preloadThumbnail(nextFile);
|
||||
preloadFile(nextFile);
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTapDown: (TapDownDetails details) {
|
||||
if (_shouldDisableScroll) {
|
||||
return;
|
||||
}
|
||||
final file = widget.memories[index].file;
|
||||
return FileWidget(
|
||||
file,
|
||||
autoPlay: false,
|
||||
tagPrefix: "memories",
|
||||
shouldDisableScroll: (value) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final edgeWidth = screenWidth * 0.20; // 20% of screen width
|
||||
if (details.localPosition.dx < edgeWidth) {
|
||||
if (_index > 0) {
|
||||
_pageController!.previousPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
}
|
||||
} else if (details.localPosition.dx > screenWidth - edgeWidth) {
|
||||
if (_index < (widget.memories.length - 1)) {
|
||||
_pageController!.nextPage(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: ExtentsPageView.extents(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index < widget.memories.length - 1) {
|
||||
final nextFile = widget.memories[index + 1].file;
|
||||
preloadThumbnail(nextFile);
|
||||
preloadFile(nextFile);
|
||||
}
|
||||
final file = widget.memories[index].file;
|
||||
return FileWidget(
|
||||
file,
|
||||
autoPlay: false,
|
||||
tagPrefix: "memories",
|
||||
shouldDisableScroll: (value) {
|
||||
setState(() {
|
||||
_shouldDisableScroll = value;
|
||||
});
|
||||
},
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: widget.memories.length,
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) async {
|
||||
unawaited(
|
||||
MemoriesService.instance.markMemoryAsSeen(widget.memories[index]),
|
||||
);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_shouldDisableScroll = value;
|
||||
_index = index;
|
||||
});
|
||||
},
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: widget.memories.length,
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) async {
|
||||
unawaited(
|
||||
MemoriesService.instance.markMemoryAsSeen(widget.memories[index]),
|
||||
);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_index = index;
|
||||
});
|
||||
}
|
||||
},
|
||||
physics: _shouldDisableScroll
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const PageScrollPhysics(),
|
||||
}
|
||||
},
|
||||
physics: _shouldDisableScroll
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const PageScrollPhysics(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ description: ente photos application
|
|||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
|
||||
version: 0.7.52+452
|
||||
version: 0.7.53+453
|
||||
|
||||
environment:
|
||||
sdk: '>=2.17.0 <3.0.0'
|
||||
|
|
Loading…
Add table
Reference in a new issue