diff --git a/.vscode/settings.json b/.vscode/settings.json index fab9821..553928e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,4 +17,5 @@ "/pubspec.yaml", "/.github/workflows" ], + "dart.flutterRunAdditionalArgs": [ "--no-enable-impeller" ] } \ No newline at end of file diff --git a/README.md b/README.md index 1dcbc67..843bff8 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ If you like the project and you want to contribute with the development, you can - [expandable](https://pub.dev/packages/expandable) - [package info plus](https://pub.dev/packages/package_info_plus) - [flutter phoenix](https://pub.dev/packages/flutter_phoenix) +- [flutter displaymode](https://pub.dev/packages/flutter_displaymode) - [flutter launcher icons](https://pub.dev/packages/flutter_launcher_icons) - [flutter native splash](https://pub.dev/packages/flutter_native_splash) - [intl](https://pub.dev/packages/intl) diff --git a/lib/config/theme.dart b/lib/config/theme.dart index eba0b9c..93b5365 100644 --- a/lib/config/theme.dart +++ b/lib/config/theme.dart @@ -27,12 +27,11 @@ ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData( dialogTheme: DialogTheme( surfaceTintColor: dynamicColorScheme?.surfaceTint ), - // DISABLE PREDICTIVE BACK GESTURE - // pageTransitionsTheme: const PageTransitionsTheme( - // builders: { - // TargetPlatform.android: PredictiveBackPageTransitionsBuilder() - // } - // ) + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder() + } + ) ); ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData( @@ -63,12 +62,11 @@ ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData( dialogTheme: DialogTheme( surfaceTintColor: dynamicColorScheme?.surfaceTint ), - // DISABLE PREDICTIVE BACK GESTURE - // pageTransitionsTheme: const PageTransitionsTheme( - // builders: { - // TargetPlatform.android: PredictiveBackPageTransitionsBuilder() - // } - // ) + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder() + } + ) ); ThemeData lightThemeOldVersions(MaterialColor primaryColor) => ThemeData( @@ -87,12 +85,11 @@ ThemeData lightThemeOldVersions(MaterialColor primaryColor) => ThemeData( iconColor: Color.fromRGBO(117, 117, 117, 1), ), brightness: Brightness.light, - // DISABLE PREDICTIVE BACK GESTURE - // pageTransitionsTheme: const PageTransitionsTheme( - // builders: { - // TargetPlatform.android: PredictiveBackPageTransitionsBuilder() - // } - // ) + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder() + } + ) ); ThemeData darkThemeOldVersions(MaterialColor primaryColor) => ThemeData( @@ -114,10 +111,9 @@ ThemeData darkThemeOldVersions(MaterialColor primaryColor) => ThemeData( iconColor: Color.fromRGBO(187, 187, 187, 1), ), brightness: Brightness.dark, - // DISABLE PREDICTIVE BACK GESTURE - // pageTransitionsTheme: const PageTransitionsTheme( - // builders: { - // TargetPlatform.android: PredictiveBackPageTransitionsBuilder() - // } - // ) + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder() + } + ) ); \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 6402b70..61126da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:provider/provider.dart'; +import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:dynamic_color/dynamic_color.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart'; @@ -196,9 +197,37 @@ void main() async { } } -class Main extends StatelessWidget { +class Main extends StatefulWidget { const Main({super.key}); + @override + State
createState() => _MainState(); +} + +class _MainState extends State
{ + List modes = []; + DisplayMode? active; + DisplayMode? preferred; + + Future displayMode() async { + try { + modes = await FlutterDisplayMode.supported; + preferred = await FlutterDisplayMode.preferred; + active = await FlutterDisplayMode.active; + await FlutterDisplayMode.setHighRefreshRate(); + setState(() {}); + } catch (_) { + // ---- // + } + } + + @override + void initState() { + displayMode(); + + super.initState(); + } + @override Widget build(BuildContext context) { final appConfigProvider = Provider.of(context); diff --git a/lib/screens/settings/update_server/update_screen.dart b/lib/screens/settings/update_server/update_screen.dart index ae894f8..4ddc959 100644 --- a/lib/screens/settings/update_server/update_screen.dart +++ b/lib/screens/settings/update_server/update_screen.dart @@ -218,110 +218,101 @@ class _Header extends SliverPersistentHeaderDelegate { final iconBottom = _iconMinBottomPositionExent + (iconMaxBottomPositionExent-iconMinBottomPositionExent)*(1-iconPercentage); return LayoutBuilder( - builder: (context, constraints) => Stack( - children: [ - Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface, - ), - ), - Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surfaceTint.withOpacity(0.075), - ), - child: Align( - alignment: Alignment.topLeft, - child: SafeArea( - bottom: false, - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - children: [ - if (Navigator.of(context).canPop()) Positioned( - top: 8, - left: 0, - child: BackButton( - onPressed: () => Navigator.pop(context), - ), - ), - Positioned( - top: 8, - right: 0, - child: IconButton( - onPressed: onRefresh, - icon: const Icon(Icons.refresh_rounded), - tooltip: AppLocalizations.of(context)!.refresh, - ) - ), - Positioned( - bottom: iconBottom, - left: (constraints.maxWidth/2)-(_iconSize/2), - child: Opacity( - opacity: 1-iconPercentage, - child: serversProvider.updateAvailable.loadStatus == LoadStatus.loading - ? const Column( - children: [ - CircularProgressIndicator(), - SizedBox(height: 4) - ], - ) - : Icon( - serversProvider.updateAvailable.data!.canAutoupdate == true - ? Icons.system_update_rounded - : Icons.system_security_update_good_rounded, - size: _iconSize, - color: Theme.of(context).colorScheme.primary, - ), - ), - ), - Positioned( - bottom: mainText, - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth-100 - ), - child: Text( - serversProvider.updateAvailable.loadStatus == LoadStatus.loading - ? AppLocalizations.of(context)!.checkingUpdates - : serversProvider.updateAvailable.data!.canAutoupdate == true - ? AppLocalizations.of(context)!.updateAvailable - : AppLocalizations.of(context)!.serverUpdated, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: textFontSize, - fontWeight: FontWeight.w400 - ), - ), - ) - ), - Positioned( - bottom: versionText, - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth-100 - ), - child: Opacity( - opacity: 1-iconPercentage, - child: Text( - serversProvider.updateAvailable.data!.canAutoupdate == true - ? "${AppLocalizations.of(context)!.newVersion}: ${serversProvider.updateAvailable.data!.newVersion ?? 'N/A'}" - : "${AppLocalizations.of(context)!.installedVersion}: ${serversProvider.updateAvailable.data!.currentVersion}", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w700, - color: Theme.of(context).colorScheme.onSurfaceVariant - ), - ), - ), - ) - ) - ], + builder: (context, constraints) => Container( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + child: Align( + alignment: Alignment.topLeft, + child: SafeArea( + bottom: false, + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + children: [ + if (Navigator.of(context).canPop()) Positioned( + top: 8, + left: 0, + child: BackButton( + onPressed: () => Navigator.pop(context), + ), ), - ), + Positioned( + top: 8, + right: 0, + child: IconButton( + onPressed: onRefresh, + icon: const Icon(Icons.refresh_rounded), + tooltip: AppLocalizations.of(context)!.refresh, + ) + ), + Positioned( + bottom: iconBottom, + left: (constraints.maxWidth/2)-(_iconSize/2), + child: Opacity( + opacity: 1-iconPercentage, + child: serversProvider.updateAvailable.loadStatus == LoadStatus.loading + ? const Column( + children: [ + CircularProgressIndicator(), + SizedBox(height: 4) + ], + ) + : Icon( + serversProvider.updateAvailable.data!.canAutoupdate == true + ? Icons.system_update_rounded + : Icons.system_security_update_good_rounded, + size: _iconSize, + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + Positioned( + bottom: mainText, + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth-100 + ), + child: Text( + serversProvider.updateAvailable.loadStatus == LoadStatus.loading + ? AppLocalizations.of(context)!.checkingUpdates + : serversProvider.updateAvailable.data!.canAutoupdate == true + ? AppLocalizations.of(context)!.updateAvailable + : AppLocalizations.of(context)!.serverUpdated, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: textFontSize, + fontWeight: FontWeight.w400 + ), + ), + ) + ), + Positioned( + bottom: versionText, + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth-100 + ), + child: Opacity( + opacity: 1-iconPercentage, + child: Text( + serversProvider.updateAvailable.data!.canAutoupdate == true + ? "${AppLocalizations.of(context)!.newVersion}: ${serversProvider.updateAvailable.data!.newVersion ?? 'N/A'}" + : "${AppLocalizations.of(context)!.installedVersion}: ${serversProvider.updateAvailable.data!.currentVersion}", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + color: Theme.of(context).colorScheme.onSurfaceVariant + ), + ), + ), + ) + ) + ], ), ), - ], + ), ), ); } diff --git a/pubspec.lock b/pubspec.lock index 207783c..d407566 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: archive - sha256: "7dcbd0f87fe5f61cb28da39a1a8b70dbc106e2fe0516f7836eb7bb2948481a12" + sha256: "0c64e928dcbefddecd234205422bcfc2b5e6d31be0b86fef0d0dd48d7b4c9742" url: "https://pub.dev" source: hosted - version: "4.0.5" + version: "4.0.4" args: dependency: transitive description: @@ -254,6 +254,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + flutter_displaymode: + dependency: "direct main" + description: + name: flutter_displaymode + sha256: "42c5e9abd13d28ed74f701b60529d7f8416947e58256e6659c5550db719c57ef" + url: "https://pub.dev" + source: hosted + version: "0.6.0" flutter_dotenv: dependency: "direct main" description: @@ -361,10 +369,10 @@ packages: dependency: transitive description: name: image - sha256: "4e973fcf4caae1a4be2fa0a13157aa38a8f9cb049db6529aa00b4d71abc4d928" + sha256: "13d3349ace88f12f4a0d175eb5c12dcdd39d35c4c109a8a13dfeb6d0bd9e31c3" url: "https://pub.dev" source: hosted - version: "4.5.4" + version: "4.5.3" intl: dependency: "direct main" description: @@ -774,10 +782,10 @@ packages: dependency: "direct main" description: name: sqlite3_flutter_libs - sha256: "1a96b59227828d9eb1463191d684b37a27d66ee5ed7597fcf42eee6452c88a14" + sha256: "7adb4cc96dc08648a5eb1d80a7619070796ca6db03901ff2b6dcb15ee30468f3" url: "https://pub.dev" source: hosted - version: "0.5.32" + version: "0.5.31" stack_trace: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2fffd97..306048b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,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: 2.20.4+151 +version: 2.20.3+150 environment: sdk: '>=2.18.1 <3.0.0' @@ -42,6 +42,7 @@ dependencies: provider: ^6.1.1 sqflite: ^2.3.0 package_info_plus: ^8.0.0 + flutter_displaymode: ^0.6.0 dynamic_color: ^1.7.0 animations: ^2.0.10 device_info_plus: ^11.2.1