This commit is contained in:
		@@ -22,25 +22,26 @@ class MediaProvider extends ChangeNotifier {
 | 
				
			|||||||
  int get crossAxisCount => _crossAxisCount;
 | 
					  int get crossAxisCount => _crossAxisCount;
 | 
				
			||||||
  List<MediaItem> get mediaItems => _mediaItems;
 | 
					  List<MediaItem> get mediaItems => _mediaItems;
 | 
				
			||||||
  bool get isLoading => _isLoading;
 | 
					  bool get isLoading => _isLoading;
 | 
				
			||||||
 | 
					  Function get resetMedia => _resetMedia;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setType(String type) {
 | 
					  void setType(String type) {
 | 
				
			||||||
    _typeid = types.indexOf(type);
 | 
					    _typeid = types.indexOf(type);
 | 
				
			||||||
    loadMedia(reload: true);
 | 
					    _resetMedia();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setMode(int mode) {
 | 
					  void setMode(int mode) {
 | 
				
			||||||
    _mode = mode;
 | 
					    _mode = mode;
 | 
				
			||||||
    loadMedia(reload: true);
 | 
					    _resetMedia();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void toggleRandom() {
 | 
					  void toggleRandom() {
 | 
				
			||||||
    _random = !_random;
 | 
					    _random = !_random;
 | 
				
			||||||
    loadMedia(reload: true);
 | 
					    _resetMedia();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setTag(String? tag) {
 | 
					  void setTag(String? tag) {
 | 
				
			||||||
    _tag = tag;
 | 
					    _tag = tag;
 | 
				
			||||||
    loadMedia(reload: true);
 | 
					    _resetMedia();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setCrossAxisCount(int crossAxisCount) {
 | 
					  void setCrossAxisCount(int crossAxisCount) {
 | 
				
			||||||
@@ -50,7 +51,8 @@ class MediaProvider extends ChangeNotifier {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  void setMediaItems(List<MediaItem> mediaItems) {
 | 
					  void setMediaItems(List<MediaItem> mediaItems) {
 | 
				
			||||||
    if (_mediaItems != mediaItems) {
 | 
					    if (_mediaItems != mediaItems) {
 | 
				
			||||||
      _mediaItems = mediaItems;
 | 
					      _mediaItems.clear();
 | 
				
			||||||
 | 
					      _mediaItems.addAll(mediaItems);
 | 
				
			||||||
      notifyListeners();
 | 
					      notifyListeners();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -60,25 +62,27 @@ class MediaProvider extends ChangeNotifier {
 | 
				
			|||||||
    notifyListeners();
 | 
					    notifyListeners();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<void> loadMedia({bool reload = false, bool notify = true}) async {
 | 
					  void _resetMedia() {
 | 
				
			||||||
 | 
					    _mediaItems.clear();
 | 
				
			||||||
 | 
					    notifyListeners();
 | 
				
			||||||
 | 
					    loadMedia();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Future<void> loadMedia({bool notify = true}) async {
 | 
				
			||||||
    if (_isLoading) return;
 | 
					    if (_isLoading) return;
 | 
				
			||||||
    _isLoading = true;
 | 
					    _isLoading = true;
 | 
				
			||||||
    if (notify) notifyListeners();
 | 
					    if (notify) notifyListeners();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      final newMedia = await fetchMedia(
 | 
					      final newMedia = await fetchMedia(
 | 
				
			||||||
        older: reload
 | 
					        older: _mediaItems.isNotEmpty ? _mediaItems.last.id : null,
 | 
				
			||||||
            ? null
 | 
					 | 
				
			||||||
            : _mediaItems.isNotEmpty
 | 
					 | 
				
			||||||
            ? _mediaItems.last.id
 | 
					 | 
				
			||||||
            : null,
 | 
					 | 
				
			||||||
        type: type,
 | 
					        type: type,
 | 
				
			||||||
        mode: mode,
 | 
					        mode: mode,
 | 
				
			||||||
        random: random,
 | 
					        random: random,
 | 
				
			||||||
        tag: tag,
 | 
					        tag: tag,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      reload ? setMediaItems(newMedia) : addMediaItems(newMedia);
 | 
					      addMediaItems(newMedia);
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
      debugPrint('Fehler beim Laden der Medien: $e');
 | 
					      debugPrint('Fehler beim Laden der Medien: $e');
 | 
				
			||||||
    } finally {
 | 
					    } finally {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,14 +31,12 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
    final initialIndex = provider.mediaItems.indexWhere(
 | 
					    final initialIndex = provider.mediaItems.indexWhere(
 | 
				
			||||||
      (item) => item.id == widget.initialItemId,
 | 
					      (item) => item.id == widget.initialItemId,
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    _pageController = PageController(initialPage: initialIndex);
 | 
					    _pageController = PageController(initialPage: initialIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _currentIndex = initialIndex;
 | 
					    _currentIndex = initialIndex;
 | 
				
			||||||
    _pageController.addListener(() {
 | 
					    _pageController.addListener(() {
 | 
				
			||||||
      setState(() {
 | 
					      setState(() => _currentIndex = _pageController.page?.round() ?? 0);
 | 
				
			||||||
        _currentIndex = _pageController.page?.round() ?? 0;
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _preloadAdjacentMedia(initialIndex);
 | 
					    _preloadAdjacentMedia(initialIndex);
 | 
				
			||||||
@@ -97,10 +95,7 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
    final provider = Provider.of<MediaProvider>(context);
 | 
					    final provider = Provider.of<MediaProvider>(context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return Scaffold(
 | 
					    return Scaffold(
 | 
				
			||||||
      appBar: AppBar(
 | 
					      appBar: AppBar(centerTitle: true, title: const Text('f0ck')),
 | 
				
			||||||
        centerTitle: true,
 | 
					 | 
				
			||||||
        title: Text('f0ck #${provider.mediaItems.elementAt(_currentIndex).id.toString()} (${provider.type})'),
 | 
					 | 
				
			||||||
      ),
 | 
					 | 
				
			||||||
      body: Stack(
 | 
					      body: Stack(
 | 
				
			||||||
        children: [
 | 
					        children: [
 | 
				
			||||||
          PageTransformer(
 | 
					          PageTransformer(
 | 
				
			||||||
@@ -157,7 +152,7 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
            VideoWidget(details: item, isActive: isActive),
 | 
					            VideoWidget(details: item, isActive: isActive),
 | 
				
			||||||
          const SizedBox(height: 20),
 | 
					          const SizedBox(height: 20),
 | 
				
			||||||
          Text(
 | 
					          Text(
 | 
				
			||||||
            item.mime,
 | 
					            'f0ck #${item.id.toString()}',
 | 
				
			||||||
            style: const TextStyle(color: Colors.white, fontSize: 18),
 | 
					            style: const TextStyle(color: Colors.white, fontSize: 18),
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
          const SizedBox(height: 10, width: double.infinity),
 | 
					          const SizedBox(height: 10, width: double.infinity),
 | 
				
			||||||
@@ -170,7 +165,7 @@ class _DetailViewState extends State<DetailView> {
 | 
				
			|||||||
                  if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
 | 
					                  if (tag.tag == 'sfw' || tag.tag == 'nsfw') return;
 | 
				
			||||||
                  setState(() {
 | 
					                  setState(() {
 | 
				
			||||||
                    provider.setTag(tag.tag);
 | 
					                    provider.setTag(tag.tag);
 | 
				
			||||||
                    Navigator.pop(context);
 | 
					                    Navigator.pop(context, true);
 | 
				
			||||||
                  });
 | 
					                  });
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                label: Text(tag.tag),
 | 
					                label: Text(tag.tag),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,10 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void scrollToTop() {
 | 
				
			||||||
 | 
					    _scrollController.jumpTo(0);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    final provider = Provider.of<MediaProvider>(context);
 | 
					    final provider = Provider.of<MediaProvider>(context);
 | 
				
			||||||
@@ -48,7 +52,10 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
            icon: Icon(
 | 
					            icon: Icon(
 | 
				
			||||||
              provider.random ? Icons.shuffle_on_outlined : Icons.shuffle,
 | 
					              provider.random ? Icons.shuffle_on_outlined : Icons.shuffle,
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            onPressed: () => provider.toggleRandom(),
 | 
					            onPressed: () {
 | 
				
			||||||
 | 
					              provider.toggleRandom();
 | 
				
			||||||
 | 
					              _scrollController.jumpTo(0);
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
          IconButton(
 | 
					          IconButton(
 | 
				
			||||||
            icon: const Icon(Icons.menu),
 | 
					            icon: const Icon(Icons.menu),
 | 
				
			||||||
@@ -78,6 +85,7 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
              onChanged: (String? newValue) {
 | 
					              onChanged: (String? newValue) {
 | 
				
			||||||
                if (newValue != null) {
 | 
					                if (newValue != null) {
 | 
				
			||||||
                  provider.setType(newValue);
 | 
					                  provider.setType(newValue);
 | 
				
			||||||
 | 
					                  _scrollController.jumpTo(0);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
@@ -96,6 +104,7 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
              onChanged: (String? newValue) {
 | 
					              onChanged: (String? newValue) {
 | 
				
			||||||
                if (newValue != null) {
 | 
					                if (newValue != null) {
 | 
				
			||||||
                  provider.setMode(provider.modes.indexOf(newValue));
 | 
					                  provider.setMode(provider.modes.indexOf(newValue));
 | 
				
			||||||
 | 
					                  _scrollController.jumpTo(0);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
@@ -125,6 +134,7 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
                    labelStyle: const TextStyle(color: Colors.white),
 | 
					                    labelStyle: const TextStyle(color: Colors.white),
 | 
				
			||||||
                    onDeleted: () {
 | 
					                    onDeleted: () {
 | 
				
			||||||
                      provider.setTag(null);
 | 
					                      provider.setTag(null);
 | 
				
			||||||
 | 
					                      _scrollController.jumpTo(0);
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                  ),
 | 
					                  ),
 | 
				
			||||||
                ],
 | 
					                ],
 | 
				
			||||||
@@ -133,7 +143,8 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
          : null,
 | 
					          : null,
 | 
				
			||||||
      body: RefreshIndicator(
 | 
					      body: RefreshIndicator(
 | 
				
			||||||
        onRefresh: () async {
 | 
					        onRefresh: () async {
 | 
				
			||||||
          await provider.loadMedia(reload: true);
 | 
					          await provider.resetMedia();
 | 
				
			||||||
 | 
					          _scrollController.jumpTo(0);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        child: Consumer<MediaProvider>(
 | 
					        child: Consumer<MediaProvider>(
 | 
				
			||||||
          builder: (context, mediaProvider, child) {
 | 
					          builder: (context, mediaProvider, child) {
 | 
				
			||||||
@@ -158,12 +169,17 @@ class _MediaGridState extends State<MediaGrid> {
 | 
				
			|||||||
                final item = provider.mediaItems[index];
 | 
					                final item = provider.mediaItems[index];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return InkWell(
 | 
					                return InkWell(
 | 
				
			||||||
                  onTap: () => Navigator.push(
 | 
					                  onTap: () async {
 | 
				
			||||||
                    context,
 | 
					                    bool test = await Navigator.push(
 | 
				
			||||||
                    MaterialPageRoute(
 | 
					                      context,
 | 
				
			||||||
                      builder: (context) => DetailView(initialItemId: item.id),
 | 
					                      MaterialPageRoute(
 | 
				
			||||||
                    ),
 | 
					                        builder: (context) => DetailView(initialItemId: item.id),
 | 
				
			||||||
                  ),
 | 
					                      ),
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					                    if (test) {
 | 
				
			||||||
 | 
					                      scrollToTop();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
                  child: Stack(
 | 
					                  child: Stack(
 | 
				
			||||||
                    fit: StackFit.expand,
 | 
					                    fit: StackFit.expand,
 | 
				
			||||||
                    children: <Widget>[
 | 
					                    children: <Widget>[
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 | 
				
			|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 | 
					# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 | 
				
			||||||
# In Windows, build-name is used as the major, minor, and patch parts
 | 
					# In Windows, build-name is used as the major, minor, and patch parts
 | 
				
			||||||
# of the product and file versions while build-number is used as the build suffix.
 | 
					# of the product and file versions while build-number is used as the build suffix.
 | 
				
			||||||
version: 1.0.28+28
 | 
					version: 1.0.29+29
 | 
				
			||||||
 | 
					
 | 
				
			||||||
environment:
 | 
					environment:
 | 
				
			||||||
  sdk: ^3.9.0-100.2.beta
 | 
					  sdk: ^3.9.0-100.2.beta
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user