v1.0.29+29
All checks were successful
Flutter Schmutter / build (push) Successful in 3m28s

This commit is contained in:
2025-06-06 11:29:01 +02:00
parent ee93ef576b
commit c7d996a402
4 changed files with 46 additions and 31 deletions

View File

@ -31,14 +31,12 @@ class _DetailViewState extends State<DetailView> {
final initialIndex = provider.mediaItems.indexWhere(
(item) => item.id == widget.initialItemId,
);
_pageController = PageController(initialPage: initialIndex);
_currentIndex = initialIndex;
_pageController.addListener(() {
setState(() {
_currentIndex = _pageController.page?.round() ?? 0;
});
setState(() => _currentIndex = _pageController.page?.round() ?? 0);
});
_preloadAdjacentMedia(initialIndex);
@ -97,10 +95,7 @@ class _DetailViewState extends State<DetailView> {
final provider = Provider.of<MediaProvider>(context);
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('f0ck #${provider.mediaItems.elementAt(_currentIndex).id.toString()} (${provider.type})'),
),
appBar: AppBar(centerTitle: true, title: const Text('f0ck')),
body: Stack(
children: [
PageTransformer(
@ -157,7 +152,7 @@ class _DetailViewState extends State<DetailView> {
VideoWidget(details: item, isActive: isActive),
const SizedBox(height: 20),
Text(
item.mime,
'f0ck #${item.id.toString()}',
style: const TextStyle(color: Colors.white, fontSize: 18),
),
const SizedBox(height: 10, width: double.infinity),
@ -170,7 +165,7 @@ class _DetailViewState extends State<DetailView> {
if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
setState(() {
provider.setTag(tag.tag);
Navigator.pop(context);
Navigator.pop(context, true);
});
},
label: Text(tag.tag),

View File

@ -33,6 +33,10 @@ class _MediaGridState extends State<MediaGrid> {
});
}
void scrollToTop() {
_scrollController.jumpTo(0);
}
@override
Widget build(BuildContext context) {
final provider = Provider.of<MediaProvider>(context);
@ -48,7 +52,10 @@ class _MediaGridState extends State<MediaGrid> {
icon: Icon(
provider.random ? Icons.shuffle_on_outlined : Icons.shuffle,
),
onPressed: () => provider.toggleRandom(),
onPressed: () {
provider.toggleRandom();
_scrollController.jumpTo(0);
},
),
IconButton(
icon: const Icon(Icons.menu),
@ -78,6 +85,7 @@ class _MediaGridState extends State<MediaGrid> {
onChanged: (String? newValue) {
if (newValue != null) {
provider.setType(newValue);
_scrollController.jumpTo(0);
}
},
),
@ -96,6 +104,7 @@ class _MediaGridState extends State<MediaGrid> {
onChanged: (String? newValue) {
if (newValue != null) {
provider.setMode(provider.modes.indexOf(newValue));
_scrollController.jumpTo(0);
}
},
),
@ -125,6 +134,7 @@ class _MediaGridState extends State<MediaGrid> {
labelStyle: const TextStyle(color: Colors.white),
onDeleted: () {
provider.setTag(null);
_scrollController.jumpTo(0);
},
),
],
@ -133,7 +143,8 @@ class _MediaGridState extends State<MediaGrid> {
: null,
body: RefreshIndicator(
onRefresh: () async {
await provider.loadMedia(reload: true);
await provider.resetMedia();
_scrollController.jumpTo(0);
},
child: Consumer<MediaProvider>(
builder: (context, mediaProvider, child) {
@ -158,12 +169,17 @@ class _MediaGridState extends State<MediaGrid> {
final item = provider.mediaItems[index];
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailView(initialItemId: item.id),
),
),
onTap: () async {
bool test = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailView(initialItemId: item.id),
),
);
if (test) {
scrollToTop();
}
},
child: Stack(
fit: StackFit.expand,
children: <Widget>[