From 78ff1953adf970095d52807158c7a4553942e2bc Mon Sep 17 00:00:00 2001 From: Flummi Date: Fri, 6 Jun 2025 08:43:50 +0200 Subject: [PATCH] v1.0.28+28 --- lib/main.dart | 2 + lib/providers/MediaProvider.dart | 12 ++-- lib/screens/DetailView.dart | 17 ++++- lib/screens/MediaGrid.dart | 66 +++---------------- lib/utils/AppVersion.dart | 10 +++ macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 24 +++++++ pubspec.yaml | 3 +- 8 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 lib/utils/AppVersion.dart diff --git a/lib/main.dart b/lib/main.dart index f73b914..ab80f62 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,12 +4,14 @@ import 'package:flutter/services.dart'; import 'package:f0ckapp/providers/MediaProvider.dart'; import 'package:f0ckapp/providers/ThemeProvider.dart'; import 'package:f0ckapp/screens/MediaGrid.dart'; +import 'package:f0ckapp/utils/AppVersion.dart'; import 'package:provider/provider.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + await AppVersion.init(); runApp( MultiProvider( diff --git a/lib/providers/MediaProvider.dart b/lib/providers/MediaProvider.dart index bfaec17..f9649d8 100644 --- a/lib/providers/MediaProvider.dart +++ b/lib/providers/MediaProvider.dart @@ -49,8 +49,10 @@ class MediaProvider extends ChangeNotifier { } void setMediaItems(List mediaItems) { - _mediaItems = mediaItems; - notifyListeners(); + if (_mediaItems != mediaItems) { + _mediaItems = mediaItems; + notifyListeners(); + } } void addMediaItems(List newItems) { @@ -58,10 +60,10 @@ class MediaProvider extends ChangeNotifier { notifyListeners(); } - Future loadMedia({bool reload = false}) async { + Future loadMedia({bool reload = false, bool notify = true}) async { if (_isLoading) return; _isLoading = true; - notifyListeners(); + if (notify) notifyListeners(); try { final newMedia = await fetchMedia( @@ -81,7 +83,7 @@ class MediaProvider extends ChangeNotifier { debugPrint('Fehler beim Laden der Medien: $e'); } finally { _isLoading = false; - notifyListeners(); + if(notify) notifyListeners(); } } } diff --git a/lib/screens/DetailView.dart b/lib/screens/DetailView.dart index 06872f1..bb4d5f6 100644 --- a/lib/screens/DetailView.dart +++ b/lib/screens/DetailView.dart @@ -21,6 +21,7 @@ class DetailView extends StatefulWidget { class _DetailViewState extends State { late PageController _pageController; bool isLoading = false; + int _currentIndex = 0; @override void initState() { @@ -30,8 +31,16 @@ class _DetailViewState extends State { final initialIndex = provider.mediaItems.indexWhere( (item) => item.id == widget.initialItemId, ); + _pageController = PageController(initialPage: initialIndex); + _currentIndex = initialIndex; + _pageController.addListener(() { + setState(() { + _currentIndex = _pageController.page?.round() ?? 0; + }); + }); + _preloadAdjacentMedia(initialIndex); } @@ -97,10 +106,12 @@ class _DetailViewState extends State { PageTransformer( controller: _pageController, pages: provider.mediaItems.map((item) { + int itemIndex = provider.mediaItems.indexOf(item); + return SafeArea( child: SmartRefreshIndicator( onRefresh: _loadMoreMedia, - child: _buildMediaItem(item), + child: _buildMediaItem(item, _currentIndex == itemIndex), ), ); }).toList(), @@ -129,7 +140,7 @@ class _DetailViewState extends State { ); } - Widget _buildMediaItem(MediaItem item) { + Widget _buildMediaItem(MediaItem item, bool isActive) { final provider = Provider.of(context); return SingleChildScrollView( @@ -143,7 +154,7 @@ class _DetailViewState extends State { errorWidget: (context, url, error) => Icon(Icons.error), ) else - VideoWidget(details: item, isActive: true), + VideoWidget(details: item, isActive: isActive), const SizedBox(height: 20), Text( item.mime, diff --git a/lib/screens/MediaGrid.dart b/lib/screens/MediaGrid.dart index d8291b3..ce791f9 100644 --- a/lib/screens/MediaGrid.dart +++ b/lib/screens/MediaGrid.dart @@ -3,6 +3,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:provider/provider.dart'; import 'package:f0ckapp/screens/DetailView.dart'; import 'package:f0ckapp/providers/MediaProvider.dart'; +import 'package:f0ckapp/utils/AppVersion.dart'; class MediaGrid extends StatefulWidget { const MediaGrid({super.key}); @@ -27,7 +28,7 @@ class _MediaGridState extends State { _scrollController.addListener(() { if (_scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 100) { - provider.loadMedia(); + provider.loadMedia(notify: false); } }); } @@ -41,8 +42,12 @@ class _MediaGridState extends State { key: scaffoldKey, appBar: AppBar( //centerTitle: true, - title: Text('f0ck v1.0.27+27'), + title: Text('fApp v${AppVersion.version}'), actions: [ + IconButton( + icon: Icon(provider.random ? Icons.shuffle_on_outlined : Icons.shuffle), + onPressed: () => provider.toggleRandom(), + ), IconButton( icon: const Icon(Icons.menu), onPressed: () { @@ -103,62 +108,6 @@ class _MediaGridState extends State { padding: EdgeInsets.all(0), child: Image.asset('assets/images/menu.webp', fit: BoxFit.cover), ), - /*ListTile( - title: Text( - 'All', - style: TextStyle( - fontWeight: provider.type == 'alles' - ? FontWeight.bold - : FontWeight.normal, - color: provider.type == 'alles' ? Colors.blue : Colors.white, - ), - ), - onTap: () { - provider.setType('all'); - }, - ), - ListTile( - title: Text( - 'Images', - style: TextStyle( - fontWeight: provider.type == 'image' - ? FontWeight.bold - : FontWeight.normal, - color: provider.type == 'image' ? Colors.blue : Colors.white, - ), - ), - onTap: () { - provider.setType('image'); - }, - ), - ListTile( - title: Text( - 'Videos', - style: TextStyle( - fontWeight: provider.type == 'video' - ? FontWeight.bold - : FontWeight.normal, - color: provider.type == 'video' ? Colors.blue : Colors.white, - ), - ), - onTap: () { - provider.setType('video'); - }, - ), - ListTile( - title: Text( - 'Audio', - style: TextStyle( - fontWeight: provider.type == 'audio' - ? FontWeight.bold - : FontWeight.normal, - color: provider.type == 'audio' ? Colors.blue : Colors.white, - ), - ), - onTap: () { - provider.setType('audio'); - }, - ),*/ ], ), ), @@ -187,6 +136,7 @@ class _MediaGridState extends State { child: Consumer( builder: (context, mediaProvider, child) { return GridView.builder( + key: PageStorageKey('mediaGrid'), controller: _scrollController, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: mediaProvider.crossAxisCount == 0 diff --git a/lib/utils/AppVersion.dart b/lib/utils/AppVersion.dart new file mode 100644 index 0000000..8e3f8fc --- /dev/null +++ b/lib/utils/AppVersion.dart @@ -0,0 +1,10 @@ +import 'package:package_info_plus/package_info_plus.dart'; + +class AppVersion { + static String version = ""; + + static Future init() async { + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + version = '${packageInfo.version}+${packageInfo.buildNumber}'; + } +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 68402fa..adbca18 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,11 +5,13 @@ import FlutterMacOS import Foundation +import package_info_plus import path_provider_foundation import sqflite_darwin import video_player_avfoundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin")) diff --git a/pubspec.lock b/pubspec.lock index d3322be..2defe30 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -272,6 +272,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191" + url: "https://pub.dev" + source: hosted + version: "8.3.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c" + url: "https://pub.dev" + source: hosted + version: "3.2.0" path: dependency: transitive description: @@ -541,6 +557,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba" + url: "https://pub.dev" + source: hosted + version: "5.13.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4731dde..fccc8b2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 # 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. -version: 1.0.27+27 +version: 1.0.28+28 environment: sdk: ^3.9.0-100.2.beta @@ -38,6 +38,7 @@ dependencies: cached_network_image: ^3.4.1 cached_video_player_plus: ^3.0.3 provider: ^6.1.5 + package_info_plus: ^8.3.0 dev_dependencies: flutter_test: