v1.1.6+36
All checks were successful
Flutter Schmutter / build (push) Successful in 3m34s

- new theme: p1nk
- optimizations
This commit is contained in:
Flummi 2025-06-07 23:07:31 +02:00
parent 836a0886e2
commit ffbde73300
5 changed files with 117 additions and 75 deletions

View File

@ -1,8 +1,18 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
final Map<String, ThemeData> themeMap = {
'f0ck': f0ckTheme,
'P1nk': p1nkTheme, // done
'Orange': orangeTheme,
'Amoled': amoledTheme,
'Paper': paperTheme,
//'Iced': icedTheme,
'f0ck95': f0ck95Theme,
'f0ck95d': f0ck95dTheme,
};
class ThemeNotifier extends StateNotifier<ThemeData> { class ThemeNotifier extends StateNotifier<ThemeData> {
final FlutterSecureStorage secureStorage; final FlutterSecureStorage secureStorage;
@ -11,23 +21,24 @@ class ThemeNotifier extends StateNotifier<ThemeData> {
} }
Future<void> _loadTheme() async { Future<void> _loadTheme() async {
try {
String? savedThemeName = await secureStorage.read(key: 'theme'); String? savedThemeName = await secureStorage.read(key: 'theme');
if (savedThemeName != null) { if (savedThemeName != null && themeMap.containsKey(savedThemeName)) {
final customTheme = themes.firstWhere( state = themeMap[savedThemeName]!;
(t) => t.name == savedThemeName, }
orElse: () => CustomTheme(name: 'f0ck', theme: f0ckTheme), } catch (error) {
); debugPrint('Fehler beim Laden des Themes: $error');
state = customTheme.theme; state = f0ckTheme;
} }
} }
Future<void> updateTheme(String themeName) async { Future<void> updateTheme(String themeName) async {
try {
await secureStorage.write(key: 'theme', value: themeName); await secureStorage.write(key: 'theme', value: themeName);
final newTheme = themes.firstWhere( state = themeMap[themeName] ?? f0ckTheme;
(t) => t.name == themeName, } catch (error) {
orElse: () => CustomTheme(name: 'f0ck', theme: f0ckTheme), debugPrint('Fehler beim Aktualisieren des Themes: $error');
); }
state = newTheme.theme;
} }
} }
@ -35,28 +46,12 @@ final themeNotifierProvider = StateNotifierProvider<ThemeNotifier, ThemeData>((
ref, ref,
) { ) {
return ThemeNotifier( return ThemeNotifier(
secureStorage: FlutterSecureStorage( secureStorage: const FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true), aOptions: AndroidOptions(encryptedSharedPreferences: true),
), ),
); );
}); });
class CustomTheme {
final String name;
final ThemeData theme;
CustomTheme({required this.name, required this.theme});
}
final List<CustomTheme> themes = [
CustomTheme(name: 'f0ck', theme: f0ckTheme),
CustomTheme(name: 'Paper', theme: paperTheme),
CustomTheme(name: 'Orange', theme: orangeTheme),
CustomTheme(name: 'Amoled', theme: amoledTheme),
CustomTheme(name: 'f0ck95', theme: f0ck95Theme),
CustomTheme(name: 'f0ck95d', theme: f0ck95dTheme),
];
final ThemeData f0ckTheme = ThemeData( final ThemeData f0ckTheme = ThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
primaryColor: const Color(0xFF9FFF00), primaryColor: const Color(0xFF9FFF00),
@ -78,13 +73,53 @@ final ThemeData f0ckTheme = ThemeData(
bodyLarge: TextStyle(color: Colors.white), bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white), bodyMedium: TextStyle(color: Colors.white),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: const Color(0xFF9FFF00), style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: const Color(0xFF000000),
backgroundColor: const Color(0xFF9FFF00),
),
), ),
scrollbarTheme: ScrollbarThemeData( scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)), thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)), trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
),
);
final ThemeData p1nkTheme = ThemeData(
brightness: Brightness.dark,
primaryColor: const Color(0xFF171717),
scaffoldBackgroundColor: const Color(0xFF171717),
appBarTheme: const AppBarTheme(
color: Color(0xFF2B2B2B),
foregroundColor: Color(0xFFFF00D0),
elevation: 2,
),
textTheme: const TextTheme(
bodyLarge: TextStyle(color: Color(0xFFFFFFFF)),
bodyMedium: TextStyle(color: Color(0xFFFFFFFF)),
titleLarge: TextStyle(color: Color(0xFFFFFFFF)),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF000000),
backgroundColor: const Color(0xFFFF00D0),
),
),
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: Color(0xFFFF00D0),
),
scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStateProperty.all(const Color(0xFF2B2B2B)),
trackColor: WidgetStateProperty.all(const Color(0xFF424242)),
),
colorScheme: const ColorScheme.dark(
primary: Color(0xFF171717),
secondary: Color(0xFFFF00D0),
surface: Color(0xFF171717),
onPrimary: Color(0xFFFFFFFF),
onSecondary: Color(0xFF000000),
onSurface: Color(0xFFFFFFFF),
error: Color(0xFFA72828),
), ),
); );
@ -109,9 +144,11 @@ final ThemeData paperTheme = ThemeData(
bodyLarge: TextStyle(color: Color(0xFF000000)), bodyLarge: TextStyle(color: Color(0xFF000000)),
bodyMedium: TextStyle(color: Color(0xFF000000)), bodyMedium: TextStyle(color: Color(0xFF000000)),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: const Color(0xFF000000), style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: const Color(0xFFFFFFFF),
backgroundColor: const Color(0xFF000000),
),
), ),
); );
@ -136,13 +173,15 @@ final ThemeData orangeTheme = ThemeData(
bodyLarge: TextStyle(color: Colors.white), bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white), bodyMedium: TextStyle(color: Colors.white),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: const Color(0xFFFF6F00), style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: Colors.white,
backgroundColor: const Color(0xFFFF6F00),
),
), ),
scrollbarTheme: ScrollbarThemeData( scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)), thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)), trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
), ),
); );
@ -169,9 +208,11 @@ final ThemeData amoledTheme = ThemeData(
bodyLarge: TextStyle(color: Colors.white), bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white), bodyMedium: TextStyle(color: Colors.white),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: const Color(0xFFFFFFFF), style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: Colors.black,
backgroundColor: const Color(0xFFFFFFFF),
),
), ),
scrollbarTheme: ScrollbarThemeData( scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF1D1C1C)), thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF1D1C1C)),
@ -199,13 +240,15 @@ final ThemeData f0ck95Theme = ThemeData(
bodyLarge: TextStyle(color: Colors.black), bodyLarge: TextStyle(color: Colors.black),
bodyMedium: TextStyle(color: Colors.black), bodyMedium: TextStyle(color: Colors.black),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: Colors.black, style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: Colors.white,
backgroundColor: Colors.black,
),
), ),
scrollbarTheme: ScrollbarThemeData( scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)), thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)), trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
), ),
); );
@ -229,12 +272,14 @@ final ThemeData f0ck95dTheme = ThemeData(
bodyLarge: TextStyle(color: Colors.white), bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white), bodyMedium: TextStyle(color: Colors.white),
), ),
buttonTheme: ButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
buttonColor: Colors.white, style: ElevatedButton.styleFrom(
textTheme: ButtonTextTheme.primary, foregroundColor: Colors.black,
backgroundColor: Colors.white,
),
), ),
scrollbarTheme: ScrollbarThemeData( scrollbarTheme: ScrollbarThemeData(
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)), thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)), trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
), ),
); );

View File

@ -48,17 +48,14 @@ class _DetailViewState extends ConsumerState<DetailView> {
void _preloadAdjacentMedia(int index) async { void _preloadAdjacentMedia(int index) async {
final mediaState = ref.read(mediaProvider); final mediaState = ref.read(mediaProvider);
if (index + 1 < mediaState.mediaItems.length) { for (int offset in [-1, 1]) {
final nextUrl = mediaState.mediaItems[index + 1].mediaUrl; final adjacentIndex = index + offset;
if (await DefaultCacheManager().getFileFromCache(nextUrl) == null) { if (adjacentIndex >= 0 && adjacentIndex < mediaState.mediaItems.length) {
await DefaultCacheManager().downloadFile(nextUrl); final url = mediaState.mediaItems[adjacentIndex].mediaUrl;
if (await DefaultCacheManager().getFileFromCache(url) == null) {
await DefaultCacheManager().downloadFile(url);
} }
} }
if (index - 1 >= 0) {
final prevUrl = mediaState.mediaItems[index - 1].mediaUrl;
if (await DefaultCacheManager().getFileFromCache(prevUrl) == null) {
await DefaultCacheManager().downloadFile(prevUrl);
}
} }
} }

View File

@ -208,17 +208,19 @@ class _MediaGridState extends ConsumerState<MediaGrid> {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column( child: Column(
children: themes.map((themeData) { children: themeMap.entries.map((entry) {
final themeName = entry.key;
final themeData = entry.value;
final currentTheme = ref.watch(themeNotifierProvider); final currentTheme = ref.watch(themeNotifierProvider);
final isSelected = currentTheme == themeData.theme; final isSelected = currentTheme == themeData;
return ListTile( return ListTile(
title: Text(themeData.name), title: Text(themeName),
selected: isSelected, selected: isSelected,
selectedTileColor: Colors.blue.withValues(alpha: 0.2), selectedTileColor: Colors.blue.withValues(alpha: 0.2),
onTap: () async { onTap: () async {
await ref await ref
.read(themeNotifierProvider.notifier) .read(themeNotifierProvider.notifier)
.updateTheme(themeData.name); .updateTheme(themeName);
}, },
); );
}).toList(), }).toList(),
@ -226,7 +228,6 @@ class _MediaGridState extends ConsumerState<MediaGrid> {
), ),
], ],
), ),
ListTile( ListTile(
title: Text('v${AppVersion.version}'), title: Text('v${AppVersion.version}'),
onTap: () { onTap: () {

View File

@ -89,7 +89,6 @@ class VideoControlsOverlay extends ConsumerWidget {
bottom: 12, bottom: 12,
child: Text( child: Text(
'${_formatDuration(controller.value.position)} / ${_formatDuration(controller.value.duration)}', '${_formatDuration(controller.value.position)} / ${_formatDuration(controller.value.duration)}',
style: TextStyle(color: Colors.white),
), ),
), ),
Listener( Listener(
@ -153,7 +152,7 @@ class _ControlButton extends StatelessWidget {
color: Colors.black.withValues(alpha: 0.4), color: Colors.black.withValues(alpha: 0.4),
), ),
child: IconButton( child: IconButton(
icon: Icon(icon, color: Colors.white, size: size), icon: Icon(icon, size: size),
onPressed: onPressed, onPressed: onPressed,
), ),
); );

View File

@ -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.1.5+35 version: 1.1.6+36
environment: environment:
sdk: ^3.9.0-100.2.beta sdk: ^3.9.0-100.2.beta