diff --git a/assets/home/bout_de_bulle_dark.png b/assets/home/bout_de_bulle_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..c6c778ca9b5666bf608d0bc9cb94968098fbc999 Binary files /dev/null and b/assets/home/bout_de_bulle_dark.png differ diff --git a/assets/translations/en.json b/assets/translations/en.json index 306a84bc08832fef3b8dc978b1b08a8046e9acb1..f41c05305c4c233e29920cffcd2d9d9e908f90ae 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -289,5 +289,11 @@ "qrCodeNotAddress": "This QR code is not a valid address", "emptyWalletCannotBeCertified": "An empty wallet cannot be certified", "timeoutScanDerivations": "Scan derivations timed out. Please try again later.", - "errorScanDerivations": "An error occurred while scanning derivations. Please try again." + "errorScanDerivations": "An error occurred while scanning derivations. Please try again.", + "revokedAccountCannotBeCertified": "A revoked account cannot be certified", + "info": "Information", + "warning": "Warning", + "success": "Success", + "error": "Error", + "question": "Question" } diff --git a/assets/translations/es.json b/assets/translations/es.json index 23e5a273f11927fbd8efa889ae71a57858218387..e60da6f4f2860f170077f56cf0ea1f08df3e858c 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -290,5 +290,11 @@ "qrCodeNotAddress": "Este código QR no es una dirección válida", "emptyWalletCannotBeCertified": "Un monedero vacío no puede ser certificado", "timeoutScanDerivations": "Se ha agotado el tiempo de escaneo de derivaciones. Por favor, inténtelo de nuevo más tarde.", - "errorScanDerivations": "Se ha producido un error al escanear las derivaciones. Por favor, inténtelo de nuevo." + "errorScanDerivations": "Se ha producido un error al escanear las derivaciones. Por favor, inténtelo de nuevo.", + "revokedAccountCannotBeCertified": "Una cuenta revocada no puede ser certificada", + "info": "Información", + "warning": "Advertencia", + "success": "Éxito", + "error": "Error", + "question": "Pregunta" } diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 66ff74435bf49eaef9a4d4e9abab45e1fb15f2d1..dddbcafe06b968b7ff2dfe17d83345b0c28d4441 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -289,5 +289,11 @@ "qrCodeNotAddress": "Ce QR code n'est pas une adresse valide", "emptyWalletCannotBeCertified": "Un portefeuille vide ne peut pas être certifié", "timeoutScanDerivations": "Délai d'attente dépassé lors du scan des dérivations. Veuillez réessayer plus tard.", - "errorScanDerivations": "Une erreur s'est produite lors du scan des dérivations. Veuillez réessayer." + "errorScanDerivations": "Une erreur s'est produite lors du scan des dérivations. Veuillez réessayer.", + "revokedAccountCannotBeCertified": "Un compte révoqué ne peut pas être certifié", + "info": "Information", + "warning": "Attention", + "success": "Succès", + "error": "Erreur", + "question": "Question" } diff --git a/assets/translations/it.json b/assets/translations/it.json index 7376d21f08eba4208b90e910ed70e2e0a3051cd6..30fb11a2419993e369e09d82735ffdf2d368cf33 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -221,5 +221,11 @@ "qrCodeNotAddress": "Questo QR code non é un indirizzo valido", "emptyWalletCannotBeCertified": "Un portafoglio vuoto non puó essere certificato", "timeoutScanDerivations": "Timeout durante la scansione delle derivazioni. Si prega di riprovare più tardi.", - "errorScanDerivations": "Si è verificato un errore durante la scansione delle derivazioni. Si prega di riprovare." + "errorScanDerivations": "Si è verificato un errore durante la scansione delle derivazioni. Si prega di riprovare.", + "revokedAccountCannotBeCertified": "Un conto revocato non puó essere certificato", + "info": "Informazione", + "warning": "Attenzione", + "success": "Successo", + "error": "Errore", + "question": "Domanda" } \ No newline at end of file diff --git a/lib/exceptions.dart b/lib/exceptions.dart new file mode 100644 index 0000000000000000000000000000000000000000..94e29d2c14b5c517c46b4715764828e8c0153da5 --- /dev/null +++ b/lib/exceptions.dart @@ -0,0 +1,22 @@ +class NotMemberException implements Exception { + final String? message; + + const NotMemberException([this.message]); + + @override + String toString() { + if (message == null || message!.isEmpty) { + return "The user is not a member."; + } + return message!; + } +} + +class CantBeCertException implements Exception { + final String message; + + const CantBeCertException(this.message); + + @override + String toString() => "Cannot be certified.\nStatus: $message"; +} diff --git a/lib/extensions.dart b/lib/extensions.dart index b2ecff520fe34447694a6d972764e0a52296e219..17710df303301d0a0208b25d2d470e819ed47a54 100644 --- a/lib/extensions.dart +++ b/lib/extensions.dart @@ -1,3 +1,5 @@ +import 'package:flutter/material.dart'; + extension IterableExtension<T> on Iterable<T> { /// The first element satisfying [test], or `null` if there are none. T? firstWhereOrNull(bool Function(T element) test) { @@ -7,3 +9,13 @@ extension IterableExtension<T> on Iterable<T> { return null; } } + +extension ExtendedBuildContext on BuildContext { + TextTheme get textTheme => Theme.of(this).textTheme; + + ColorScheme get colorScheme => Theme.of(this).colorScheme; + + /// Is dark mode currently enabled? + bool get isDarkTheme => Theme.of(this).brightness == Brightness.dark; +} + diff --git a/lib/globals.dart b/lib/globals.dart index 7b9b826a133456a7cff795fb7667c3313805e6c9..ba4ace5ada40f50a58980b89d2e05a4d6fc71cb3 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -38,11 +38,11 @@ late BuildContext homeContext; final log = Logger(); // Colors -const Color orangeC = Color(0xffd07316); -const Color yellowC = Color(0xffFFD68E); -const Color floattingYellow = Color(0xffEFEFBF); -const Color backgroundColor = Color(0xFFF5F5F5); -const Color headerColor = Color(0xFFFFF3E0); +// const Color context.colorScheme.primary = Color(0xffd07316); // Moved to theme_provider.dart +// const Color yellowC = Color(0xffFFD68E); // Moved to theme_provider.dart +// const Color floattingYellow = Color(0xffEFEFBF); // Moved to theme_provider.dart +// const Color backgroundColor = Color(0xFFF5F5F5); // Moved to theme_provider.dart +// const Color headerColor = Color(0xFFFFF3E0); // Moved to theme_provider.dart // Substrate settings const String currencyName = 'ĞD'; diff --git a/lib/main.dart b/lib/main.dart index abf8a8767a9b894d3fcb3e7c4823d650b53e8da5..dac6c2ed6f3e6eecbf15dc527d98e4c29dfd7368 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -39,6 +39,7 @@ import 'package:responsive_framework/responsive_framework.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/providers/theme_provider.dart'; const bool enableSentry = true; @@ -134,68 +135,35 @@ class Gecko extends StatelessWidget { ChangeNotifierProvider(create: (_) => SubstrateSdk()), ChangeNotifierProvider(create: (_) => DuniterIndexer()), ChangeNotifierProvider(create: (_) => SettingsProvider()), - ChangeNotifierProvider(create: (_) => V2sDatapodProvider()) + ChangeNotifierProvider(create: (_) => V2sDatapodProvider()), + ChangeNotifierProvider(create: (_) => ThemeProvider()), ], - child: MaterialApp( - localizationsDelegates: context.localizationDelegates, - supportedLocales: context.supportedLocales, - locale: context.locale, - builder: (context, child) => ResponsiveBreakpoints.builder( - child: child!, - breakpoints: [ - const Breakpoint(start: 0, end: 450, name: MOBILE), - const Breakpoint(start: 451, end: 800, name: TABLET), - const Breakpoint(start: 801, end: double.infinity, name: DESKTOP), - ], - ), - title: 'Ğecko', - theme: ThemeData( - appBarTheme: const AppBarTheme( - elevation: 0, - backgroundColor: headerColor, - titleTextStyle: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.black87, - fontFamily: 'Roboto', + child: Consumer<ThemeProvider>( + builder: (context, themeProvider, child) { + return MaterialApp( + localizationsDelegates: context.localizationDelegates, + supportedLocales: context.supportedLocales, + locale: context.locale, + theme: lightTheme, + darkTheme: darkTheme, + themeMode: themeProvider.currentThemeMode, + builder: (context, child) => ResponsiveBreakpoints.builder( + child: child!, + breakpoints: [ + const Breakpoint(start: 0, end: 450, name: MOBILE), + const Breakpoint(start: 451, end: 800, name: TABLET), + const Breakpoint(start: 801, end: double.infinity, name: DESKTOP), + ], ), - ), - textTheme: const TextTheme( - titleLarge: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.black87, - fontFamily: 'Roboto', - ), - bodyMedium: TextStyle( - fontSize: 14, - color: Colors.black87, - fontFamily: 'Roboto', - ), - bodySmall: TextStyle( - fontSize: 13, - color: Colors.black54, - fontFamily: 'Roboto', - ), - labelMedium: TextStyle( - fontSize: 15, - fontFamily: 'Monospace', - fontWeight: FontWeight.w500, - ), - ), - primaryColor: const Color(0xffFFD58D), - scaffoldBackgroundColor: backgroundColor, - canvasColor: backgroundColor, - colorScheme: - ColorScheme.fromSwatch().copyWith(secondary: Colors.grey[850]), - dialogTheme: DialogThemeData(backgroundColor: backgroundColor), - ), - initialRoute: "/", - routes: { - '/': (context) => const HomeScreen(), - '/mywallets': (context) => const WalletsHome(), - '/search': (context) => const SearchScreen(), - '/searchResult': (context) => const SearchResultScreen(), + title: 'Ğecko', + initialRoute: "/", + routes: { + '/': (context) => const HomeScreen(), + '/mywallets': (context) => const WalletsHome(), + '/search': (context) => const SearchScreen(), + '/searchResult': (context) => const SearchResultScreen(), + }, + ); }, ), ); diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 058c16464a626dd58e8eb31fdbc55d7725c4af68..3a0e953fdca1d1b365a976cad2d05c14dcd9c81b 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -6,6 +6,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:fast_base58/fast_base58.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/exceptions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/certification_data.dart'; import 'package:gecko/models/membership_status.dart'; @@ -444,6 +445,8 @@ class SubstrateSdk with ChangeNotifier { return CertState(status: CertStatus.mustWaitBeforeCert, duration: Duration(seconds: certDelayDuration)); } else if (toStatus == IdtyStatus.created) { return CertState(status: CertStatus.mustConfirmIdentity); + } else if (toStatus == IdtyStatus.revoked) { + return CertState(status: CertStatus.revoked); } else { return CertState(status: CertStatus.canCert); } @@ -1104,7 +1107,7 @@ class SubstrateSdk with ChangeNotifier { final toIndex = await _getIdentityIndexOf(destAddress); if (myIdtyStatus != IdtyStatus.validated) { - return 'notMember'; + throw NotMemberException(); } final sender = await _setSender(fromAddress); @@ -1147,7 +1150,7 @@ class SubstrateSdk with ChangeNotifier { } } else { log.e('cantBeCert: $toIdtyStatus'); - return 'cantBeCert'; + throw CantBeCertException(toIdtyStatus.name); } log.d('Cert action: ${txInfo.module!}.${txInfo.call!}'); diff --git a/lib/providers/theme_provider.dart b/lib/providers/theme_provider.dart new file mode 100644 index 0000000000000000000000000000000000000000..57d5292ed351490aafb77ebdaf0636d574675812 --- /dev/null +++ b/lib/providers/theme_provider.dart @@ -0,0 +1,228 @@ +import 'package:flutter/material.dart'; +import 'package:gecko/globals.dart'; + +enum ThemeModeSetting { system, light, dark } + +class ThemeProvider with ChangeNotifier { + ThemeModeSetting _themeModeSetting = ThemeModeSetting.system; + + ThemeModeSetting get themeModeSetting => _themeModeSetting; + + ThemeMode get currentThemeMode { + if (_themeModeSetting == ThemeModeSetting.light) { + return ThemeMode.light; + } else if (_themeModeSetting == ThemeModeSetting.dark) { + return ThemeMode.dark; + } else { + return ThemeMode.system; + } + } + + ThemeProvider() { + _loadThemePreference(); + } + + void _loadThemePreference() { + final String? themeString = configBox.get('themeMode'); + if (themeString == 'light') { + _themeModeSetting = ThemeModeSetting.light; + } else if (themeString == 'dark') { + _themeModeSetting = ThemeModeSetting.dark; + } else { + _themeModeSetting = ThemeModeSetting.system; + } + notifyListeners(); + } + + Future<void> setThemeMode(ThemeModeSetting setting) async { + _themeModeSetting = setting; + await configBox.put('themeMode', setting.toString().split('.').last); + notifyListeners(); + } +} + +const Color _orangeC = Color(0xffd07316); +const Color _darkOrangeC = Color.fromARGB(255, 132, 71, 11); + +const Color _yellowC = Color(0xffFFD68E); +const Color _darkYellowC = Color.fromARGB(255, 135, 113, 75); + +const Color _floattingYellow = Color(0xffEFEFBF); +const Color _darkFloattingYellow = Color(0xff1E1E1E); + +const Color _backgroundColor = Color(0xffF5F5F5); +const Color _darkBackgroundColor = Color(0xff121212); + +const Color _headerColor = Color(0xFFFFF3E0); +const Color _darkHeaderColor = Color(0xff1E1E1E); + +const Color _cardColor = Colors.white; +const Color _darkCardColor = Color.fromARGB(255, 43, 43, 43); + +const Color _textColor = Colors.black87; +const Color _darkTextColor = Colors.white70; + +const Color _textOnContainerColor = Colors.black87; +Color _darkTextOnContainerColor = Colors.grey[300]!; + +const Color _textSecondaryColor = Colors.black54; +const Color _darkTextSecondaryColor = Colors.white60; + +const Color _iconColor = Colors.black54; +const Color _darkIconColor = Colors.white54; + +Color _disabledColor = Colors.grey[700]!; +Color _darkDisabledColor = Colors.grey[400]!; + +const Color _errorColor = Color.fromARGB(255, 232, 211, 211); +const Color _darkErrorColor = Color.fromARGB(255, 90, 38, 38); + +final ThemeData lightTheme = ThemeData( + primaryColor: _orangeC, + scaffoldBackgroundColor: _backgroundColor, + canvasColor: _backgroundColor, + appBarTheme: const AppBarTheme( + elevation: 0, + backgroundColor: _headerColor, + titleTextStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: _textColor, + fontFamily: 'Roboto', + ), + iconTheme: IconThemeData(color: _iconColor), + ), + textTheme: const TextTheme( + titleLarge: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: _textColor, + fontFamily: 'Roboto', + ), + bodyMedium: TextStyle( + fontSize: 14, + color: _textColor, + fontFamily: 'Roboto', + ), + bodySmall: TextStyle( + fontSize: 13, + color: _textSecondaryColor, + fontFamily: 'Roboto', + ), + labelMedium: TextStyle( + fontSize: 15, + fontFamily: 'Monospace', + fontWeight: FontWeight.w500, + color: _textColor, + ), + ), + colorScheme: ColorScheme.fromSeed(seedColor: _yellowC, brightness: Brightness.light).copyWith( + secondary: _yellowC, + tertiary: _headerColor, + surfaceTint: _floattingYellow, + surfaceContainer: _cardColor, + primary: _orangeC, + onPrimary: Colors.white, + surface: _backgroundColor, + onSurface: _textColor, + onSecondaryContainer: _textOnContainerColor, + onSurfaceVariant: _disabledColor, + error: _errorColor, + ), + dialogTheme: const DialogThemeData(backgroundColor: _backgroundColor), + iconTheme: const IconThemeData(color: _iconColor), + popupMenuTheme: const PopupMenuThemeData( + color: _cardColor, + textStyle: TextStyle(color: _textColor, fontFamily: 'Roboto', fontSize: 14), + ), + switchTheme: SwitchThemeData( + thumbColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) { + if (states.contains(WidgetState.selected)) { + return _orangeC; + } + return Colors.grey[400]; + }), + trackColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) { + if (states.contains(WidgetState.selected)) { + return _orangeC.withValues(alpha: 0.5); + } + return Colors.grey[300]; + }), + ), + dividerColor: Colors.grey[300], +); + +final ThemeData darkTheme = ThemeData( + primaryColor: _darkOrangeC, + scaffoldBackgroundColor: _darkBackgroundColor, + canvasColor: _darkBackgroundColor, + appBarTheme: const AppBarTheme( + elevation: 0, + backgroundColor: _darkHeaderColor, + titleTextStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: _darkTextColor, + fontFamily: 'Roboto', + ), + iconTheme: IconThemeData(color: _darkIconColor), + ), + textTheme: const TextTheme( + titleLarge: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: _darkTextColor, + fontFamily: 'Roboto', + ), + bodyMedium: TextStyle( + fontSize: 14, + color: _darkTextColor, + fontFamily: 'Roboto', + ), + bodySmall: TextStyle( + fontSize: 13, + color: _darkTextSecondaryColor, + fontFamily: 'Roboto', + ), + labelMedium: TextStyle( + fontSize: 15, + fontFamily: 'Monospace', + fontWeight: FontWeight.w500, + color: _darkTextColor, + ), + ), + colorScheme: ColorScheme.fromSeed(seedColor: _darkOrangeC, brightness: Brightness.dark).copyWith( + secondary: _darkYellowC, + tertiary: _darkHeaderColor, + surface: _darkBackgroundColor, + onSurface: _darkTextColor, + primary: _darkOrangeC, + onPrimary: Colors.black, + surfaceContainer: _darkCardColor, + surfaceTint: _darkFloattingYellow, + onSurfaceVariant: _darkDisabledColor, + onSecondaryContainer: _darkTextOnContainerColor, + error: _darkErrorColor, + ), + dialogTheme: const DialogThemeData(backgroundColor: _darkCardColor), + iconTheme: const IconThemeData(color: _darkIconColor), + popupMenuTheme: PopupMenuThemeData( + color: _darkCardColor, + textStyle: TextStyle(color: _darkTextColor, fontFamily: 'Roboto', fontSize: 14), + ), + switchTheme: SwitchThemeData( + thumbColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) { + if (states.contains(WidgetState.selected)) { + return _darkOrangeC; + } + return Colors.grey[600]; + }), + trackColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) { + if (states.contains(WidgetState.selected)) { + return _darkOrangeC.withValues(alpha: 0.5); + } + return Colors.grey[800]; + }), + ), + dividerColor: Colors.grey[700], +); diff --git a/lib/providers/wallets_profiles.dart b/lib/providers/wallets_profiles.dart index 1dc5bf8c8e7a952e91025f4d228c7ffec35dcfab..336b70ad03e4d34611bd726e0a479448b11bd38f 100644 --- a/lib/providers/wallets_profiles.dart +++ b/lib/providers/wallets_profiles.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -157,29 +158,41 @@ bool isPubkey(String pubkey) { return regExp.hasMatch(pubkey) == true && pubkey.length > 42 && pubkey.length < 45; } -snackMessage(context, {required String message, int duration = 2, double fontSize = 14}) { +snackMessage(BuildContext context, {required String message, int duration = 4, double fontSize = 14}) { final snackBar = SnackBar( - backgroundColor: Colors.grey[900], + backgroundColor: context.colorScheme.onSurface, padding: EdgeInsets.all(scaleSize(19)), - content: Text(message, style: scaledTextStyle(fontSize: fontSize)), + content: Text(message, + style: scaledTextStyle( + fontSize: fontSize, + color: context.colorScheme.surfaceContainer, + )), duration: Duration(seconds: duration)); ScaffoldMessenger.of(context).showSnackBar(snackBar); } -snackCopyKey(context) { +snackCopyKey(BuildContext context) { final snackBar = SnackBar( - backgroundColor: Colors.grey[900], + backgroundColor: context.colorScheme.onSurface, padding: EdgeInsets.all(scaleSize(19)), - content: Text("thisAddressHasBeenCopiedToClipboard".tr(), style: scaledTextStyle(fontSize: 13)), - duration: const Duration(seconds: 2)); + content: Text("thisAddressHasBeenCopiedToClipboard".tr(), + style: scaledTextStyle( + fontSize: 13, + color: context.colorScheme.surfaceContainer, + )), + duration: const Duration(seconds: 4)); ScaffoldMessenger.of(context).showSnackBar(snackBar); } -snackCopySeed(context) { +snackCopySeed(BuildContext context) { final snackBar = SnackBar( - backgroundColor: Colors.grey[900], + backgroundColor: context.colorScheme.onSurface, padding: EdgeInsets.all(scaleSize(19)), - content: Text("thisMnemonicHasBeenCopiedToClipboard".tr(), style: scaledTextStyle(fontSize: 13)), + content: Text("thisMnemonicHasBeenCopiedToClipboard".tr(), + style: scaledTextStyle( + fontSize: 13, + color: context.colorScheme.surfaceContainer, + )), duration: const Duration(seconds: 4)); ScaffoldMessenger.of(context).showSnackBar(snackBar); } diff --git a/lib/screens/activity.dart b/lib/screens/activity.dart index 5c877de2da4667017837e7459f60ec24c9e81d2a..b21b717187a78d4a3b93e491ce0efc9b2d80ae5f 100644 --- a/lib/screens/activity.dart +++ b/lib/screens/activity.dart @@ -1,5 +1,6 @@ // ignore_for_file: must_be_immutable +import 'package:durt2/durt2.dart' show IdtyStatus; import 'package:easy_localization/easy_localization.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -12,6 +13,8 @@ import 'package:gecko/widgets/commons/offline_info.dart'; import 'package:provider/provider.dart'; import 'package:gecko/widgets/wallet_header.dart'; import 'package:gecko/widgets/commons/wallet_app_bar.dart'; +import 'package:gecko/models/wallet_header_data.dart'; +import 'package:gecko/providers/my_wallets.dart'; class ActivityScreen extends StatefulWidget { const ActivityScreen({required this.address, this.username, this.transactionId, this.comment}) : super(key: keyActivityScreen); @@ -24,46 +27,94 @@ class ActivityScreen extends StatefulWidget { } class _ActivityScreenState extends State<ActivityScreen> { + late Future<WalletHeaderData> _headerDataFuture; + @override void initState() { + super.initState(); final sub = Provider.of<SubstrateSdk>(homeContext, listen: false); sub.getOldOwnerKey(widget.address); - super.initState(); + _headerDataFuture = _loadWalletData(); + } + + Future<WalletHeaderData> _loadWalletData() async { + final sub = Provider.of<SubstrateSdk>(context, listen: false); + final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); + + final (idtyStatusValue, balanceResult, certData) = await ( + sub.idtyStatus(widget.address), + sub.getBalance(widget.address), + sub.getCertsCounter(widget.address), + ).wait; + + final data = WalletHeaderData( + hasIdentity: idtyStatusValue != IdtyStatus.none, + isOwner: myWalletProvider.isOwner(widget.address), + walletName: duniterIndexer.walletNameIndexer[widget.address], + balance: BigInt.from(balanceResult.transferableBalance), + certCount: certData, + ); + + return data; } @override Widget build(BuildContext context) { final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: true); - return PopScope( - onPopInvokedWithResult: (_, __) { - duniterIndexer.refetch = duniterIndexer.transBC = null; - }, - child: Scaffold( - backgroundColor: Colors.grey[50], - appBar: WalletAppBar( - address: widget.address, - title: 'accountActivity'.tr(), - ), - body: Stack( - children: [ - Column( - children: <Widget>[ - WalletHeader(address: widget.address), - Expanded( - child: HistoryQuery( - address: widget.address, - transactionId: widget.transactionId, - comment: widget.comment, - ), + return FutureBuilder<WalletHeaderData>( + future: _headerDataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Scaffold( + appBar: AppBar(title: Text('accountActivity'.tr())), + body: const Center(child: CircularProgressIndicator()), + bottomNavigationBar: const GeckoBottomAppBar(), + ); + } + + if (snapshot.hasError || !snapshot.hasData) { + return Scaffold( + appBar: AppBar(title: Text('accountActivity'.tr())), + body: Center(child: Text('errorLoadingWalletData'.tr())), + bottomNavigationBar: const GeckoBottomAppBar(), + ); + } + + final walletData = snapshot.data!; + + return PopScope( + onPopInvokedWithResult: (_, __) { + duniterIndexer.refetch = duniterIndexer.transBC = null; + }, + child: Scaffold( + appBar: WalletAppBar( + address: widget.address, + currentBalance: walletData.balance, + title: 'accountActivity'.tr(), + ), + body: Stack( + children: [ + Column( + children: <Widget>[ + WalletHeader(address: widget.address), + Expanded( + child: HistoryQuery( + address: widget.address, + transactionId: widget.transactionId, + comment: widget.comment, + ), + ), + ], ), + const OfflineInfo(), ], ), - const OfflineInfo(), - ], - ), - bottomNavigationBar: const GeckoBottomAppBar(), - ), + bottomNavigationBar: const GeckoBottomAppBar(), + ), + ); + }, ); } } diff --git a/lib/screens/certifications.dart b/lib/screens/certifications.dart index eed13b352104d35f49c89a1b7f1f96db7e3ac72b..38458268d16e289b3515fe6407797501b6ffee6a 100644 --- a/lib/screens/certifications.dart +++ b/lib/screens/certifications.dart @@ -1,7 +1,7 @@ import 'package:accordion/controllers.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/widgets/certs_list.dart'; import 'package:gecko/widgets/certs_counter.dart'; @@ -9,26 +9,24 @@ import 'package:accordion/accordion.dart'; import 'package:gecko/widgets/commons/top_appbar.dart'; class CertificationsScreen extends StatelessWidget { - const CertificationsScreen( - {super.key, required this.address, required this.username}); + const CertificationsScreen({super.key, required this.address, required this.username}); final String address; final String username; @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('certificationsOf'.tr(args: [username])), body: SafeArea( child: Accordion( paddingListTop: 7, paddingListBottom: 10, maxOpenSections: 1, - headerBackgroundColorOpened: orangeC, + headerBackgroundColorOpened: context.colorScheme.primary, scaleWhenAnimating: true, openAndCloseAnimation: true, - headerPadding: EdgeInsets.symmetric( - vertical: scaleSize(6), horizontal: scaleSize(14)), + headerPadding: EdgeInsets.symmetric(vertical: scaleSize(6), horizontal: scaleSize(14)), sectionOpeningHapticFeedback: SectionHapticFeedback.heavy, sectionClosingHapticFeedback: SectionHapticFeedback.light, children: [ @@ -36,34 +34,44 @@ class CertificationsScreen extends StatelessWidget { isOpen: true, leftIcon: Icon( Icons.insights_rounded, - color: Colors.black, + color: context.colorScheme.onSecondaryContainer, size: scaleSize(20), ), - headerBackgroundColor: yellowC, - headerBackgroundColorOpened: orangeC, + headerBackgroundColor: context.colorScheme.secondary, + headerBackgroundColorOpened: context.colorScheme.primary, + contentBackgroundColor: context.colorScheme.surfaceContainer, header: Row(children: [ Text( 'received'.tr(), - style: scaledTextStyle(fontSize: 16), + style: scaledTextStyle( + fontSize: 16, + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(width: 5), CertsCounter(address: address) ]), - content: CertsList( - address: address, direction: CertDirection.received), + content: CertsList(address: address, direction: CertDirection.received), contentHorizontalPadding: 0, contentBorderWidth: 1, ), AccordionSection( isOpen: false, - leftIcon: - const Icon(Icons.insights_rounded, color: Colors.black), - headerBackgroundColor: yellowC, - headerBackgroundColorOpened: orangeC, + leftIcon: Icon( + Icons.insights_rounded, + color: context.colorScheme.onSecondaryContainer, + size: scaleSize(20), + ), + headerBackgroundColor: context.colorScheme.secondary, + headerBackgroundColorOpened: context.colorScheme.primary, + contentBackgroundColor: context.colorScheme.surfaceContainer, header: Row(children: [ Text( 'sent'.tr(), - style: scaledTextStyle(fontSize: 16), + style: scaledTextStyle( + fontSize: 16, + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(width: 5), CertsCounter(address: address, isSent: true) diff --git a/lib/screens/debug_screen.dart b/lib/screens/debug_screen.dart index 29f0640c46b65ac195b4e989b38adb776d85fdd1..1badff5845a8a48455a515ca6e235ecff70c600a 100644 --- a/lib/screens/debug_screen.dart +++ b/lib/screens/debug_screen.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/widgets/commons/top_appbar.dart'; @@ -16,7 +16,7 @@ class DebugScreen extends StatelessWidget { final isSmallScreen = screenSize.height < 700; return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('Debug'), body: SafeArea( child: SingleChildScrollView( @@ -30,7 +30,7 @@ class DebugScreen extends StatelessWidget { // Section Nœud Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -49,7 +49,7 @@ class DebugScreen extends StatelessWidget { children: [ Icon( Icons.dns_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(24), ), ScaledSizedBox(width: 12), @@ -57,7 +57,7 @@ class DebugScreen extends StatelessWidget { 'currencyNode'.tr(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: context.colorScheme.onSecondaryContainer, ), ), ], @@ -67,7 +67,7 @@ class DebugScreen extends StatelessWidget { 'node: ${sub.getConnectedEndpoint()}', style: scaledTextStyle( fontSize: 13, - color: Colors.grey[600], + color: context.colorScheme.onSecondaryContainer, ), ), ScaledSizedBox(height: 8), @@ -75,7 +75,7 @@ class DebugScreen extends StatelessWidget { 'blockN'.tr(args: [sub.blocNumber.toString()]), style: scaledTextStyle( fontSize: 13, - color: Colors.grey[600], + color: context.colorScheme.onSecondaryContainer, ), ), ], @@ -87,7 +87,7 @@ class DebugScreen extends StatelessWidget { // Section Actions Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -106,7 +106,7 @@ class DebugScreen extends StatelessWidget { children: [ Icon( Icons.build_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(24), ), ScaledSizedBox(width: 12), @@ -114,7 +114,7 @@ class DebugScreen extends StatelessWidget { 'Actions', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: context.colorScheme.onSecondaryContainer, ), ), ], @@ -125,7 +125,7 @@ class DebugScreen extends StatelessWidget { child: ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, padding: EdgeInsets.symmetric(vertical: scaleSize(12)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 1222cf1e9f133b869b1954b91364a892bb9460e5..53cd28a0c6353c626fc63d97b7e9445806021529 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -1,4 +1,5 @@ import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -45,7 +46,7 @@ class _HomeScreenState extends State<HomeScreen> { return Scaffold( resizeToAvoidBottomInset: false, drawer: MainDrawer(isWalletsExists: isWalletsExists), - backgroundColor: yellowC, + backgroundColor: context.colorScheme.secondary, body: isWalletsExists ? geckHome(context) : welcomeHome(context)); } } @@ -55,8 +56,13 @@ Widget geckHome(context) { final statusBarHeight = MediaQuery.of(context).padding.top; return Container( - decoration: const BoxDecoration( + decoration: BoxDecoration( image: DecorationImage( + opacity: 0.8, + colorFilter: ColorFilter.mode( + Colors.black.withValues(alpha: homeContext.isDarkTheme ? 0.8 : 0.4), + BlendMode.colorDodge, + ), image: AssetImage("assets/home/background.jpg"), fit: BoxFit.cover, ), @@ -227,7 +233,7 @@ Widget welcomeHome(context) { key: keyOnboardingNewChest, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: homeContext.colorScheme.primary, elevation: 0, padding: EdgeInsets.symmetric(vertical: scaleSize(8)), shape: RoundedRectangleBorder( @@ -268,7 +274,7 @@ Widget welcomeHome(context) { child: OutlinedButton( key: keyRestoreChest, style: OutlinedButton.styleFrom( - side: BorderSide(width: scaleSize(4), color: orangeC), + side: BorderSide(width: scaleSize(4), color: homeContext.colorScheme.primary), padding: EdgeInsets.symmetric(vertical: scaleSize(8)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), @@ -295,10 +301,7 @@ Widget welcomeHome(context) { }, child: Text( "restoreWallet".tr(), - style: scaledTextStyle( - fontSize: 20, - color: orangeC, - fontWeight: FontWeight.w600), + style: scaledTextStyle(fontSize: 20, color: homeContext.colorScheme.primary, fontWeight: FontWeight.w600), ), ), ), diff --git a/lib/screens/identity/confirm_identity.dart b/lib/screens/identity/confirm_identity.dart index 591beb30c36b0be87558e8b1ec617e49c31f07a9..bb381a9618e3a99da611ff59d98d0447d27320da 100644 --- a/lib/screens/identity/confirm_identity.dart +++ b/lib/screens/identity/confirm_identity.dart @@ -1,12 +1,14 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/duniter_indexer.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/providers/substrate_sdk.dart'; +import 'package:gecko/providers/wallet_options.dart'; import 'package:gecko/screens/transaction_in_progress.dart'; import 'package:gecko/widgets/commons/confirmation_dialog.dart'; import 'package:gecko/widgets/commons/wallet_app_bar.dart'; @@ -90,13 +92,14 @@ class _ConfirmIdentityScreenState extends State<ConfirmIdentityScreen> { @override Widget build(BuildContext context) { final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); + final walletOptions = Provider.of<WalletOptionsProvider>(context, listen: false); final screenSize = MediaQuery.of(context).size; final isSmallScreen = screenSize.height < 700; return Scaffold( - backgroundColor: Colors.white, appBar: WalletAppBar( address: widget.address, + currentBalance: BigInt.from(walletOptions.balanceCache[widget.address] ?? 0), title: 'chooseIdentityName'.tr(), ), body: Column( @@ -114,13 +117,13 @@ class _ConfirmIdentityScreenState extends State<ConfirmIdentityScreen> { width: scaleSize(isSmallScreen ? 60 : 80), height: scaleSize(isSmallScreen ? 60 : 80), decoration: BoxDecoration( - color: orangeC.withValues(alpha: 0.1), + color: context.colorScheme.primary.withValues(alpha: 0.1), shape: BoxShape.circle, ), child: Icon( Icons.person_outline, size: scaleSize(isSmallScreen ? 30 : 40), - color: orangeC, + color: context.colorScheme.primary, ), ), ), @@ -153,7 +156,7 @@ class _ConfirmIdentityScreenState extends State<ConfirmIdentityScreen> { padding: EdgeInsets.only(bottom: scaleSize(isSmallScreen ? 8 : 12)), child: Row( children: [ - Icon(Icons.check_circle, color: orangeC, size: scaleSize(isSmallScreen ? 16 : 20)), + Icon(Icons.check_circle, color: context.colorScheme.primary, size: scaleSize(isSmallScreen ? 16 : 20)), ScaledSizedBox(width: isSmallScreen ? 8 : 12), Expanded( child: Text( @@ -211,7 +214,7 @@ class _ConfirmIdentityScreenState extends State<ConfirmIdentityScreen> { key: keyConfirm, onPressed: _canValidate ? () => _confirmIdentity(context) : null, style: ElevatedButton.styleFrom( - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, disabledBackgroundColor: Colors.grey[300], elevation: 0, shape: RoundedRectangleBorder( diff --git a/lib/screens/myWallets/change_pin.dart b/lib/screens/myWallets/change_pin.dart index c4420d473a55de58b0ec20d3002fda78725f5d38..ffa3e85aecdb0cbcddaedb70a5976b901c3a685d 100644 --- a/lib/screens/myWallets/change_pin.dart +++ b/lib/screens/myWallets/change_pin.dart @@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/screens/myWallets/confirm_change_pin.dart'; @@ -42,7 +43,7 @@ class _ChangePinScreenState extends State<ChangePinScreen> { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar(widget.walletName!), body: SafeArea( child: SingleChildScrollView( diff --git a/lib/screens/myWallets/chest_options.dart b/lib/screens/myWallets/chest_options.dart index b5197711040eab537add215d58fa489d52fcfa96..00ac869e2920f859e006ce1c77e45aa85bcfb0f5 100644 --- a/lib/screens/myWallets/chest_options.dart +++ b/lib/screens/myWallets/chest_options.dart @@ -3,7 +3,7 @@ import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/chest_provider.dart'; @@ -25,7 +25,7 @@ class ChestOptions extends StatelessWidget { final currentSafe = Durt.i.walletService.defaultSafeBox; return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, resizeToAvoidBottomInset: false, appBar: GeckoAppBar(currentSafe.name), bottomNavigationBar: const GeckoBottomAppBar(), @@ -55,8 +55,7 @@ class ChestOptionsContent extends StatelessWidget { @override Widget build(BuildContext context) { final chestProvider = Provider.of<ChestProvider>(context, listen: false); - final myWalletProvider = - Provider.of<MyWalletsProvider>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); final currentChest = Durt.i.walletService.defaultSafeBox; final isAlone = myWalletProvider.listWallets.length == 1; @@ -77,14 +76,13 @@ class ChestOptionsContent extends StatelessWidget { ); }, child: Container( - padding: EdgeInsets.symmetric( - horizontal: scaleSize(16), vertical: scaleSize(12)), + padding: EdgeInsets.symmetric(horizontal: scaleSize(16), vertical: scaleSize(12)), child: Row( children: [ Icon( Icons.vpn_key_outlined, size: scaleSize(24), - color: Colors.black87, + color: context.colorScheme.onSurface, ), ScaledSizedBox(width: 16), Expanded( @@ -92,7 +90,7 @@ class ChestOptionsContent extends StatelessWidget { 'displayMnemonic'.tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), softWrap: true, ), @@ -118,8 +116,7 @@ class ChestOptionsContent extends StatelessWidget { ); }, child: Container( - padding: EdgeInsets.symmetric( - horizontal: scaleSize(16), vertical: scaleSize(12)), + padding: EdgeInsets.symmetric(horizontal: scaleSize(16), vertical: scaleSize(12)), child: Row( children: [ Icon( @@ -133,7 +130,7 @@ class ChestOptionsContent extends StatelessWidget { 'changePassword'.tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), softWrap: true, ), @@ -153,22 +150,18 @@ class ChestOptionsContent extends StatelessWidget { ? () async { await Navigator.push( context, - MaterialPageRoute( - builder: (context) => const CustomDerivation()), + MaterialPageRoute(builder: (context) => const CustomDerivation()), ); } : null, child: Container( - padding: EdgeInsets.symmetric( - horizontal: scaleSize(16), vertical: scaleSize(12)), + padding: EdgeInsets.symmetric(horizontal: scaleSize(16), vertical: scaleSize(12)), child: Row( children: [ Icon( Icons.manage_accounts, size: scaleSize(24), - color: Durt.i.isConnected - ? Colors.black87 - : Colors.grey[400], + color: Durt.i.isConnected ? context.colorScheme.onSurface : Colors.grey[400], ), ScaledSizedBox(width: 16), Expanded( @@ -176,9 +169,7 @@ class ChestOptionsContent extends StatelessWidget { 'createDerivation'.tr(), style: scaledTextStyle( fontSize: 16, - color: Durt.i.isConnected - ? Colors.black87 - : Colors.grey[500], + color: Durt.i.isConnected ? context.colorScheme.onSurface : Colors.grey[500], ), softWrap: true, ), @@ -197,8 +188,7 @@ class ChestOptionsContent extends StatelessWidget { await chestProvider.forgetSafe(context, currentChest); }, child: Container( - padding: EdgeInsets.symmetric( - horizontal: scaleSize(16), vertical: scaleSize(12)), + padding: EdgeInsets.symmetric(horizontal: scaleSize(16), vertical: scaleSize(12)), child: Row( children: [ Image.asset( diff --git a/lib/screens/myWallets/choose_chest.dart b/lib/screens/myWallets/choose_chest.dart index 843905105767ea13cd5ac699a8b8193ec232704e..7688011c3ce0ba242cb570256219e3a73985d71d 100644 --- a/lib/screens/myWallets/choose_chest.dart +++ b/lib/screens/myWallets/choose_chest.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -33,9 +34,8 @@ class _ChooseChestState extends State<ChooseChest> { final myWalletProvider = Provider.of<MyWalletsProvider>(context); return Scaffold( - backgroundColor: backgroundColor, - appBar: AppBar( - toolbarHeight: scaleSize(57), title: Text('selectMyChest'.tr())), + backgroundColor: context.colorScheme.surface, + appBar: AppBar(toolbarHeight: scaleSize(57), title: Text('selectMyChest'.tr())), body: SafeArea( child: Column(children: <Widget>[ const SizedBox(height: 160), @@ -82,22 +82,15 @@ class _ChooseChestState extends State<ChooseChest> { children: Durt.i.walletService.safeBox.values.toList().map((entry) { return GestureDetector( - onTap: () => - buttonCarouselController.animateToPage(entry.key), + onTap: () => buttonCarouselController.animateToPage(entry.key), child: Container( width: 12.0, height: 12.0, - margin: const EdgeInsets.symmetric( - vertical: 8.0, horizontal: 4.0), + margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0), decoration: BoxDecoration( shape: BoxShape.circle, - color: (Theme.of(context).brightness == - Brightness.dark - ? Colors.white - : Colors.black) - .withValues( - alpha: - currentChest == entry.key ? 0.9 : 0.4)), + color: (Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.black) + .withValues(alpha: currentChest == entry.key ? 0.9 : 0.4)), ), ); }).toList(), @@ -109,7 +102,7 @@ class _ChooseChestState extends State<ChooseChest> { child: ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Colors.black, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, ), onPressed: () async { await configBox.put('currentChest', currentChest); @@ -124,10 +117,7 @@ class _ChooseChestState extends State<ChooseChest> { }, child: Text( 'openThisChest'.tr(), - style: const TextStyle( - fontSize: 21, - color: backgroundColor, - fontWeight: FontWeight.w600), + style: TextStyle(fontSize: 21, color: context.colorScheme.surface, fontWeight: FontWeight.w600), ), ), ), @@ -149,11 +139,7 @@ class _ChooseChestState extends State<ChooseChest> { width: 400, height: 50, child: Center( - child: Text('createChest'.tr(), - style: const TextStyle( - fontSize: 21, - color: orangeC, - fontWeight: FontWeight.w600))), + child: Text('createChest'.tr(), style: TextStyle(fontSize: 21, color: context.colorScheme.primary, fontWeight: FontWeight.w600))), ), ), ), @@ -171,12 +157,8 @@ class _ChooseChestState extends State<ChooseChest> { child: SizedBox( width: 400, height: 50, - child: Center( - child: Text('importChest'.tr(), - style: const TextStyle( - fontSize: 21, - color: orangeC, - fontWeight: FontWeight.w600))), + child: + Center(child: Text('importChest'.tr(), style: TextStyle(fontSize: 21, color: context.colorScheme.primary, fontWeight: FontWeight.w600))), )), const SizedBox(height: 20), ]), diff --git a/lib/screens/myWallets/confirm_change_pin.dart b/lib/screens/myWallets/confirm_change_pin.dart index 88a57d94dde63523f1859b9ebbb79982fd58a455..214c3c0acce404c5d53ec71106067b59a57ec88a 100644 --- a/lib/screens/myWallets/confirm_change_pin.dart +++ b/lib/screens/myWallets/confirm_change_pin.dart @@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/providers/substrate_sdk.dart'; @@ -44,7 +45,7 @@ class _ConfirmChangePinScreenState extends State<ConfirmChangePinScreen> { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar(widget.walletName!), body: SafeArea( child: Column(children: <Widget>[ diff --git a/lib/screens/myWallets/custom_derivations.dart b/lib/screens/myWallets/custom_derivations.dart index 9d60927d3bf85fdd5d6eab430fc0df774dbf52b6..abd584bde3942d504b5e74b91f38bc713ac47dd8 100644 --- a/lib/screens/myWallets/custom_derivations.dart +++ b/lib/screens/myWallets/custom_derivations.dart @@ -2,8 +2,8 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:easy_localization/easy_localization.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/widgets/commons/top_appbar.dart'; @@ -43,7 +43,7 @@ class _CustomDerivationState extends State<CustomDerivation> { } return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('createCustomDerivation'.tr()), body: Center( child: SafeArea( @@ -73,10 +73,10 @@ class _CustomDerivationState extends State<CustomDerivation> { size: scaleSize(20), ), elevation: 16, - style: scaledTextStyle(color: orangeC), + style: scaledTextStyle(color: context.colorScheme.primary), underline: Container( height: 2, - color: orangeC, + color: context.colorScheme.primary, ), onChanged: (String? newValue) { setState(() { @@ -107,13 +107,13 @@ class _CustomDerivationState extends State<CustomDerivation> { child: ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: () async { if (!await myWalletProvider.askPinCode()) return; diff --git a/lib/screens/myWallets/import_g1_v1.dart b/lib/screens/myWallets/import_g1_v1.dart index 0704ba6cd47c9a6622376e2bcbc0d38b8ca3921d..df7b8d05ec15c69a04940dca6dd1913b41df6381 100644 --- a/lib/screens/myWallets/import_g1_v1.dart +++ b/lib/screens/myWallets/import_g1_v1.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'package:durt2/durt2.dart' show IdtyStatus, WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/migrate_wallet_checks.dart'; @@ -38,7 +39,7 @@ class ImportG1v1 extends StatelessWidget { resetScreen(); }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('importOldAccount'.tr()), body: SafeArea( child: Consumer<SubstrateSdk>(builder: (context, sub, _) { @@ -52,8 +53,8 @@ class ImportG1v1 extends StatelessWidget { ScaledSizedBox( height: 35, width: 35, - child: const CircularProgressIndicator( - color: orangeC, + child: CircularProgressIndicator( + color: context.colorScheme.primary, strokeWidth: 4, ), ), @@ -70,6 +71,7 @@ class ImportG1v1 extends StatelessWidget { children: <Widget>[ // Section des identifiants Cesium Card( + color: context.colorScheme.surfaceContainer, elevation: 2, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), @@ -81,7 +83,11 @@ class ImportG1v1 extends StatelessWidget { children: [ Text( 'cesiumCredentials'.tr(), - style: scaledTextStyle(fontSize: 14, fontWeight: FontWeight.bold), + style: scaledTextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(height: 8), TextFormField( @@ -112,7 +118,7 @@ class ImportG1v1 extends StatelessWidget { textInputAction: TextInputAction.next, controller: sub.csSalt, obscureText: !sub.isCesiumIDVisible, - style: scaledTextStyle(fontSize: 13), + style: scaledTextStyle(fontSize: 13, color: context.colorScheme.onSecondaryContainer), decoration: InputDecoration( isDense: true, contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), @@ -167,7 +173,7 @@ class ImportG1v1 extends StatelessWidget { textInputAction: TextInputAction.done, controller: sub.csPassword, obscureText: !sub.isCesiumIDVisible, - style: scaledTextStyle(fontSize: 13), + style: scaledTextStyle(fontSize: 13, color: context.colorScheme.onSecondaryContainer), decoration: InputDecoration( isDense: true, contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), @@ -200,6 +206,7 @@ class ImportG1v1 extends StatelessWidget { visible: sub.g1V1OldPubkey != '' && sub.csSalt.text != '' && sub.csPassword.text != '', child: Card( elevation: 2, + color: context.colorScheme.surfaceContainer, margin: EdgeInsets.symmetric(vertical: scaleSize(8)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), @@ -211,7 +218,11 @@ class ImportG1v1 extends StatelessWidget { children: [ Text( 'accountInformation'.tr(), - style: scaledTextStyle(fontSize: 14, fontWeight: FontWeight.bold), + style: scaledTextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(height: 8), Row( @@ -231,11 +242,15 @@ class ImportG1v1 extends StatelessWidget { children: [ Text( 'v1: ', - style: scaledTextStyle(fontSize: 13), + style: scaledTextStyle(fontSize: 13, color: context.colorScheme.onSecondaryContainer), ), Text( getShortPubkey(sub.g1V1OldPubkey), - style: scaledTextStyle(fontSize: 13, fontFamily: 'Monospace'), + style: scaledTextStyle( + fontSize: 13, + fontFamily: 'Monospace', + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(width: 6), Icon(Icons.copy, size: scaleSize(14), color: Colors.grey), @@ -253,11 +268,15 @@ class ImportG1v1 extends StatelessWidget { children: [ Text( 'v2: ', - style: scaledTextStyle(fontSize: 13), + style: scaledTextStyle(fontSize: 13, color: context.colorScheme.onSecondaryContainer), ), Text( getShortPubkey(sub.g1V1NewAddress), - style: scaledTextStyle(fontSize: 13, fontFamily: 'Monospace'), + style: scaledTextStyle( + fontSize: 13, + fontFamily: 'Monospace', + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(width: 6), Icon(Icons.copy, size: scaleSize(14), color: Colors.grey), @@ -274,6 +293,7 @@ class ImportG1v1 extends StatelessWidget { value: statusData.fromBalance['transferableBalance'], size: 14, fontWeight: FontWeight.w600, + color: context.colorScheme.onSecondaryContainer, ), ScaledSizedBox(height: 4), Row( @@ -301,6 +321,7 @@ class ImportG1v1 extends StatelessWidget { // Section de sélection du portefeuille Card( + color: context.colorScheme.surfaceContainer, elevation: 2, margin: EdgeInsets.only(bottom: scaleSize(8)), shape: RoundedRectangleBorder( @@ -313,7 +334,11 @@ class ImportG1v1 extends StatelessWidget { children: [ Text( 'migrateToThisWallet'.tr(), - style: scaledTextStyle(fontSize: 14, fontWeight: FontWeight.bold), + style: scaledTextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: context.colorScheme.onSecondaryContainer, + ), ), ScaledSizedBox(height: 8), Container( @@ -361,13 +386,13 @@ class ImportG1v1 extends StatelessWidget { key: keyConfirm, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: statusData.canValidate ? () async { diff --git a/lib/screens/myWallets/manage_membership.dart b/lib/screens/myWallets/manage_membership.dart index 064118acacd141860445e79a27350235c46ec5cf..cb058ac434cbceec4fcf961faa74a08267ee1434 100644 --- a/lib/screens/myWallets/manage_membership.dart +++ b/lib/screens/myWallets/manage_membership.dart @@ -2,8 +2,8 @@ import 'package:durt2/durt2.dart' show IdtyStatus; import 'package:easy_localization/easy_localization.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/my_wallets.dart'; @@ -26,7 +26,7 @@ class ManageMembership extends StatelessWidget { final sub = Provider.of<SubstrateSdk>(context); return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('manageMembership'.tr()), body: SafeArea( child: SingleChildScrollView( @@ -120,14 +120,14 @@ class ManageMembership extends StatelessWidget { Icon( Icons.change_circle_outlined, size: scaleSize(24), - color: Colors.black87, + color: context.colorScheme.onSurface, ), ScaledSizedBox(width: 16), Text( 'Migrer mon identité', style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), ), ], @@ -180,7 +180,7 @@ class ManageMembership extends StatelessWidget { 'revokeMyIdentity'.tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), ), ], @@ -211,7 +211,7 @@ class ManageMembership extends StatelessWidget { Image.asset( 'assets/medal.png', height: scaleSize(24), - color: info.canRenew ? Colors.black87 : Colors.grey[400], + color: info.canRenew ? context.colorScheme.onSurface : Colors.grey[400], ), ScaledSizedBox(width: 16), Expanded( @@ -223,7 +223,7 @@ class ManageMembership extends StatelessWidget { 'renewMembership'.tr(), style: scaledTextStyle( fontSize: 16, - color: info.canRenew ? Colors.black87 : Colors.grey[500], + color: info.canRenew ? context.colorScheme.onSurface : Colors.grey[500], ), ), MembershipRenewal.buildExpirationText(info), diff --git a/lib/screens/myWallets/migrate_identity.dart b/lib/screens/myWallets/migrate_identity.dart index 4f3c01cfe7c2b84f03ab867c713ad9a64b0f3569..d49e638bef0ce560418922d0d7fe7919cc6e1967 100644 --- a/lib/screens/myWallets/migrate_identity.dart +++ b/lib/screens/myWallets/migrate_identity.dart @@ -2,6 +2,7 @@ import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/migrate_wallet_checks.dart'; @@ -92,7 +93,7 @@ class MigrateIdentityScreen extends StatelessWidget { } return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('migrateIdentity'.tr()), body: SafeArea( child: Column( @@ -113,13 +114,13 @@ class MigrateIdentityScreen extends StatelessWidget { width: scaleSize(isSmallScreen ? 50 : 70), height: scaleSize(isSmallScreen ? 50 : 70), decoration: BoxDecoration( - color: orangeC.withValues(alpha: 0.1), + color: context.colorScheme.primary.withValues(alpha: 0.1), shape: BoxShape.circle, ), child: Icon( Icons.swap_horiz_rounded, size: scaleSize(isSmallScreen ? 25 : 35), - color: orangeC, + color: context.colorScheme.primary, ), ), ScaledSizedBox(height: isSmallScreen ? 16 : 24), @@ -131,7 +132,7 @@ class MigrateIdentityScreen extends StatelessWidget { textAlign: WrapAlignment.center, style: scaledTextStyle( fontSize: isSmallScreen ? 14 : 15, - color: Colors.black87, + color: context.colorScheme.onSurface, height: 1.5, ), ), @@ -139,9 +140,9 @@ class MigrateIdentityScreen extends StatelessWidget { value: walletOptions.balanceCache[fromAddress] ?? 0, size: isSmallScreen ? 14 : 15, fontWeight: FontWeight.bold, - color: Colors.black87, + color: context.colorScheme.onSurface, ), - Text(' ?', style: scaledTextStyle(fontSize: isSmallScreen ? 14 : 15, color: Colors.black87)), + Text(' ?', style: scaledTextStyle(fontSize: isSmallScreen ? 14 : 15, color: context.colorScheme.onSurface)), ], ), ], @@ -155,7 +156,7 @@ class MigrateIdentityScreen extends StatelessWidget { style: scaledTextStyle( fontSize: isSmallScreen ? 15 : 16, fontWeight: FontWeight.w600, - color: Colors.black87, + color: context.colorScheme.onSurface, ), ), ScaledSizedBox(height: isSmallScreen ? 12 : 16), @@ -198,7 +199,7 @@ class MigrateIdentityScreen extends StatelessWidget { maxLines: isSmallScreen ? 2 : 3, style: scaledTextStyle( fontSize: isSmallScreen ? 14 : 15, - color: Colors.black87, + color: context.colorScheme.onSurface, height: 1.5, ), decoration: InputDecoration( @@ -258,7 +259,7 @@ class MigrateIdentityScreen extends StatelessWidget { controller: newWalletAddress, style: scaledTextStyle( fontSize: isSmallScreen ? 14 : 15, - color: Colors.black87, + color: context.colorScheme.onSurface, ), decoration: InputDecoration( contentPadding: EdgeInsets.all(scaleSize(isSmallScreen ? 12 : 16)), @@ -344,7 +345,7 @@ class MigrateIdentityScreen extends StatelessWidget { child: ElevatedButton( key: keyConfirm, style: ElevatedButton.styleFrom( - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, foregroundColor: Colors.white, elevation: 0, shape: RoundedRectangleBorder( diff --git a/lib/screens/myWallets/restore_chest.dart b/lib/screens/myWallets/restore_chest.dart index 567d9f4ae8d23368661a4c221229c4e1bbde862e..0e8a6d45157b2039f4aff6488d9dca6ba281a435 100644 --- a/lib/screens/myWallets/restore_chest.dart +++ b/lib/screens/myWallets/restore_chest.dart @@ -3,6 +3,7 @@ import 'package:bubble/bubble.dart'; import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -35,7 +36,7 @@ class RestoreChest extends StatelessWidget { genW.resetImportView(); }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('restoreAChest'.tr()), body: SafeArea( child: Stack(children: [ @@ -78,7 +79,7 @@ class RestoreChest extends StatelessWidget { key: keyGoNext, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 0, padding: EdgeInsets.symmetric(vertical: scaleSize(12)), shape: RoundedRectangleBorder( @@ -128,7 +129,7 @@ class RestoreChest extends StatelessWidget { key: keyPastMnemonic, style: ElevatedButton.styleFrom( foregroundColor: Colors.black, - backgroundColor: yellowC, + backgroundColor: context.colorScheme.secondary, elevation: 0, padding: EdgeInsets.symmetric( vertical: scaleSize(8), @@ -188,12 +189,16 @@ class RestoreChest extends StatelessWidget { borderWidth: 1, borderColor: Colors.black, radius: Radius.zero, - color: Colors.white, + color: homeContext.colorScheme.surfaceContainer, child: Text( text, key: keyBubbleSpeak, textAlign: TextAlign.justify, - style: scaledTextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w400), + style: scaledTextStyle( + color: homeContext.colorScheme.onSecondaryContainer, + fontSize: 16, + fontWeight: FontWeight.w400, + ), ), ); } @@ -206,7 +211,7 @@ class RestoreChest extends StatelessWidget { height: scaleSize(37), decoration: BoxDecoration( border: Border.all(color: Colors.grey), - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(3), ), child: TextField( @@ -216,7 +221,7 @@ class RestoreChest extends StatelessWidget { decoration: InputDecoration( border: InputBorder.none, focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: orangeC), + borderSide: BorderSide(color: context.colorScheme.primary), ), contentPadding: EdgeInsets.zero, ), @@ -232,7 +237,7 @@ class RestoreChest extends StatelessWidget { } }, textAlign: TextAlign.center, - style: scaledTextStyle(fontSize: 16), + style: scaledTextStyle(fontSize: 16, color: context.colorScheme.onSecondaryContainer), ), ); } diff --git a/lib/screens/myWallets/show_seed.dart b/lib/screens/myWallets/show_seed.dart index 15f50526e8ab2ce9d0a2cd754cb0ae14a027a9db..f25cd5e3e1ff5c68a78b7e6db7cdb362b4a0f1e9 100644 --- a/lib/screens/myWallets/show_seed.dart +++ b/lib/screens/myWallets/show_seed.dart @@ -1,8 +1,8 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/my_wallets.dart'; @@ -28,7 +28,7 @@ class ShowSeed extends StatelessWidget { WalletData defaultWallet = myWalletProvider.getDefaultWallet(); return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('myMnemonic'.tr()), body: SafeArea( child: SingleChildScrollView( @@ -43,8 +43,8 @@ class ShowSeed extends StatelessWidget { return ScaledSizedBox( height: 15, width: 15, - child: const CircularProgressIndicator( - color: orangeC, + child: CircularProgressIndicator( + color: context.colorScheme.primary, strokeWidth: 2, ), ); @@ -69,7 +69,7 @@ class ShowSeed extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 1, ), onPressed: () { @@ -116,13 +116,13 @@ class ShowSeed extends StatelessWidget { child: ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: () { Navigator.pop(context); @@ -215,7 +215,7 @@ class PrintWallet extends StatelessWidget { onPressed: () { Navigator.pop(context); }), - backgroundColor: yellowC, + backgroundColor: context.colorScheme.secondary, foregroundColor: Colors.black, toolbarHeight: scaleSize(57), title: Text( diff --git a/lib/screens/myWallets/unlocking_wallet.dart b/lib/screens/myWallets/unlocking_wallet.dart index d4c541084a3ebf67c19d6b28fae69be69c3444a5..72b0c9d8ae825d1b960ae8c733de444860f7d820 100644 --- a/lib/screens/myWallets/unlocking_wallet.dart +++ b/lib/screens/myWallets/unlocking_wallet.dart @@ -4,6 +4,7 @@ import 'package:durt2/durt2.dart' show Durt, SafeBox, WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/substrate_sdk.dart'; @@ -42,10 +43,8 @@ class _UnlockingWalletState extends State<UnlockingWallet> { @override Widget build(BuildContext context) { - final walletOptions = - Provider.of<WalletOptionsProvider>(context, listen: false); - final myWalletProvider = - Provider.of<MyWalletsProvider>(context, listen: false); + final walletOptions = Provider.of<WalletOptionsProvider>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); final pinLenght = walletOptions.getPinLenght(widget.wallet.number); @@ -55,7 +54,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { myWalletProvider.isPinLoading = true; }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, body: SafeArea( child: SingleChildScrollView( child: Column( @@ -97,7 +96,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { textAlign: TextAlign.center, style: scaledTextStyle( fontSize: isTall ? 24 : 20, - color: Colors.black, + color: context.colorScheme.onSurface, fontWeight: FontWeight.w700, ), ), @@ -109,7 +108,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { margin: const EdgeInsets.symmetric(horizontal: 16), padding: EdgeInsets.all(isTall ? 24 : 16), decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(24), boxShadow: [ BoxShadow( @@ -126,13 +125,12 @@ class _UnlockingWalletState extends State<UnlockingWallet> { textAlign: TextAlign.center, style: scaledTextStyle( fontSize: isTall ? 16 : 14, - color: Colors.black87, + color: context.colorScheme.onSurface, fontWeight: FontWeight.w500, ), ), ScaledSizedBox(height: isTall ? 24 : 12), - if (!myWalletProvider.isPinValid && - !myWalletProvider.isPinLoading) + if (!myWalletProvider.isPinValid && !myWalletProvider.isPinLoading) Padding( padding: const EdgeInsets.only(bottom: 16), child: Text( @@ -147,8 +145,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { pinForm(context, pinLenght), ScaledSizedBox(height: isTall ? 16 : 8), if (canUnlock) - Consumer<WalletOptionsProvider>( - builder: (context, sub, _) { + Consumer<WalletOptionsProvider>(builder: (context, sub, _) { return InkWell( key: keyCachePassword, onTap: () { @@ -159,10 +156,8 @@ class _UnlockingWalletState extends State<UnlockingWallet> { mainAxisSize: MainAxisSize.min, children: [ Icon( - configBox.get('isCacheChecked') - ? Icons.check_box - : Icons.check_box_outline_blank, - color: orangeC, + configBox.get('isCacheChecked') ? Icons.check_box : Icons.check_box_outline_blank, + color: context.colorScheme.primary, size: scaleSize(20), ), ScaledSizedBox(width: 8), @@ -171,7 +166,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { 'rememberPassword'.tr(), style: scaledTextStyle( fontSize: 12, - color: Colors.grey[700], + color: homeContext.colorScheme.onSurfaceVariant, fontWeight: FontWeight.w500, ), ), @@ -191,7 +186,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { ); } - Widget pinForm(context, pinLenght) { + Widget pinForm(BuildContext context, int pinLenght) { final myWalletProvider = Provider.of<MyWalletsProvider>(context); final sub = Provider.of<SubstrateSdk>(context, listen: false); @@ -199,8 +194,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { return Form( child: Padding( - padding: EdgeInsets.symmetric( - vertical: scaleSize(3), horizontal: scaleSize(isTall ? 30 : 20)), + padding: EdgeInsets.symmetric(vertical: scaleSize(3), horizontal: scaleSize(isTall ? 30 : 20)), child: PinCodeTextField( key: keyPinForm, textCapitalization: TextCapitalization.characters, @@ -229,17 +223,17 @@ class _UnlockingWalletState extends State<UnlockingWallet> { borderRadius: BorderRadius.circular(12), fieldHeight: scaleSize(50), fieldWidth: scaleSize(50), - activeFillColor: Colors.white, - selectedFillColor: Colors.white, - inactiveFillColor: Colors.white, + activeFillColor: context.colorScheme.surfaceContainer, + selectedFillColor: context.colorScheme.surfaceContainer, + inactiveFillColor: context.colorScheme.surfaceContainer, activeColor: pinColor, - selectedColor: orangeC, + selectedColor: context.colorScheme.primary, inactiveColor: Colors.grey[300], borderWidth: 1.5, ), enableActiveFill: true, showCursor: !kDebugMode, - cursorColor: orangeC, + cursorColor: context.colorScheme.primary, cursorHeight: 25, textStyle: scaledTextStyle( fontSize: 24, @@ -253,8 +247,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { onCompleted: (pin) async { myWalletProvider.isPinLoading = true; myWalletProvider.pinCode = pin.toUpperCase(); - final isValid = await sub.checkPassword( - defaultWallet.address, pin.toUpperCase()); + final isValid = await sub.checkPassword(defaultWallet.address, pin.toUpperCase()); if (!isValid) { await Future.delayed(const Duration(milliseconds: 20)); pinColor = Colors.red[600]!; @@ -268,6 +261,7 @@ class _UnlockingWalletState extends State<UnlockingWallet> { myWalletProvider.isPinLoading = false; pinColor = Colors.green[400]!; myWalletProvider.debounceResetPinCode(); + // ignore: use_build_context_synchronously Navigator.pop(context, pin.toUpperCase()); } }, diff --git a/lib/screens/myWallets/wallet_options.dart b/lib/screens/myWallets/wallet_options.dart index 95740e028393ed99ea03cb95343ef94a970daf1c..ae9f0d5fcf7be8cdafddec6abff24268cd7c1915 100644 --- a/lib/screens/myWallets/wallet_options.dart +++ b/lib/screens/myWallets/wallet_options.dart @@ -6,6 +6,7 @@ import 'package:durt2/durt2.dart' show Durt, IdtyStatus, WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/membership_status.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -60,12 +61,10 @@ class WalletOptions extends StatelessWidget { myWalletProvider.reload(); }, child: Scaffold( - backgroundColor: Colors.white, appBar: WalletAppBar( address: wallet.address, - title: isWalletNameIndexed - ? duniterIndexer.walletNameIndexer[walletOptions.address.text]! - : wallet.name!, + currentBalance: BigInt.from(walletOptions.balanceCache[wallet.address] ?? 0), + title: isWalletNameIndexed ? duniterIndexer.walletNameIndexer[walletOptions.address.text]! : wallet.name!, ), body: Stack( children: [ @@ -130,7 +129,7 @@ class WalletOptions extends StatelessWidget { "editWalletName".tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), softWrap: true, ), @@ -260,7 +259,7 @@ class WalletOptions extends StatelessWidget { "displayActivity".tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), softWrap: true, ), @@ -383,7 +382,7 @@ class WalletOptions extends StatelessWidget { child: ElevatedButton( key: keyRenewMembership, style: ElevatedButton.styleFrom( - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), @@ -453,9 +452,7 @@ class WalletOptions extends StatelessWidget { : 'defineWalletAsDefault'.tr(), style: scaledTextStyle( fontSize: 16, - color: walletProvider.isDefaultWallet - ? Colors.grey[500] - : Colors.black87, + color: walletProvider.isDefaultWallet ? Colors.grey[500] : context.colorScheme.onSurface, ), softWrap: true, ), @@ -487,7 +484,7 @@ class WalletOptions extends StatelessWidget { child: ElevatedButton( key: keyConfirmIdentity, style: ElevatedButton.styleFrom( - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), @@ -564,9 +561,7 @@ Widget aloneWalletOptions() { 'createNewWallet'.tr(), style: scaledTextStyle( fontSize: 16, - color: Durt.i.isConnected - ? Colors.black87 - : Colors.grey[500], + color: Durt.i.isConnected ? context.colorScheme.onSurface : Colors.grey[500], ), softWrap: true, ), @@ -599,7 +594,7 @@ Widget aloneWalletOptions() { 'importIdPasswordAccount'.tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: homeContext.colorScheme.onSurface, ), softWrap: true, ), diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index 80bd603a49b871fe1c0f260e63f49a769c958662..6b4904ab3369a009e420644d630672c036241e89 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -2,6 +2,7 @@ import 'package:durt2/durt2.dart' hide Provider; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -27,17 +28,13 @@ class WalletsHome extends StatefulWidget { State<WalletsHome> createState() => _WalletsHomeState(); } -class _WalletsHomeState extends State<WalletsHome> - with SingleTickerProviderStateMixin { +class _WalletsHomeState extends State<WalletsHome> with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - final myWalletProvider = - Provider.of<MyWalletsProvider>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); return Scaffold( - body: myWalletProvider.listWallets.length == 1 - ? WalletOptions(wallet: myWalletProvider.listWallets[0]) - : _WalletsHomeContent(), + body: myWalletProvider.listWallets.length == 1 ? WalletOptions(wallet: myWalletProvider.listWallets[0]) : _WalletsHomeContent(), ); } } @@ -45,16 +42,15 @@ class _WalletsHomeState extends State<WalletsHome> class _WalletsHomeContent extends StatelessWidget { @override Widget build(BuildContext context) { - final myWalletProvider = - Provider.of<MyWalletsProvider>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); final currentChestNumber = myWalletProvider.getCurrentSafe; - final SafeBox currentChest = - Durt.i.walletService.safeBox.get(currentChestNumber)!; + final SafeBox currentChest = Durt.i.walletService.safeBox.get(currentChestNumber)!; return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: AppBar( toolbarHeight: scaleSize(57), + backgroundColor: context.colorScheme.tertiary, title: Row( children: [ Image.asset( @@ -64,16 +60,12 @@ class _WalletsHomeContent extends StatelessWidget { ScaledSizedBox(width: 17), Text( currentChest.name, - style: scaledTextStyle( - color: Colors.grey[850], - fontSize: 16, - fontWeight: FontWeight.w500), + style: scaledTextStyle(color: context.colorScheme.onSurface, fontSize: 16, fontWeight: FontWeight.w500), ), ], ), ), - bottomNavigationBar: - Consumer<MyWalletsProvider>(builder: (context, _, __) { + bottomNavigationBar: Consumer<MyWalletsProvider>(builder: (context, _, __) { return myWalletProvider.lastFlyBy == null ? const GeckoBottomAppBar( actualRoute: 'safeHome', @@ -132,8 +124,7 @@ class _WalletsHomeContent extends StatelessWidget { Text( 'explainDraggableWallet'.tr(), textAlign: TextAlign.center, - style: scaledTextStyle( - fontSize: 16, fontWeight: FontWeight.w500), + style: scaledTextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), ], )) @@ -142,15 +133,14 @@ class _WalletsHomeContent extends StatelessWidget { enableOverlayTab: true, ), ], - colorShadow: orangeC, + colorShadow: context.colorScheme.primary, textSkip: "skip".tr(), paddingFocus: 10, opacityShadow: 0.8, ); // configBox.delete('showDraggableTutorial'); - final bool showDraggableTutorial = - configBox.get('showDraggableTutorial') ?? true; + final bool showDraggableTutorial = configBox.get('showDraggableTutorial') ?? true; if (myWalletProvider.listWallets.length > 1 && showDraggableTutorial) { tutorialCoachMark.show(context: context); @@ -168,25 +158,16 @@ class _WalletsHomeContent extends StatelessWidget { child: WalletTileMembre(wallet: myWalletProvider.idtyWallet!), ), ), - SliverGrid.count( - key: keyListWallets, - crossAxisCount: nTule, - childAspectRatio: 1, - crossAxisSpacing: 0, - mainAxisSpacing: 0, - children: <Widget>[ - for (final repository in myWalletProvider.listWalletsWithoutIdty) - DragTuleAction( - wallet: repository, - child: WalletTile(repository: repository), - ), - Consumer<SubstrateSdk>(builder: (context, sub, _) { - return Durt.i.isConnected && - myWalletProvider.listWallets.length < maxWalletsInSafe - ? const AddNewDerivationButton() - : const Text(''); - }), - ]), + SliverGrid.count(key: keyListWallets, crossAxisCount: nTule, childAspectRatio: 1, crossAxisSpacing: 0, mainAxisSpacing: 0, children: <Widget>[ + for (final repository in myWalletProvider.listWalletsWithoutIdty) + DragTuleAction( + wallet: repository, + child: WalletTile(repository: repository), + ), + Consumer<SubstrateSdk>(builder: (context, sub, _) { + return Durt.i.isConnected && myWalletProvider.listWallets.length < maxWalletsInSafe ? const AddNewDerivationButton() : const Text(''); + }), + ]), const SliverToBoxAdapter(child: ChestOptionsButtons()), ]), ); diff --git a/lib/screens/my_contacts.dart b/lib/screens/my_contacts.dart index cd88da0c4db41f5e07ad9001a95e4560bebe30e1..4f4dd18d2a0383e637f14fc5a54a26afc2039c69 100644 --- a/lib/screens/my_contacts.dart +++ b/lib/screens/my_contacts.dart @@ -1,4 +1,5 @@ import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/providers/wallets_profiles.dart'; @@ -53,7 +54,7 @@ class _ContactsScreenState extends State<ContactsScreen> { } }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('contactsManagementWithNbr'.tr(args: ['${allContacts.length}'])), bottomNavigationBar: const GeckoBottomAppBar(), body: SafeArea( @@ -70,7 +71,7 @@ class _ContactsScreenState extends State<ContactsScreen> { prefixIcon: const Icon(Icons.search), border: const OutlineInputBorder(), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: orangeC), + borderSide: BorderSide(color: context.colorScheme.primary), ), contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), ), diff --git a/lib/screens/onBoarding/1.dart b/lib/screens/onBoarding/1.dart index 0dd40e48429772c3f976cf2698b925295906640f..da8dda3c739e2c09bd3f75532b057601b9b9f3d3 100644 --- a/lib/screens/onBoarding/1.dart +++ b/lib/screens/onBoarding/1.dart @@ -1,7 +1,7 @@ // ignore_for_file: file_names import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/2.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -13,7 +13,7 @@ class OnboardingStepOne extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('newWallet'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart index 619ca93fedfcd853bf9744d29b2d1d483357fbe7..736937f52bb1d9409cd94fba9ca0cb566a5749f8 100644 --- a/lib/screens/onBoarding/10.dart +++ b/lib/screens/onBoarding/10.dart @@ -66,7 +66,7 @@ class _OnboardingStepTenState extends State<OnboardingStepTen> { myWalletProvider.isPinLoading = true; }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('myPassword'.tr()), body: SafeArea( child: Stack(children: [ @@ -115,13 +115,13 @@ class _OnboardingStepTenState extends State<OnboardingStepTen> { const Spacer(), Icon( configBox.get('isCacheChecked') ?? false ? Icons.check_box : Icons.check_box_outline_blank, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(22), ), ScaledSizedBox(width: 8), Text( 'rememberPassword'.tr(), - style: scaledTextStyle(fontSize: 14, color: Colors.grey[700]), + style: scaledTextStyle(fontSize: 14, color: homeContext.colorScheme.onSurfaceVariant), ), const Spacer() ])) @@ -180,7 +180,7 @@ class _OnboardingStepTenState extends State<OnboardingStepTen> { showCursor: !kDebugMode, cursorColor: Colors.black, textStyle: const TextStyle(fontSize: 24, height: 1.6), - backgroundColor: const Color(0xffF9F9F1), + backgroundColor: homeContext.colorScheme.surface, enableActiveFill: false, controller: enterPin, keyboardType: TextInputType.number, diff --git a/lib/screens/onBoarding/11_congratulations.dart b/lib/screens/onBoarding/11_congratulations.dart index 0662093c174c6c9022f39f383232aab6900104ae..3e9245af24ad9d0aff1026535fa02e70920b1aea 100644 --- a/lib/screens/onBoarding/11_congratulations.dart +++ b/lib/screens/onBoarding/11_congratulations.dart @@ -4,6 +4,7 @@ import 'dart:math'; import 'package:confetti/confetti.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -22,7 +23,7 @@ class OnboardingStepEleven extends StatelessWidget { return PopScope( canPop: false, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('allGood'.tr()), body: SafeArea( child: Stack(children: [ @@ -132,13 +133,13 @@ Widget finishButton(BuildContext context) { key: keyGoWalletsHome, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: () { Navigator.pushNamedAndRemoveUntil(context, '/mywallets', ModalRoute.withName('/')); diff --git a/lib/screens/onBoarding/2.dart b/lib/screens/onBoarding/2.dart index 0e777beb3938b08eb1600e646dcdbee0cd557919..33cd15431bbbfb444e2d106d46c6c6f25e65d6cb 100644 --- a/lib/screens/onBoarding/2.dart +++ b/lib/screens/onBoarding/2.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/3.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -14,7 +14,7 @@ class OnboardingStepTwo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('yourMnemonic'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/3.dart b/lib/screens/onBoarding/3.dart index 6e6aacfaaca96f7a4d2b6d451b444f2565f33c8d..bc91ed45cd9c3b96517e879cd2f9c971a0f857bd 100644 --- a/lib/screens/onBoarding/3.dart +++ b/lib/screens/onBoarding/3.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/4.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -14,7 +14,7 @@ class OnboardingStepThree extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('yourMnemonic'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/4.dart b/lib/screens/onBoarding/4.dart index d859674841dfefc5492378f29203da8d42225050..bd12614153453b7b5a2518da0a1bd43a6aa415ee 100644 --- a/lib/screens/onBoarding/4.dart +++ b/lib/screens/onBoarding/4.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/5.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -14,7 +14,7 @@ class OnboardingStepFor extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('yourMnemonic'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/5.dart b/lib/screens/onBoarding/5.dart index 8dfd761e07fceee3f0bc6ddcaf63839b236a04df..431de37ce1c1e0067243738e1f517feb087b461c 100644 --- a/lib/screens/onBoarding/5.dart +++ b/lib/screens/onBoarding/5.dart @@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -60,9 +61,9 @@ class _ChooseChestState extends State<OnboardingStepFive> { Widget sentanceArray() { if (mnemonicList == null) { - return const Center( + return Center( child: CircularProgressIndicator( - color: orangeC, + color: context.colorScheme.primary, strokeWidth: 2, ), ); @@ -110,9 +111,9 @@ class _ChooseChestState extends State<OnboardingStepFive> { if (isLoading) Container( color: const Color(0xffeeeedd).withValues(alpha: 0.7), - child: const Center( + child: Center( child: CircularProgressIndicator( - color: orangeC, + color: context.colorScheme.primary, strokeWidth: 2, ), ), @@ -142,7 +143,7 @@ class _ChooseChestState extends State<OnboardingStepFive> { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('yourMnemonic'.tr()), body: SafeArea( child: Stack(children: [ @@ -167,7 +168,7 @@ class _ChooseChestState extends State<OnboardingStepFive> { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 1, ), onPressed: isMnemonicGenerated @@ -203,6 +204,7 @@ class _ChooseChestState extends State<OnboardingStepFive> { child: Image.asset( 'assets/printer.png', height: scaleSize(42), + color: context.colorScheme.onSurface, ), ), ], @@ -263,13 +265,13 @@ class _ChooseChestState extends State<OnboardingStepFive> { key: keyGoNext, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(vertical: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: isMnemonicGenerated ? () { diff --git a/lib/screens/onBoarding/6.dart b/lib/screens/onBoarding/6.dart index 9f25da9b6aca5d1ced93015828fbdb6057c5b68f..ac4dfa9389cf4601b6679765fbb1803f91a38c62 100644 --- a/lib/screens/onBoarding/6.dart +++ b/lib/screens/onBoarding/6.dart @@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -36,7 +37,7 @@ class OnboardingStepSix extends StatelessWidget { generateWalletProvider.askedWordColor = Colors.black; }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('yourMnemonic'.tr()), body: SafeArea( child: Stack(children: [ @@ -51,7 +52,7 @@ class OnboardingStepSix extends StatelessWidget { ScaledSizedBox(height: isTall ? 40 : 5), if (isTall) Text('${generateWalletProvider.nbrWord + 1}', - key: keyAskedWord, style: scaledTextStyle(fontSize: 19, color: orangeC, fontWeight: FontWeight.w500)), + key: keyAskedWord, style: scaledTextStyle(fontSize: 19, color: context.colorScheme.primary, fontWeight: FontWeight.w500)), if (isTall) ScaledSizedBox(height: 5), Container( decoration: BoxDecoration( @@ -123,13 +124,13 @@ Widget nextButton(BuildContext context, String text, nextScreen, bool isFast) { key: keyGoNext, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: () { Navigator.push(context, FaderTransition(page: nextScreen, isFast: isFast)); diff --git a/lib/screens/onBoarding/7.dart b/lib/screens/onBoarding/7.dart index cb6bf0082c44548e58a4a6ea10bc40eaa482057c..0161b00cf5aec60289bff430fe7efa433bb3d06f 100644 --- a/lib/screens/onBoarding/7.dart +++ b/lib/screens/onBoarding/7.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/8.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -16,7 +16,7 @@ class OnboardingStepSeven extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('myPassword'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/8.dart b/lib/screens/onBoarding/8.dart index e6084d40e318411a8d472c4291946fcd4e50167a..a2ee0531cbaa228aee63f844e1a81aeca2b62efb 100644 --- a/lib/screens/onBoarding/8.dart +++ b/lib/screens/onBoarding/8.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/screens/onBoarding/9.dart'; import 'package:gecko/widgets/commons/intro_info.dart'; import 'package:gecko/widgets/commons/offline_info.dart'; @@ -16,7 +16,7 @@ class OnboardingStepEight extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('myPassword'.tr()), body: SafeArea( child: Stack(children: [ diff --git a/lib/screens/onBoarding/9.dart b/lib/screens/onBoarding/9.dart index ef400b647ec9aa9bdd2f0e52f9af045d139dbbdf..201fadb89c12a9b057430b3499db70b65aac2faf 100644 --- a/lib/screens/onBoarding/9.dart +++ b/lib/screens/onBoarding/9.dart @@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -40,7 +41,7 @@ class _OnboardingStepNineState extends State<OnboardingStepNine> { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('myPassword'.tr()), body: SafeArea( child: Stack(children: [ @@ -61,7 +62,7 @@ class _OnboardingStepNineState extends State<OnboardingStepNine> { ); } - Widget pinForm(context, int walletNbr, int derivation) { + Widget pinForm(BuildContext context, int walletNbr, int derivation) { Color? pinColor = const Color(0xFFA4B600); return Form( @@ -104,7 +105,7 @@ class _OnboardingStepNineState extends State<OnboardingStepNine> { showCursor: !kDebugMode, cursorColor: Colors.black, textStyle: const TextStyle(fontSize: 24, height: 1.6), - backgroundColor: const Color(0xffF9F9F1), + backgroundColor: homeContext.colorScheme.surface, enableActiveFill: false, controller: enterPin, keyboardType: TextInputType.number, diff --git a/lib/screens/qrcode_fullscreen.dart b/lib/screens/qrcode_fullscreen.dart index bc116e6935d79512eaa8abb954982fbcdcae7453..bfdff6b7440e19f39e1715e717bd6298adb9752d 100644 --- a/lib/screens/qrcode_fullscreen.dart +++ b/lib/screens/qrcode_fullscreen.dart @@ -1,6 +1,7 @@ // ignore_for_file: must_be_immutable import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -57,18 +58,18 @@ class _QrCodeFullscreenState extends State<QrCodeFullscreen> { backgroundColor: widget.color ?? Colors.black, toolbarHeight: scaleSize(57), leading: IconButton( - icon: const Icon(Icons.arrow_back, color: orangeC), + icon: Icon(Icons.arrow_back, color: context.colorScheme.primary), onPressed: () { Navigator.pop(context); }), title: Text( 'QR Code de ${getShortPubkey(widget.address)}', - style: scaledTextStyle(color: orangeC, fontSize: 17), + style: scaledTextStyle(color: context.colorScheme.primary, fontSize: 17), )), body: SafeArea( child: SizedBox.expand( child: Container( - color: widget.color ?? backgroundColor, + color: widget.color ?? context.colorScheme.surface, child: Column( children: [ const Spacer(), @@ -76,6 +77,12 @@ class _QrCodeFullscreenState extends State<QrCodeFullscreen> { data: widget.address, version: QrVersions.auto, size: scaleSize(320), + dataModuleStyle: QrDataModuleStyle( + color: context.colorScheme.onSecondaryContainer, + ), + eyeStyle: QrEyeStyle( + color: context.colorScheme.onSecondaryContainer, + ), ), const Spacer(), ScaledSizedBox( @@ -83,8 +90,8 @@ class _QrCodeFullscreenState extends State<QrCodeFullscreen> { height: 55, child: OutlinedButton( style: OutlinedButton.styleFrom( - foregroundColor: orangeC, - side: const BorderSide(color: orangeC, width: 1), + foregroundColor: context.colorScheme.primary, + side: BorderSide(color: context.colorScheme.primary, width: 1), padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), @@ -98,7 +105,7 @@ class _QrCodeFullscreenState extends State<QrCodeFullscreen> { style: scaledTextStyle( fontSize: 17, fontWeight: FontWeight.w500, - color: orangeC, + color: context.colorScheme.primary, ), ), ), diff --git a/lib/screens/search.dart b/lib/screens/search.dart index 90123b62310906a83a280ddb692e9b90530b6691..802e79a1f886e45a5e7c5b54185be7ed83be542f 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/search.dart'; @@ -42,7 +42,7 @@ class _SearchScreenState extends State<SearchScreen> { searchProvider.searchController.text = ''; }, child: Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('search'.tr()), body: SafeArea( child: Stack(children: [ @@ -128,13 +128,13 @@ class _SearchScreenState extends State<SearchScreen> { boxShadow: canValidate || searchProvider.canPasteAddress ? [ BoxShadow( - color: orangeC.withValues(alpha: 0.3), + color: context.colorScheme.primary.withValues(alpha: 0.3), blurRadius: 12, offset: const Offset(0, 6), spreadRadius: -2, ), BoxShadow( - color: orangeC.withValues(alpha: 0.2), + color: context.colorScheme.primary.withValues(alpha: 0.2), blurRadius: 4, offset: const Offset(0, 2), spreadRadius: 0, @@ -146,7 +146,7 @@ class _SearchScreenState extends State<SearchScreen> { key: keyConfirmSearch, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 0, padding: const EdgeInsets.symmetric(vertical: 12), shape: RoundedRectangleBorder( @@ -223,7 +223,7 @@ class _SearchScreenState extends State<SearchScreen> { child: ClipOval( key: keyOpenWalletsHomme, child: Material( - color: yellowC, + color: context.colorScheme.secondary, child: Padding( padding: EdgeInsets.all(scaleSize(14.5)), child: Icon( diff --git a/lib/screens/search_result.dart b/lib/screens/search_result.dart index cefaba31e7d8b661302b1667e2b63b0408e6cad1..936fef1c591d04309c14056ddf3921b96c9992b3 100644 --- a/lib/screens/search_result.dart +++ b/lib/screens/search_result.dart @@ -1,4 +1,5 @@ import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -23,7 +24,7 @@ class SearchResultScreen extends StatelessWidget { final avatarSize = scaleSize(37); return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: GeckoAppBar('researchResults'.tr()), bottomNavigationBar: const GeckoBottomAppBar(), body: SafeArea( diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 5ff588f8b8bd29c508d3676da59c46b3b7869d55..590e9c72b8524683f2272040b5b7b3d79ba4fc9e 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -3,6 +3,8 @@ import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; +import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/duniter_indexer.dart'; @@ -10,7 +12,7 @@ import 'package:gecko/providers/home.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/providers/settings_provider.dart'; import 'package:gecko/providers/substrate_sdk.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/providers/theme_provider.dart' as theme_provider; import 'package:gecko/widgets/commons/loading.dart'; import 'package:gecko/widgets/commons/top_appbar.dart'; import 'package:gecko/widgets/commons/confirmation_dialog.dart'; @@ -95,7 +97,7 @@ class _SettingsScreenState extends State<SettingsScreen> { final isSmallScreen = screenSize.height < 700; return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, appBar: GeckoAppBar('parameters'.tr()), body: SafeArea( child: SingleChildScrollView( @@ -112,7 +114,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: isSmallScreen ? 15 : 16, fontWeight: FontWeight.w600, - color: Colors.black87, + color: Theme.of(context).textTheme.titleLarge?.color, ), ), ScaledSizedBox(height: isSmallScreen ? 8 : 12), @@ -120,7 +122,7 @@ class _SettingsScreenState extends State<SettingsScreen> { // Carte Unité de devise Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -142,10 +144,31 @@ class _SettingsScreenState extends State<SettingsScreen> { ), ScaledSizedBox(height: isSmallScreen ? 12 : 16), + // Carte Sélection du thème + Container( + width: double.infinity, + decoration: BoxDecoration( + color: context.colorScheme.surfaceContainer, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 2), + ), + ], + ), + child: Padding( + padding: EdgeInsets.all(scaleSize(isSmallScreen ? 10 : 14)), + child: chooseThemeMode(context), + ), + ), + ScaledSizedBox(height: isSmallScreen ? 12 : 16), + // Carte Nettoyage du cache Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -187,7 +210,7 @@ class _SettingsScreenState extends State<SettingsScreen> { children: [ Icon( Icons.cleaning_services_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(isSmallScreen ? 20 : 24), ), ScaledSizedBox(width: 12), @@ -195,7 +218,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'clearCache'.tr(), style: scaledTextStyle( fontSize: isSmallScreen ? 14 : 15, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -211,7 +234,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: isSmallScreen ? 15 : 16, fontWeight: FontWeight.w600, - color: Colors.black87, + color: Theme.of(context).textTheme.titleLarge?.color, ), ), ScaledSizedBox(height: isSmallScreen ? 8 : 12), @@ -219,7 +242,7 @@ class _SettingsScreenState extends State<SettingsScreen> { // Carte Nœud Duniter Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -244,7 +267,7 @@ class _SettingsScreenState extends State<SettingsScreen> { // Carte Indexer Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( @@ -267,23 +290,14 @@ class _SettingsScreenState extends State<SettingsScreen> { ScaledSizedBox(height: isSmallScreen ? 20 : 24), // Section Danger - Text( - 'dangerZone'.tr(), - style: scaledTextStyle( - fontSize: isSmallScreen ? 15 : 16, - fontWeight: FontWeight.w600, - color: const Color(0xffD80000), - ), - ), ScaledSizedBox(height: isSmallScreen ? 8 : 12), // Carte Suppression des coffres Container( decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, + border: Border.all(color: const Color(0xffD80000).withValues(alpha: 0.1)), borderRadius: BorderRadius.circular(12), - border: Border.all( - color: const Color(0xffD80000).withValues(alpha: 0.1)), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.05), @@ -292,34 +306,38 @@ class _SettingsScreenState extends State<SettingsScreen> { ), ], ), - child: InkWell( - key: keyDeleteAllWallets, - onTap: () async { - log.w('Oublier tous mes coffres'); - await _myWallets.deleteAllWallet(context); - }, - child: Padding( - padding: - EdgeInsets.all(scaleSize(isSmallScreen ? 10 : 14)), - child: Row( - children: [ - Icon( - Icons.delete_forever_rounded, - color: const Color(0xffD80000), - size: scaleSize(isSmallScreen ? 20 : 24), - ), - ScaledSizedBox(width: 12), - Text( - 'forgetAllMyChests'.tr(), - style: scaledTextStyle( - fontSize: isSmallScreen ? 14 : 15, - color: const Color(0xffD80000), - fontWeight: FontWeight.w600, - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + key: keyDeleteAllWallets, + onTap: () async { + log.w('Oublier tous mes coffres'); + await _myWallets.deleteAllWallet(context); + }, + child: Padding( + padding: EdgeInsets.all(scaleSize(isSmallScreen ? 10 : 14)), + child: Row( + children: [ + Icon( + Icons.delete_forever_rounded, + color: const Color(0xffD80000), + size: scaleSize(isSmallScreen ? 20 : 24), + ), + ScaledSizedBox(width: 12), + Text( + 'forgetAllMyChests'.tr(), + style: scaledTextStyle( + fontSize: isSmallScreen ? 14 : 15, + color: const Color(0xffD80000), + fontWeight: FontWeight.w600, + ), + ), + ], ), - ], + ), ), - ), + ], ), ), ScaledSizedBox(height: isSmallScreen ? 20 : 24), @@ -342,7 +360,7 @@ class _SettingsScreenState extends State<SettingsScreen> { children: [ Icon( Icons.calculate_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(24), ), ScaledSizedBox(width: 12), @@ -350,7 +368,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'showUdAmounts'.tr(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), const Spacer(), @@ -359,7 +377,7 @@ class _SettingsScreenState extends State<SettingsScreen> { final bool isUdUnit = configBox.get('isUdUnit') ?? false; return Switch( value: isUdUnit, - activeColor: orangeC, + activeColor: context.colorScheme.primary, inactiveThumbColor: Colors.grey[400], inactiveTrackColor: Colors.grey[300], onChanged: (bool value) async { @@ -390,7 +408,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: 16, fontWeight: FontWeight.w600, - color: Colors.black87, + color: Theme.of(context).textTheme.titleLarge?.color, ), ), content: SingleChildScrollView( @@ -411,10 +429,8 @@ class _SettingsScreenState extends State<SettingsScreen> { mainAxisSize: MainAxisSize.min, children: [ Icon( - isSelected - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: isSelected ? orangeC : Colors.grey[400], + isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: isSelected ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -423,7 +439,7 @@ class _SettingsScreenState extends State<SettingsScreen> { node.endpoint!, style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ), @@ -495,7 +511,7 @@ class _SettingsScreenState extends State<SettingsScreen> { children: [ Icon( Icons.dns_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(24), ), ScaledSizedBox(width: 12), @@ -503,7 +519,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'currencyNode'.tr(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ScaledSizedBox(width: 12), @@ -527,7 +543,6 @@ class _SettingsScreenState extends State<SettingsScreen> { vertical: scaleSize(6), ), decoration: BoxDecoration( - color: Colors.grey[100], borderRadius: BorderRadius.circular(8), border: Border.all(color: Colors.grey[300]!), ), @@ -538,7 +553,7 @@ class _SettingsScreenState extends State<SettingsScreen> { getDisplayMode(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ScaledSizedBox(width: 4), @@ -557,12 +572,8 @@ class _SettingsScreenState extends State<SettingsScreen> { child: Row( children: [ Icon( - configBox.get('autoEndpoint') == true - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: configBox.get('autoEndpoint') == true - ? orangeC - : Colors.grey[400], + configBox.get('autoEndpoint') == true ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: configBox.get('autoEndpoint') == true ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -570,7 +581,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'Auto', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -582,12 +593,8 @@ class _SettingsScreenState extends State<SettingsScreen> { child: Row( children: [ Icon( - configBox.get('autoEndpoint') != true - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: configBox.get('autoEndpoint') != true - ? orangeC - : Colors.grey[400], + configBox.get('autoEndpoint') != true ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: configBox.get('autoEndpoint') != true ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -595,7 +602,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'manual'.tr(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -616,7 +623,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'select'.tr(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -683,7 +690,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: 13, fontStyle: FontStyle.italic, - color: Colors.grey[600], + color: Theme.of(context).textTheme.bodySmall?.color, ), ), ], @@ -695,7 +702,6 @@ class _SettingsScreenState extends State<SettingsScreen> { ScaledSizedBox(height: 12), Container( decoration: BoxDecoration( - color: Colors.grey[100], borderRadius: BorderRadius.circular(8), border: Border.all(color: Colors.grey[300]!), ), @@ -704,7 +710,7 @@ class _SettingsScreenState extends State<SettingsScreen> { focusNode: _duniterFocusNode, controller: endpointController, autocorrect: false, - style: scaledTextStyle(fontSize: 14), + style: scaledTextStyle(fontSize: 14, color: Theme.of(context).textTheme.bodyMedium?.color), decoration: InputDecoration( contentPadding: EdgeInsets.symmetric( horizontal: scaleSize(12), @@ -738,7 +744,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'blockN'.tr(args: [sub.blocNumber.toString()]), style: scaledTextStyle( fontSize: 13, - color: Colors.grey[600], + color: Theme.of(context).textTheme.bodySmall?.color, ), ), ], @@ -766,7 +772,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: 16, fontWeight: FontWeight.w600, - color: Colors.black87, + color: Theme.of(context).textTheme.titleLarge?.color, ), ), content: SingleChildScrollView( @@ -787,10 +793,8 @@ class _SettingsScreenState extends State<SettingsScreen> { mainAxisSize: MainAxisSize.min, children: [ Icon( - isSelected - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: isSelected ? orangeC : Colors.grey[400], + isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: isSelected ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -799,7 +803,7 @@ class _SettingsScreenState extends State<SettingsScreen> { endpoint, style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ), @@ -856,7 +860,7 @@ class _SettingsScreenState extends State<SettingsScreen> { children: [ Icon( Icons.storage_rounded, - color: orangeC, + color: context.colorScheme.primary, size: scaleSize(24), ), ScaledSizedBox(width: 12), @@ -864,13 +868,13 @@ class _SettingsScreenState extends State<SettingsScreen> { 'Indexer', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ScaledSizedBox(width: 12), Icon( - indexerEndpoint != '' ? Icons.check_circle : Icons.error, - color: indexerEndpoint != '' ? Colors.green : Colors.red, + _indexerEndpointController.text.isNotEmpty && _indexerEndpointController.text != 'https://' ? Icons.check_circle : Icons.error, + color: _indexerEndpointController.text.isNotEmpty && _indexerEndpointController.text != 'https://' ? Colors.green : Colors.red, size: scaleSize(16), ), const Spacer(), @@ -883,7 +887,6 @@ class _SettingsScreenState extends State<SettingsScreen> { vertical: scaleSize(6), ), decoration: BoxDecoration( - color: Colors.grey[100], borderRadius: BorderRadius.circular(8), border: Border.all(color: Colors.grey[300]!), ), @@ -894,7 +897,7 @@ class _SettingsScreenState extends State<SettingsScreen> { getDisplayMode(), style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ScaledSizedBox(width: 4), @@ -912,13 +915,8 @@ class _SettingsScreenState extends State<SettingsScreen> { child: Row( children: [ Icon( - !configBox.containsKey('customIndexer') - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: - !configBox.containsKey('customIndexer') - ? orangeC - : Colors.grey[400], + !configBox.containsKey('customIndexer') ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: !configBox.containsKey('customIndexer') ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -926,7 +924,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'Auto', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -937,13 +935,8 @@ class _SettingsScreenState extends State<SettingsScreen> { child: Row( children: [ Icon( - configBox.containsKey('customIndexer') - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: - configBox.containsKey('customIndexer') - ? orangeC - : Colors.grey[400], + configBox.containsKey('customIndexer') ? Icons.radio_button_checked : Icons.radio_button_unchecked, + color: configBox.containsKey('customIndexer') ? context.colorScheme.primary : Colors.grey[400], size: scaleSize(20), ), ScaledSizedBox(width: 12), @@ -951,7 +944,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'Manuel', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -971,7 +964,7 @@ class _SettingsScreenState extends State<SettingsScreen> { 'Sélectionner', style: scaledTextStyle( fontSize: 14, - color: Colors.black87, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), ], @@ -1039,7 +1032,7 @@ class _SettingsScreenState extends State<SettingsScreen> { style: scaledTextStyle( fontSize: 13, fontStyle: FontStyle.italic, - color: Colors.grey[600], + color: Theme.of(context).textTheme.bodySmall?.color, ), ), ], @@ -1059,7 +1052,7 @@ class _SettingsScreenState extends State<SettingsScreen> { focusNode: _indexerFocusNode, controller: indexerEndpointController, autocorrect: false, - style: scaledTextStyle(fontSize: 14), + style: scaledTextStyle(fontSize: 14, color: Theme.of(context).textTheme.bodyMedium?.color), decoration: InputDecoration( contentPadding: EdgeInsets.symmetric( horizontal: scaleSize(12), @@ -1086,4 +1079,59 @@ class _SettingsScreenState extends State<SettingsScreen> { ], ); } + + Widget chooseThemeMode(BuildContext context) { + final themeProvider = Provider.of<theme_provider.ThemeProvider>(context, listen: false); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'theme'.tr(), + style: scaledTextStyle( + fontSize: 14, + color: Theme.of(context).textTheme.bodyMedium?.color, + ), + ), + ScaledSizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Consumer<theme_provider.ThemeProvider>( + builder: (context, theme, _) { + return SegmentedButton<theme_provider.ThemeModeSetting>( + segments: <ButtonSegment<theme_provider.ThemeModeSetting>>[ + ButtonSegment( + value: theme_provider.ThemeModeSetting.light, + label: Text('light'.tr()), + icon: const Icon(Icons.light_mode), + ), + ButtonSegment( + value: theme_provider.ThemeModeSetting.system, + label: Text('system'.tr()), + icon: const Icon(Icons.brightness_auto), + ), + ButtonSegment( + value: theme_provider.ThemeModeSetting.dark, + label: Text('dark'.tr()), + icon: const Icon(Icons.dark_mode), + ), + ], + selected: {theme.themeModeSetting}, + onSelectionChanged: (Set<theme_provider.ThemeModeSetting> newSelection) { + themeProvider.setThemeMode(newSelection.first); + }, + style: SegmentedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.surfaceContainerHighest, + foregroundColor: Theme.of(context).colorScheme.onSurface, + selectedForegroundColor: Theme.of(context).colorScheme.onPrimary, + selectedBackgroundColor: Theme.of(context).colorScheme.primary, + ), + ); + }, + ), + ], + ), + ], + ); + } } diff --git a/lib/screens/template_screen.dart b/lib/screens/template_screen.dart index 3cccbb47e6966791e24a1660e34bbee62d350f69..d43c8ad18033248359432eef948dd2e265a45e5b 100644 --- a/lib/screens/template_screen.dart +++ b/lib/screens/template_screen.dart @@ -1,5 +1,5 @@ -import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/widgets/commons/top_appbar.dart'; @@ -11,7 +11,7 @@ class TemplateScreen extends StatelessWidget { // final _homeProvider = Provider.of<HomeProvider>(context); return Scaffold( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, appBar: const GeckoAppBar('Template screen'), body: SafeArea( child: Column(children: <Widget>[ diff --git a/lib/screens/transaction_in_progress.dart b/lib/screens/transaction_in_progress.dart index 8894dfb52f0ff144a136ba885b86e3a471d31799..1f80b96458de47ba9f473720a865400eeda44e16 100644 --- a/lib/screens/transaction_in_progress.dart +++ b/lib/screens/transaction_in_progress.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/transaction_content.dart'; @@ -76,7 +77,6 @@ class _TransactionInProgressState extends State<TransactionInProgress> { if (txContent == null) { return Scaffold( - backgroundColor: Colors.white, body: Center( child: Loading( size: 30, @@ -104,9 +104,8 @@ class _TransactionInProgressState extends State<TransactionInProgress> { } return Scaffold( - backgroundColor: Colors.white, appBar: AppBar( - backgroundColor: headerColor, + backgroundColor: context.colorScheme.tertiary, elevation: 0, automaticallyImplyLeading: false, centerTitle: true, @@ -114,7 +113,7 @@ class _TransactionInProgressState extends State<TransactionInProgress> { 'extrinsicInProgress'.tr(args: [actionMap[widget.transType] ?? 'strangeTransaction'.tr()]), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, fontWeight: FontWeight.w500, ), ), @@ -123,7 +122,7 @@ class _TransactionInProgressState extends State<TransactionInProgress> { children: [ Container( width: double.infinity, - color: headerColor, + color: context.colorScheme.tertiary, padding: EdgeInsets.symmetric( horizontal: scaleSize(24), vertical: scaleSize(16), @@ -200,7 +199,7 @@ class _TransactionInProgressState extends State<TransactionInProgress> { style: scaledTextStyle( fontSize: 15, height: 1.4, - color: Colors.black87, + color: context.colorScheme.onSurface, ), ), ), diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index d0ecaf8dd3989fcefcda16452e778b5241a6e462..4cfd80c54791a03575b6e225f68b86d3651096fe 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -1,8 +1,9 @@ // ignore_for_file: use_build_context_synchronously -import 'package:durt2/durt2.dart' show Durt; +import 'package:durt2/durt2.dart' show Durt, IdtyStatus; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:flutter/material.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -19,13 +20,14 @@ import 'package:gecko/widgets/page_route_no_transition.dart'; import 'package:gecko/widgets/payment_popup.dart'; import 'package:provider/provider.dart'; import 'package:gecko/widgets/commons/wallet_app_bar.dart'; +import 'package:gecko/models/wallet_header_data.dart'; +import 'package:gecko/providers/duniter_indexer.dart'; const double buttonSize = 75; const double buttonFontSize = 13; class WalletViewScreen extends StatefulWidget { - const WalletViewScreen( - {required this.address, required this.username, super.key}); + const WalletViewScreen({required this.address, required this.username, super.key}); final String address; final String? username; @@ -36,114 +38,148 @@ class WalletViewScreen extends StatefulWidget { class _WalletViewScreenState extends State<WalletViewScreen> { late String address; late String? username; + late Future<WalletHeaderData> _headerDataFuture; @override void initState() { super.initState(); address = widget.address; username = widget.username; + _headerDataFuture = _loadWalletData(); + } + + Future<WalletHeaderData> _loadWalletData() async { + final sub = Provider.of<SubstrateSdk>(context, listen: false); + final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); + + final (idtyStatusValue, balanceResult, certData) = await ( + sub.idtyStatus(address), + sub.getBalance(address), + sub.getCertsCounter(address), + ).wait; + + final data = WalletHeaderData( + hasIdentity: idtyStatusValue != IdtyStatus.none, + isOwner: myWalletProvider.isOwner(address), + walletName: duniterIndexer.walletNameIndexer[address], + balance: BigInt.from(balanceResult.transferableBalance), + certCount: certData, + ); + + await walletHeaderDataBox.put(address, data); + return data; } @override Widget build(BuildContext context) { - final walletProfile = - Provider.of<WalletsProfilesProvider>(context, listen: false); + final walletProfile = Provider.of<WalletsProfilesProvider>(context, listen: false); walletProfile.address = address; Durt.i.walletService.setDefaultWallet(address); - return Scaffold( - backgroundColor: backgroundColor, - resizeToAvoidBottomInset: true, - appBar: WalletAppBar( - address: address, - titleBuilder: (username) => username == null - ? 'seeAWallet'.tr() - : 'memberAccountOf'.tr(args: [username]), - ), - bottomNavigationBar: const GeckoBottomAppBar(), - body: SafeArea( - child: LayoutBuilder( - builder: (context, constraints) { - return SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints(minHeight: constraints.maxHeight), - // On divise le contenu en deux parties afin de pouvoir utiliser mainAxisAlignment.spaceBetween - // et ainsi faire remonter le bouton de transfert en bas sur grand écran. - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: <Widget>[ - // Partie haute - Column( - children: [ - WalletHeader(address: address), - ScaledSizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + return FutureBuilder<WalletHeaderData>( + future: _headerDataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Scaffold( + appBar: AppBar(title: Text(username == null ? 'seeAWallet'.tr() : 'memberAccountOf'.tr(args: [username ?? '']))), + body: const Center(child: CircularProgressIndicator()), + ); + } + + if (snapshot.hasError || !snapshot.hasData) { + return Scaffold( + appBar: AppBar(title: Text(username == null ? 'seeAWallet'.tr() : 'memberAccountOf'.tr(args: [username ?? '']))), + body: Center(child: Text('errorLoadingWalletData'.tr())), + ); + } + + final walletData = snapshot.data!; + + return Scaffold( + resizeToAvoidBottomInset: true, + appBar: WalletAppBar( + address: address, + currentBalance: walletData.balance, + titleBuilder: (uname) => uname == null ? 'seeAWallet'.tr() : 'memberAccountOf'.tr(args: [uname]), + ), + bottomNavigationBar: const GeckoBottomAppBar(), + body: SafeArea( + child: LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints(minHeight: constraints.maxHeight), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: <Widget>[ + Column( children: [ - _buildActionButton( - context: context, - key: keyViewActivity, - icon: 'assets/walletOptions/clock.png', - label: "displayNActivity".tr(), - onTap: () => Navigator.push( - context, - PageNoTransit( - builder: (context) => - ActivityScreen(address: address), + WalletHeader(address: address), + ScaledSizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + _buildActionButton( + context: context, + key: keyViewActivity, + icon: 'assets/walletOptions/clock.png', + label: "displayNActivity".tr(), + onTap: () => Navigator.push( + context, + PageNoTransit( + builder: (context) => ActivityScreen(address: address), + ), + ), ), - ), - ), - Consumer<SubstrateSdk>( - builder: (context, sub, _) { - return FutureBuilder( - future: sub.certState(address), - builder: (context, - AsyncSnapshot<CertState> snapshot) { - if (!snapshot.hasData) { - return const SizedBox.shrink(); - } - final certState = snapshot.data!; - return Visibility( - visible: - certState.status != CertStatus.none, - child: CertStateWidget( - certState: certState, - address: address, - ), + Consumer<SubstrateSdk>( + builder: (context, sub, _) { + return FutureBuilder( + future: sub.certState(address), + builder: (context, AsyncSnapshot<CertState> snapshot) { + if (!snapshot.hasData) return const SizedBox.shrink(); + final certState = snapshot.data!; + return Visibility( + visible: certState.status != CertStatus.none, + child: CertStateWidget( + certState: certState, + address: address, + ), + ); + }, ); }, - ); - }, - ), - _buildActionButton( - context: context, - key: keyCopyAddress, - icon: 'assets/copy_key.png', - label: "copyAddress".tr(), - onTap: () { - Clipboard.setData(ClipboardData(text: address)); - snackCopyKey(context); - }, + ), + _buildActionButton( + context: context, + key: keyCopyAddress, + icon: 'assets/copy_key.png', + label: "copyAddress".tr(), + onTap: () { + Clipboard.setData(ClipboardData(text: address)); + snackCopyKey(context); + }, + ), + ], ), ], ), + Column( + children: [ + _buildTransferButton(context), + ScaledSizedBox(height: isTall ? 40 : 7), + ], + ), ], ), - // Partie basse - Column( - children: [ - _buildTransferButton(context), - ScaledSizedBox(height: isTall ? 40 : 7), - ], - ), - ], - ), - ), - ); - }, - ), - ), + ), + ); + }, + ), + ), + ); + }, ); } @@ -161,7 +197,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { height: scaleSize(buttonSize), width: scaleSize(buttonSize), decoration: BoxDecoration( - color: yellowC, + color: context.colorScheme.secondary, shape: BoxShape.circle, boxShadow: [ BoxShadow( @@ -179,7 +215,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { onTap: onTap, child: Padding( padding: EdgeInsets.all(scaleSize(15)), - child: Image.asset(icon, color: Colors.black87), + child: Image.asset(icon, color: context.colorScheme.onSurface), ), ), ), @@ -205,7 +241,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { height: scaleSize(buttonSize + 5), width: scaleSize(buttonSize + 5), decoration: BoxDecoration( - color: orangeC, + color: context.colorScheme.primary, shape: BoxShape.circle, boxShadow: [ BoxShadow( @@ -226,9 +262,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { child: InkWell( key: keyPay, borderRadius: BorderRadius.circular((buttonSize + 5) / 2), - onTap: Durt.i.isConnected - ? () => _handleTransfer(context) - : null, + onTap: Durt.i.isConnected ? () => _handleTransfer(context) : null, child: Padding( padding: EdgeInsets.all(scaleSize(15)), child: Image.asset( @@ -246,7 +280,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodySmall?.copyWith( fontWeight: FontWeight.w500, - color: Durt.i.isConnected ? Colors.black87 : Colors.grey[500], + color: Durt.i.isConnected ? context.colorScheme.onSurface : Colors.grey[500], ), ), ], @@ -255,8 +289,7 @@ class _WalletViewScreenState extends State<WalletViewScreen> { } Future<void> _handleTransfer(BuildContext context) async { - final myWalletProvider = - Provider.of<MyWalletsProvider>(context, listen: false); + final myWalletProvider = Provider.of<MyWalletsProvider>(context, listen: false); final defaultWallet = myWalletProvider.getDefaultWallet(); if (myWalletProvider.pinCode == '') { diff --git a/lib/widgets/balance.dart b/lib/widgets/balance.dart index 63b14b25ca81b57dc4121751ac67d296cb8f9fb1..9ea290ffd5d2ac2163427dbb2b20df3b4173f4b1 100644 --- a/lib/widgets/balance.dart +++ b/lib/widgets/balance.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/wallet_balance.dart'; import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/wallet_options.dart'; @@ -6,28 +7,29 @@ import 'package:gecko/widgets/balance_display.dart'; import 'package:provider/provider.dart'; class Balance extends StatelessWidget { - const Balance({super.key, required this.address, required this.size, this.color = Colors.black}); + const Balance({super.key, required this.address, required this.size, this.color}); final String address; final double size; - final Color color; + final Color? color; @override Widget build(BuildContext context) { final walletOptions = Provider.of<WalletOptionsProvider>(context, listen: false); + final finalColor = color ?? context.colorScheme.onSecondaryContainer; return Consumer<SubstrateSdk>(builder: (context, sdk, _) { return FutureBuilder( future: sdk.getBalance(address), builder: (BuildContext context, AsyncSnapshot<WalletBalance> globalBalance) { if (globalBalance.connectionState != ConnectionState.done || globalBalance.hasError || !globalBalance.hasData) { if (walletOptions.balanceCache[address] != null && walletOptions.balanceCache[address] != -1) { - return BalanceDisplay(value: walletOptions.balanceCache[address]!, size: size, color: color); + return BalanceDisplay(value: walletOptions.balanceCache[address]!, size: size, color: finalColor); } else { return const SizedBox.shrink(); } } walletOptions.balanceCache[address] = globalBalance.data!.transferableBalance; if (walletOptions.balanceCache[address] != -1) { - return BalanceDisplay(value: walletOptions.balanceCache[address]!, size: size, color: color); + return BalanceDisplay(value: walletOptions.balanceCache[address]!, size: size, color: finalColor); } else { return const Text(''); } diff --git a/lib/widgets/balance_display.dart b/lib/widgets/balance_display.dart index 5d39b4578046e45d5f0d999afdb22cbcf03f5989..60629e7ea5b2a5bdf4c4ba3d2f8fd528b7b96b0b 100644 --- a/lib/widgets/balance_display.dart +++ b/lib/widgets/balance_display.dart @@ -22,20 +22,100 @@ class BalanceDisplay extends StatelessWidget { return double.parse(result); } + String _toSuperscript(String numberStr) { + const Map<String, String> superscriptMap = { + '0': '⁰', + '1': '¹', + '2': '²', + '3': '³', + '4': '⁴', + '5': '⁵', + '6': '⁶', + '7': '⁷', + '8': '⁸', + '9': '⁹', + '-': '⁻', + }; + return numberStr.split('').map((char) => superscriptMap[char] ?? char).join(''); + } + + // Helper for scientific notation (used for both small and very large numbers) + String _formatScientificNotation(double value) { + String expStr = value.toStringAsExponential(2); + int eIndex = expStr.indexOf('e'); + if (eIndex != -1) { + String mantissa = expStr.substring(0, eIndex); + String exponentValue = expStr.substring(eIndex + 1); + if (exponentValue.startsWith('+')) { + exponentValue = exponentValue.substring(1); + } + return '$mantissa×10${_toSuperscript(exponentValue)}'; + } else { + // Fallback, though toStringAsExponential should always produce 'e' for non-zero finite numbers. + return _removeDecimalZero(value).toString(); + } + } + + // Helper to format a value into Billions, Millions, direct, or very large scientific. + // Returns a map containing the final string value and the prefix (M or B). + Map<String, String> _getStandardFormattedParts(double valueToFormat) { + String finalNumericValue; + String prefix = ""; + + final double absValue = valueToFormat.abs(); + + if (absValue >= 1.0e12) { + // 1000 Billions or more -> scientific + finalNumericValue = _formatScientificNotation(valueToFormat); + // prefix remains "" + } else { + // For B, M, direct, we operate on the value after _removeDecimalZero + final double displayValue = _removeDecimalZero(valueToFormat); + final double absDisplayValue = displayValue.abs(); + + if (absDisplayValue >= 1000000000) { + // Billions + finalNumericValue = (displayValue / 1000000000).toStringAsFixed(2); + prefix = "B"; + } else if (absDisplayValue >= 1000000) { + // Millions + finalNumericValue = (displayValue / 1000000).toStringAsFixed(2); + prefix = "M"; + } else { + // Direct + finalNumericValue = displayValue.toString(); + // prefix remains "" + } + } + return {'value': finalNumericValue, 'prefix': prefix}; + } + @override Widget build(BuildContext context) { final isUdUnit = configBox.get('isUdUnit') ?? false; - final unitRatio = isUdUnit ? 1 : 100; - final valueRatio = _removeDecimalZero((value / balanceRatio) / unitRatio); - final absValueRatio = valueRatio.abs(); + final double rawValueInMainUnit = value / balanceRatio; late String finalValue; - if (absValueRatio >= 1000000000) { - finalValue = '${(valueRatio / 1000000000).toStringAsFixed(2)}B'; - } else if (absValueRatio >= 1000000) { - finalValue = '${(valueRatio / 1000000).toStringAsFixed(2)}M'; + String displayPrefix = ""; + + if (isUdUnit) { + final double absRawValueInDU = rawValueInMainUnit.abs(); + if (absRawValueInDU > 0 && absRawValueInDU < 0.01) { + // Special case for small DU values + finalValue = _formatScientificNotation(rawValueInMainUnit); + // displayPrefix remains "", as scientific notation doesn't use M/B prefixes here + } else { + // Standard DU formatting (includes large scientific, B, M, or direct) + Map<String, String> parts = _getStandardFormattedParts(rawValueInMainUnit); + finalValue = parts['value']!; + displayPrefix = parts['prefix']!; + } } else { - finalValue = valueRatio.toString(); + // Not isUdUnit: displaying in a subunit + final double valueInSubUnit = rawValueInMainUnit / 100.0; + Map<String, String> parts = _getStandardFormattedParts(valueInSubUnit); + finalValue = parts['value']!; + displayPrefix = parts['prefix']!; } return Row( @@ -46,7 +126,12 @@ class BalanceDisplay extends StatelessWidget { style: scaledTextStyle(fontSize: size, color: color, fontWeight: fontWeight), ), ScaledSizedBox(width: 5), - UdUnitDisplay(size: scaleSize(size), color: color, fontWeight: fontWeight), + UdUnitDisplay( + size: scaleSize(size), + color: color, + fontWeight: fontWeight, + valuePrefix: displayPrefix, + ), ], ); } diff --git a/lib/widgets/bottom_app_bar.dart b/lib/widgets/bottom_app_bar.dart index 7a3c3fcfd715b881dc3677eadc2664a72d4b4e45..df2830a8c9cdb3554561e90899238f0261b56718 100644 --- a/lib/widgets/bottom_app_bar.dart +++ b/lib/widgets/bottom_app_bar.dart @@ -1,6 +1,7 @@ // ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -27,7 +28,7 @@ class GeckoBottomAppBar extends StatelessWidget { visible: showBottomBar, child: Container( decoration: BoxDecoration( - color: const Color(0xFFFFFBF2), + color: context.colorScheme.tertiary, boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.08), @@ -92,7 +93,7 @@ class GeckoBottomAppBar extends StatelessWidget { bool isDisabled = false, required VoidCallback? onTap, }) { - final color = isSelected ? orangeC : const Color.fromARGB(255, 80, 69, 61); + final color = isSelected ? homeContext.colorScheme.onSurface.withValues(alpha: 0.8) : homeContext.colorScheme.onSecondaryContainer.withValues(alpha: 0.8); final size = scaleSize(34); return Material( @@ -105,7 +106,7 @@ class GeckoBottomAppBar extends StatelessWidget { padding: EdgeInsets.all(scaleSize(12)), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: isSelected ? yellowC.withValues(alpha: 0.5) : Colors.transparent, + color: isSelected ? homeContext.colorScheme.secondary.withValues(alpha: 0.5) : Colors.transparent, ), child: icon != null ? Icon( diff --git a/lib/widgets/bubble_speak.dart b/lib/widgets/bubble_speak.dart index 140aa955a947e3e8805f6406e60db3b5661150f7..53dccf2626b6459fd7b8910e0af1841d302a2aa4 100644 --- a/lib/widgets/bubble_speak.dart +++ b/lib/widgets/bubble_speak.dart @@ -1,5 +1,6 @@ import 'package:bubble/bubble.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -22,11 +23,11 @@ class BubbleSpeak extends StatelessWidget { return Bubble( padding: long == null ? BubbleEdges.all(isTall ? 18 : 12) : BubbleEdges.symmetric(horizontal: long, vertical: 30), elevation: 5, - color: backgroundColor, + color: context.colorScheme.surfaceContainer, child: Text( text, key: textKey, - style: scaledTextStyle(color: Colors.black, fontSize: isTall ? fontSize : fontSize * 0.9, fontWeight: FontWeight.w400), + style: scaledTextStyle(color: context.colorScheme.onSecondaryContainer, fontSize: isTall ? fontSize : fontSize * 0.9, fontWeight: FontWeight.w400), ), ); } @@ -57,7 +58,7 @@ class BubbleSpeakWithTail extends StatelessWidget { left: 15, bottom: -scaleSize(28), child: Image( - image: const AssetImage('assets/home/bout_de_bulle.png'), + image: AssetImage(homeContext.isDarkTheme ? 'assets/home/bout_de_bulle_dark.png' : 'assets/home/bout_de_bulle.png'), height: scaleSize(30), ), ), diff --git a/lib/widgets/buttons/add_new_derivation_button.dart b/lib/widgets/buttons/add_new_derivation_button.dart index bec9623e11f874a6439c4f3bcc57197e9b2f2999..c46f8d79a707f1c3e5075fb8de9d61f3bb004388 100644 --- a/lib/widgets/buttons/add_new_derivation_button.dart +++ b/lib/widgets/buttons/add_new_derivation_button.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/my_wallets.dart'; @@ -46,7 +46,7 @@ class AddNewDerivationButton extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - color: floattingYellow, + color: context.colorScheme.surfaceTint, borderRadius: BorderRadius.circular(12), ), child: Center( @@ -54,8 +54,8 @@ class AddNewDerivationButton extends StatelessWidget { ? ScaledSizedBox( height: 50, width: 50, - child: const CircularProgressIndicator( - color: orangeC, + child: CircularProgressIndicator( + color: context.colorScheme.primary, strokeWidth: 6, ), ) diff --git a/lib/widgets/buttons/chest_options_buttons.dart b/lib/widgets/buttons/chest_options_buttons.dart index d3e9941239832c17f57de90090342fd3d36c6d26..8282e65f7d1fbdc78bbefd93d891426f61ec094b 100644 --- a/lib/widgets/buttons/chest_options_buttons.dart +++ b/lib/widgets/buttons/chest_options_buttons.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/screens/myWallets/chest_options.dart'; @@ -26,13 +26,13 @@ class ChestOptionsButtons extends StatelessWidget { ), style: ElevatedButton.styleFrom( foregroundColor: Colors.black, - backgroundColor: floattingYellow, + backgroundColor: context.colorScheme.surfaceTint, elevation: 2, padding: const EdgeInsets.symmetric(horizontal: 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: floattingYellow.withValues(alpha: 0.3), + shadowColor: context.colorScheme.surfaceTint.withValues(alpha: 0.3), ), onPressed: () => Navigator.push( context, @@ -95,7 +95,7 @@ class ChestOptionsButtons extends StatelessWidget { // child: Text('changeChest'.tr(), // style: const scaledTextStyle( // fontSize: 19, - // color: Colors.grey, //orangeC + // color: Colors.grey, //context.colorScheme.primary // fontWeight: FontWeight.w500))), // ), // ), diff --git a/lib/widgets/buttons/home_buttons.dart b/lib/widgets/buttons/home_buttons.dart index 85f54eeddd32fd0d0927ca24fc69d9c4a96ed503..be6600ce300ab1d6163d73d749823f59c8e12f8a 100644 --- a/lib/widgets/buttons/home_buttons.dart +++ b/lib/widgets/buttons/home_buttons.dart @@ -3,6 +3,7 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -48,7 +49,7 @@ class HomeButtons extends StatelessWidget { ), child: ClipOval( child: Material( - color: orangeC, + color: context.colorScheme.primary, child: InkWell( splashColor: Colors.white.withValues(alpha: 0.2), highlightColor: Colors.white.withValues(alpha: 0.1), @@ -112,7 +113,7 @@ class HomeButtons extends StatelessWidget { child: ClipOval( key: keyOpenWalletsHomme, child: Material( - color: homeProvider.isWalletBoxInit ? orangeC : Colors.grey[500], // button color + color: homeProvider.isWalletBoxInit ? context.colorScheme.primary : Colors.grey[500], // button color child: InkWell( onTap: !homeProvider.isWalletBoxInit ? null @@ -168,7 +169,7 @@ class HomeButtons extends StatelessWidget { ), child: ClipOval( child: Material( - color: orangeC, // button color + color: context.colorScheme.primary, // button color child: InkWell( child: Padding( padding: EdgeInsets.all(scaleSize(14)), child: Image(image: const AssetImage('assets/home/qrcode.png'), height: scaleSize(62))), diff --git a/lib/widgets/buttons/manage_membership_button.dart b/lib/widgets/buttons/manage_membership_button.dart index 576ca7f802d8fd3f3cb22fa40bbff69fab4ddc89..8c8298f48dd1921c1bfe70aad717da66b5160d2f 100644 --- a/lib/widgets/buttons/manage_membership_button.dart +++ b/lib/widgets/buttons/manage_membership_button.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/wallet_options.dart'; import 'package:gecko/screens/myWallets/manage_membership.dart'; @@ -33,7 +34,7 @@ class ManageMembershipButton extends StatelessWidget { 'manageMembership'.tr(), style: scaledTextStyle( fontSize: 16, - color: Colors.black87, + color: context.colorScheme.onSurface, ), ), ), diff --git a/lib/widgets/cert_tile.dart b/lib/widgets/cert_tile.dart index 144047d1bb79377f12f0b13f344dd7470ba097e2..37ee95081de65dfbf9b762d63da80ed866444192 100644 --- a/lib/widgets/cert_tile.dart +++ b/lib/widgets/cert_tile.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -32,14 +33,17 @@ class CertTile extends StatelessWidget { padding: const EdgeInsets.only(bottom: 2), child: Text( repository['name'], - style: scaledTextStyle(fontSize: 15), + style: scaledTextStyle( + fontSize: 15, + color: context.colorScheme.onSecondaryContainer, + ), ), ), subtitle: RichText( text: TextSpan( style: scaledTextStyle( fontSize: 14, - color: Colors.grey[700], + color: homeContext.colorScheme.onSurfaceVariant, ), children: <TextSpan>[ TextSpan( diff --git a/lib/widgets/certifications.dart b/lib/widgets/certifications.dart index 2fddd2d4c47a2b85c18b97dc1595d19e05b8a989..5c344fd6291c1c6ae5de803f4e83061b95f3d2da 100644 --- a/lib/widgets/certifications.dart +++ b/lib/widgets/certifications.dart @@ -4,10 +4,10 @@ import 'package:gecko/providers/substrate_sdk.dart'; import 'package:provider/provider.dart'; class Certifications extends StatefulWidget { - const Certifications({super.key, required this.address, required this.size, this.color = Colors.black}); + const Certifications({super.key, required this.address, required this.size, this.color}); final String address; final double size; - final Color color; + final Color? color; @override State<Certifications> createState() => _CertificationsState(); @@ -58,15 +58,16 @@ class _CertificationsState extends State<Certifications> { } Widget _buildContent(int receivedCount, int sentCount) { + final finalColor = widget.color ?? Theme.of(context).colorScheme.onSecondaryContainer; return Row( children: [ - Image.asset('assets/medal.png', color: widget.color, height: scaleSize(18)), + Image.asset('assets/medal.png', color: finalColor, height: scaleSize(18)), ScaledSizedBox(width: 1), - Text(receivedCount.toString(), style: scaledTextStyle(fontSize: widget.size, color: widget.color)), + Text(receivedCount.toString(), style: scaledTextStyle(fontSize: widget.size, color: finalColor)), ScaledSizedBox(width: 5), Text( "($sentCount)", - style: scaledTextStyle(fontSize: widget.size * 0.7, color: widget.color), + style: scaledTextStyle(fontSize: widget.size * 0.7, color: finalColor), ) ], ); diff --git a/lib/widgets/certify/cert_state.dart b/lib/widgets/certify/cert_state.dart index d93caeee23411ec3243d9155ee6cc16c1835f28e..cf2b3b355ccdfb122c6dbadfa920d90d6e9c46ea 100644 --- a/lib/widgets/certify/cert_state.dart +++ b/lib/widgets/certify/cert_state.dart @@ -31,6 +31,9 @@ class CertStateWidget extends StatelessWidget { case CertStatus.emptyWallet: label = 'emptyWalletCannotBeCertified'.tr(); break; + case CertStatus.revoked: + label = 'revokedAccountCannotBeCertified'.tr(); + break; case CertStatus.none: return const SizedBox.shrink(); } @@ -68,6 +71,7 @@ enum CertStatus { mustWaitBeforeCert, mustConfirmIdentity, emptyWallet, + revoked, } class CertState { diff --git a/lib/widgets/certify/certify_button.dart b/lib/widgets/certify/certify_button.dart index 195348e95a6c05756a0560ba9ddc75a4d8f812e7..7047197a0043de9ff4a8b2f15acc0caac6db3434 100644 --- a/lib/widgets/certify/certify_button.dart +++ b/lib/widgets/certify/certify_button.dart @@ -3,7 +3,8 @@ import 'package:durt2/durt2.dart' show Durt; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/exceptions.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/duniter_indexer.dart'; @@ -37,7 +38,7 @@ class CertifyButton extends StatelessWidget { color: const Color(0xffFFD58D), child: InkWell( key: keyCertify, - splashColor: orangeC, + splashColor: context.colorScheme.primary, onTap: () async { final walletName = duniterIndexer.walletNameIndexer[address]; final message = walletName != null @@ -76,20 +77,28 @@ class CertifyButton extends StatelessWidget { Provider.of<WalletsProfilesProvider>(context, listen: false); final acc = sub.getCurrentKeyPair(); - final transactionId = await sub.certify( - acc.address!, - walletViewProvider.address, - myWalletProvider.pinCode, - ); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return TransactionInProgress( - transactionId: transactionId, - transType: 'cert', - ); - }), - ); + try { + final transactionId = await sub.certify( + acc.address!, + walletViewProvider.address, + myWalletProvider.pinCode, + ); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return TransactionInProgress( + transactionId: transactionId, + transType: 'cert', + ); + }), + ); + } catch (e) { + if (e is NotMemberException) { + showConfirmationDialog(context: context, type: ConfirmationDialogType.error, message: e.toString()); + } else if (e is CantBeCertException) { + showConfirmationDialog(context: context, type: ConfirmationDialogType.error, message: e.toString()); + } + } }, child: const Padding( padding: EdgeInsets.only(bottom: 0), diff --git a/lib/widgets/certify/wait_to_cert.dart b/lib/widgets/certify/wait_to_cert.dart index 270ecdb7694a9888d5832660a74d104f525ac900..365dc8ed1f411d74efb9e6697ce845842a2b0b5f 100644 --- a/lib/widgets/certify/wait_to_cert.dart +++ b/lib/widgets/certify/wait_to_cert.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/screens/wallet_view.dart' show buttonSize, buttonFontSize; @@ -19,7 +19,7 @@ class WaitToCertWidget extends StatelessWidget { opacity: 0.4, child: Image( image: const AssetImage('assets/gecko_certify.png'), - color: backgroundColor, + color: context.colorScheme.surface, colorBlendMode: BlendMode.saturation, ), ), diff --git a/lib/widgets/certs_list.dart b/lib/widgets/certs_list.dart index 9ab2ac695dc17ef166ee10ed21036c58210cd7a0..0348bd496445d78348dc01877a73643e67aa1f8c 100644 --- a/lib/widgets/certs_list.dart +++ b/lib/widgets/certs_list.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/queries_indexer.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -96,7 +97,7 @@ class CertsList extends StatelessWidget { return SizedBox( height: windowHeight, child: RefreshIndicator( - color: orangeC, + color: context.colorScheme.primary, onRefresh: () async => refetch!.call(), child: ListView( key: keyListTransactions, diff --git a/lib/widgets/commons/build_progress_bar.dart b/lib/widgets/commons/build_progress_bar.dart index 14fe40d72b1983dbc54e27c7df66b1a0bef97356..cda5b36debcc1ef78a33f20d61ce2243e42817cc 100644 --- a/lib/widgets/commons/build_progress_bar.dart +++ b/lib/widgets/commons/build_progress_bar.dart @@ -1,6 +1,6 @@ import 'package:dots_indicator/dots_indicator.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; class BuildProgressBar extends StatelessWidget { @@ -21,7 +21,7 @@ class BuildProgressBar extends StatelessWidget { activeSize: Size.square(scaleSize(10)), spacing: EdgeInsets.symmetric(horizontal: scaleSize(10)), color: Colors.grey[400]!, - activeColor: orangeC, + activeColor: context.colorScheme.primary, ), ); } diff --git a/lib/widgets/commons/build_text.dart b/lib/widgets/commons/build_text.dart index 61154c4827ddec01626a433c678f73471d626966..f5a98440cdce6e1f893e992a16f77d17ab8a786d 100644 --- a/lib/widgets/commons/build_text.dart +++ b/lib/widgets/commons/build_text.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -19,24 +20,17 @@ class BuildText extends StatelessWidget { Widget build(BuildContext context) { final double ratio = isTall ? 1 : 0.95; final mdStyle = MarkdownStyleSheet( - p: scaledTextStyle( - fontSize: size * ratio, color: Colors.black, letterSpacing: 0.3), + p: scaledTextStyle(fontSize: size * ratio, color: context.colorScheme.onSecondaryContainer, letterSpacing: 0.3), textAlign: WrapAlignment.spaceBetween, ); return Container( padding: const EdgeInsets.all(12), width: scaleSize(350 * ratio), - decoration: BoxDecoration( - color: Colors.white, border: Border.all(color: Colors.grey[900]!)), + decoration: BoxDecoration(color: context.colorScheme.surfaceContainer, border: Border.all(color: Colors.grey[900]!)), child: isMd ? MarkdownBody(data: text, styleSheet: mdStyle) - : Text(text, - textAlign: TextAlign.justify, - style: scaledTextStyle( - fontSize: size * ratio, - color: Colors.black, - letterSpacing: 0.3)), + : Text(text, textAlign: TextAlign.justify, style: scaledTextStyle(fontSize: size * ratio, color: context.colorScheme.onSecondaryContainer, letterSpacing: 0.3)), ); } } diff --git a/lib/widgets/commons/common_elements.dart b/lib/widgets/commons/common_elements.dart index 6108530859bd3d79a05827c4aac38116fa41f4e6..d5170949b06101c31098d4a37946fb6555931940 100644 --- a/lib/widgets/commons/common_elements.dart +++ b/lib/widgets/commons/common_elements.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -10,7 +10,7 @@ Future<void> infoPopup(BuildContext context, String title) async { barrierDismissible: true, builder: (BuildContext context) { return AlertDialog( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, content: Text( title, textAlign: TextAlign.center, diff --git a/lib/widgets/commons/confirmation_dialog.dart b/lib/widgets/commons/confirmation_dialog.dart index 022af3e67bf382f3277e937ec64b55cb439a66d6..b432e62184c6327a6664b61ea944745256f0ab07 100644 --- a/lib/widgets/commons/confirmation_dialog.dart +++ b/lib/widgets/commons/confirmation_dialog.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -18,17 +19,33 @@ extension ConfirmationDialogTypeExtension on ConfirmationDialogType { ConfirmationDialogType.info => Icons.info_rounded, ConfirmationDialogType.warning => Icons.warning_rounded, ConfirmationDialogType.success => Icons.task_alt_rounded, - ConfirmationDialogType.error => Icons.error_rounded, + ConfirmationDialogType.error => Icons.cancel_rounded, ConfirmationDialogType.question => Icons.help_rounded, }; Color get iconColor => switch (this) { - ConfirmationDialogType.info => orangeC, + ConfirmationDialogType.info => homeContext.colorScheme.primary, ConfirmationDialogType.warning => const Color(0xFFFF9800), ConfirmationDialogType.success => const Color(0xFF4CAF50), ConfirmationDialogType.error => const Color(0xFFF44336), ConfirmationDialogType.question => const Color(0xFF673AB7), }; + + String get title => switch (this) { + ConfirmationDialogType.info => 'info'.tr(), + ConfirmationDialogType.warning => 'warning'.tr(), + ConfirmationDialogType.success => 'success'.tr(), + ConfirmationDialogType.error => 'error'.tr(), + ConfirmationDialogType.question => 'question'.tr(), + }; + + String get confirmText => switch (this) { + ConfirmationDialogType.info => 'confirm'.tr(), + ConfirmationDialogType.warning => 'confirm'.tr(), + ConfirmationDialogType.success => 'confirm'.tr(), + ConfirmationDialogType.error => 'close'.tr(), + ConfirmationDialogType.question => 'confirm'.tr(), + }; } Future<bool> showConfirmationDialog({ @@ -44,7 +61,8 @@ Future<bool> showConfirmationDialog({ }) async { final IconData iconToShow = customIcon ?? type.icon; final Color iconColorToShow = customIconColor ?? type.iconColor; - final String dialogTitle = title ?? 'confirmationTitle'.tr(); + final String dialogTitle = title ?? type.title; + final String confirmTextToShow = confirmText ?? type.confirmText; final result = await showDialog<bool>( context: context, @@ -55,11 +73,10 @@ Future<bool> showConfirmationDialog({ borderRadius: BorderRadius.circular(24), ), elevation: 0, - backgroundColor: Colors.transparent, child: Container( padding: EdgeInsets.all(20), decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surface, borderRadius: BorderRadius.circular(24), boxShadow: [ BoxShadow( @@ -117,26 +134,28 @@ Future<bool> showConfirmationDialog({ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Expanded( - child: TextButton( - onPressed: () => Navigator.of(context).pop(false), - style: TextButton.styleFrom( - padding: EdgeInsets.symmetric(vertical: 12), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), + if (type != ConfirmationDialogType.error) ...[ + Expanded( + child: TextButton( + onPressed: () => Navigator.of(context).pop(false), + style: TextButton.styleFrom( + padding: EdgeInsets.symmetric(vertical: 12), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), ), - ), - child: Text( - cancelText ?? 'cancel'.tr(), - style: scaledTextStyle( - fontSize: 15, - color: Colors.grey[600], - fontWeight: FontWeight.w600, + child: Text( + cancelText ?? 'cancel'.tr(), + style: scaledTextStyle( + fontSize: 15, + color: Colors.grey[600], + fontWeight: FontWeight.w600, + ), ), ), ), - ), - SizedBox(width: 16), + SizedBox(width: 16), + ], Expanded( child: ElevatedButton( onPressed: () => Navigator.of(context).pop(true), @@ -150,7 +169,7 @@ Future<bool> showConfirmationDialog({ ), ), child: Text( - confirmText ?? 'confirm'.tr(), + confirmTextToShow, style: scaledTextStyle( fontSize: 15, fontWeight: FontWeight.w600, diff --git a/lib/widgets/commons/loading.dart b/lib/widgets/commons/loading.dart index cd36878889897b092820359201d1a3851aa68ca7..ea5b841d9f12c6e4b5d386809b676e3ec1bce117 100644 --- a/lib/widgets/commons/loading.dart +++ b/lib/widgets/commons/loading.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; class Loading extends StatelessWidget { @@ -18,7 +18,7 @@ class Loading extends StatelessWidget { height: size, width: size, child: CircularProgressIndicator( - color: orangeC, + color: context.colorScheme.primary, strokeWidth: stroke, ), ); diff --git a/lib/widgets/commons/next_button.dart b/lib/widgets/commons/next_button.dart index cbc9824ef4ee1d5de9295ba9eda55708dfe19ebd..96249934a5663c1dd097c6ec7d4dd0237e3d7be3 100644 --- a/lib/widgets/commons/next_button.dart +++ b/lib/widgets/commons/next_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/widgets/commons/fader_transition.dart'; @@ -25,13 +25,13 @@ class NextButton extends StatelessWidget { key: keyGoNext, style: ElevatedButton.styleFrom( foregroundColor: Colors.white, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, elevation: 2, padding: const EdgeInsets.symmetric(vertical: 2), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: orangeC.withValues(alpha: 0.3), + shadowColor: context.colorScheme.primary.withValues(alpha: 0.3), ), onPressed: () { Navigator.push(context, FaderTransition(page: nextScreen, isFast: isFast)); diff --git a/lib/widgets/commons/top_appbar.dart b/lib/widgets/commons/top_appbar.dart index 78cde6b8a15c428c2633c8689e919c736dc17cd2..ec8286f8c4b6588c5196c346fbac1218abcde65f 100644 --- a/lib/widgets/commons/top_appbar.dart +++ b/lib/widgets/commons/top_appbar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; class GeckoAppBar extends StatelessWidget implements PreferredSizeWidget { @@ -9,11 +10,16 @@ class GeckoAppBar extends StatelessWidget implements PreferredSizeWidget { @override AppBar build(BuildContext context) { return AppBar( + backgroundColor: context.colorScheme.tertiary, toolbarHeight: scaleSize(57), titleSpacing: 10, title: Text( text, - style: scaledTextStyle(fontWeight: FontWeight.w600, fontSize: 17), + style: scaledTextStyle( + fontWeight: FontWeight.w600, + fontSize: 17, + color: context.colorScheme.onSecondaryContainer, + ), ), ); } diff --git a/lib/widgets/commons/wallet_app_bar.dart b/lib/widgets/commons/wallet_app_bar.dart index 15a1ac04f65ab5f3814f7bdc3e9c589d01fa4254..5d1f6664619be0759a8d7dd6bed846aeccd3dd2e 100644 --- a/lib/widgets/commons/wallet_app_bar.dart +++ b/lib/widgets/commons/wallet_app_bar.dart @@ -1,11 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/duniter_indexer.dart'; import 'package:gecko/providers/substrate_sdk.dart'; -import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/providers/wallet_options.dart'; +import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/screens/qrcode_fullscreen.dart'; import 'package:provider/provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; @@ -14,26 +15,28 @@ class WalletAppBar extends StatelessWidget implements PreferredSizeWidget { const WalletAppBar({ super.key, required this.address, + required this.currentBalance, this.title, this.titleBuilder, }) : assert(title != null || titleBuilder != null); final String address; + final BigInt currentBalance; final String? title; final String Function(String? username)? titleBuilder; @override Widget build(BuildContext context) { final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); - final walletOptions = Provider.of<WalletOptionsProvider>(context); + final walletOptions = Provider.of<WalletOptionsProvider>(context, listen: false); Provider.of<SubstrateSdk>(context); //To refresh header color on block changes - // Récupération du solde - final balance = walletOptions.balanceCache[address] ?? 0; - final isEmptyWallet = balance == 0; + final balance = walletOptions.balanceCache[address] == null ? currentBalance : BigInt.from(walletOptions.balanceCache[address] ?? 0); + + final isEmptyWallet = balance == BigInt.zero; return AppBar( - backgroundColor: isEmptyWallet ? Colors.grey[300] : headerColor, + backgroundColor: isEmptyWallet ? context.colorScheme.error : context.colorScheme.tertiary, titleSpacing: 10, title: Text( title ?? titleBuilder!(duniterIndexer.walletNameIndexer[address]), @@ -53,6 +56,7 @@ class WalletAppBar extends StatelessWidget implements PreferredSizeWidget { icon: Icon( profile.isContact(address) ? Icons.add_reaction_rounded : Icons.add_reaction_outlined, size: scaleSize(27), + color: context.colorScheme.onSecondaryContainer, ), ); }), @@ -69,6 +73,12 @@ class WalletAppBar extends StatelessWidget implements PreferredSizeWidget { data: address, version: QrVersions.auto, size: scaleSize(45), + dataModuleStyle: QrDataModuleStyle( + color: context.colorScheme.onSecondaryContainer, + ), + eyeStyle: QrEyeStyle( + color: context.colorScheme.onSecondaryContainer, + ), ), ), ), diff --git a/lib/widgets/contacts_list.dart b/lib/widgets/contacts_list.dart index d3478d29fa8789b403c5775e034707ebb8823733..a8caa33db2aaa3312ac9e72721f7c766321dc0ca 100644 --- a/lib/widgets/contacts_list.dart +++ b/lib/widgets/contacts_list.dart @@ -1,6 +1,7 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -31,7 +32,7 @@ class ContactsList extends StatelessWidget { builder: (BuildContext context) { return Container( decoration: BoxDecoration( - color: backgroundColor, + color: context.colorScheme.surface, borderRadius: const BorderRadius.vertical(top: Radius.circular(20)), ), child: Column( diff --git a/lib/widgets/drag_tule_action.dart b/lib/widgets/drag_tule_action.dart index 184abd4607c6287f09945ac8e1ca5bf602150d89..b0e604591610a683afe874346bbb507a46db58c8 100644 --- a/lib/widgets/drag_tule_action.dart +++ b/lib/widgets/drag_tule_action.dart @@ -2,6 +2,7 @@ import 'package:durt2/durt2.dart' show Durt, WalletData; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/my_wallets.dart'; @@ -33,7 +34,7 @@ class DragTuleAction extends StatelessWidget { feedback: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, shape: const CircleBorder(), padding: EdgeInsets.all(scaleSize(14)), ), diff --git a/lib/widgets/drag_wallets_info.dart b/lib/widgets/drag_wallets_info.dart index e567f258e00c0e30b448ce61121f2825f5c58be6..3c513344cc79b0f85eed61698cb33c7ddc367b76 100644 --- a/lib/widgets/drag_wallets_info.dart +++ b/lib/widgets/drag_wallets_info.dart @@ -2,6 +2,7 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/duniter_indexer.dart'; @@ -30,7 +31,7 @@ class DragWalletsInfo extends StatelessWidget { ); return Container( - color: yellowC, + color: context.colorScheme.secondary, width: screenWidth, height: scaleSize(85), child: Center( diff --git a/lib/widgets/drawer.dart b/lib/widgets/drawer.dart index 0673cca41251f7a56b790f8f885e87070d2ae020..35d763415b8705782f54df209fa0f77f03eb020f 100644 --- a/lib/widgets/drawer.dart +++ b/lib/widgets/drawer.dart @@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -20,36 +21,53 @@ class MainDrawer extends StatelessWidget { @override Widget build(BuildContext context) { - final listStyle = scaledTextStyle(fontSize: 14); + final listStyle = scaledTextStyle(fontSize: 14, color: context.colorScheme.onSurface); return SizedBox( width: MediaQuery.of(context).size.width * 0.67, child: Drawer( + backgroundColor: context.colorScheme.surface, child: Column( children: <Widget>[ Expanded( child: ListView(padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( - decoration: const BoxDecoration( - color: orangeC, + decoration: BoxDecoration( + color: context.colorScheme.primary, ), child: Column(children: <Widget>[ - Image( - image: const AssetImage('assets/icon/gecko_final.png'), - height: scaleSize(118)), + Image(image: const AssetImage('assets/icon/gecko_final.png'), height: scaleSize(118)), ]), ), ScaledSizedBox(height: scaleSize(10)), - Opacity( - opacity: 0.8, - child: ListTile( - key: keyParameters, - leading: Icon(Icons.settings, size: scaleSize(25)), + ListTile( + key: keyParameters, + leading: Icon(Icons.settings, size: scaleSize(25)), + dense: !isTall, + // contentPadding: + // EdgeInsets.symmetric(horizontal: scaleSize(12)), + title: Text( + 'parameters'.tr(), + style: listStyle, + ), + onTap: () { + Navigator.pop(context); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return SettingsScreen(); + }), + ); + }, + ), + ScaledSizedBox(height: scaleSize(4)), + if (isWalletsExists) + ListTile( + key: keyContacts, + leading: Icon(Icons.contacts_rounded, size: scaleSize(25)), dense: !isTall, - // contentPadding: - // EdgeInsets.symmetric(horizontal: scaleSize(12)), title: Text( - 'parameters'.tr(), + 'contactsManagement'.tr(), style: listStyle, ), onTap: () { @@ -57,80 +75,47 @@ class MainDrawer extends StatelessWidget { Navigator.push( context, MaterialPageRoute(builder: (context) { - return SettingsScreen(); + return const ContactsScreen(); }), ); }, ), - ), - ScaledSizedBox(height: scaleSize(4)), - if (isWalletsExists) - Opacity( - opacity: 0.8, - child: ListTile( - key: keyContacts, - leading: Icon(Icons.contacts_rounded, size: scaleSize(25)), - dense: !isTall, - title: Text( - 'contactsManagement'.tr(), - style: listStyle, - ), - onTap: () { - Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const ContactsScreen(); - }), - ); - }, - ), - ), if (isWalletsExists) ScaledSizedBox(height: scaleSize(4)), if (kDebugMode) - Opacity( - opacity: 0.8, - child: ListTile( - key: keyDebugScreen, - leading: - Icon(Icons.developer_mode_rounded, size: scaleSize(25)), - dense: !isTall, - title: Text( - 'Debug screen'.tr(), - style: listStyle, - ), - onTap: () { - Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const DebugScreen(); - }), - ); - }, + ListTile( + key: keyDebugScreen, + leading: Icon(Icons.developer_mode_rounded, size: scaleSize(25)), + dense: !isTall, + title: Text( + 'Debug screen'.tr(), + style: listStyle, ), + onTap: () { + Navigator.pop(context); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return const DebugScreen(); + }), + ); + }, ), ])), Align( alignment: FractionalOffset.bottomCenter, child: InkWell( key: keyCopyAddress, - splashColor: orangeC, + splashColor: context.colorScheme.primary, child: Padding( padding: const EdgeInsets.all(15), child: Opacity( opacity: 0.8, - child: Text('Ğecko v$appVersion', - style: scaledTextStyle(fontSize: 12)), + child: Text('Ğecko v$appVersion', style: scaledTextStyle(fontSize: 12)), ), ), onTap: () { - Clipboard.setData( - ClipboardData(text: 'Ğecko v$appVersion')); - snackMessage(context, - message: - 'Le numéro de version de Ğecko a été copié dans votre presse papier', - duration: 4); + Clipboard.setData(ClipboardData(text: 'Ğecko v$appVersion')); + snackMessage(context, message: 'Le numéro de version de Ğecko a été copié dans votre presse papier', duration: 4); }), ), ScaledSizedBox(height: 15) diff --git a/lib/widgets/history_query.dart b/lib/widgets/history_query.dart index 546a52316dc2f255bed67c04dc7d091d6ac516e2..4b5cf2089d34f215086f4b7ba645f15698613113 100644 --- a/lib/widgets/history_query.dart +++ b/lib/widgets/history_query.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/queries_indexer.dart'; import 'package:gecko/models/scale_functions.dart'; @@ -88,9 +89,9 @@ class HistoryQuery extends StatelessWidget { builder: (QueryResult result, {fetchMore, refetch}) { duniterIndexer.refetch = refetch; if (result.isLoading && result.data == null) { - return const Center( + return Center( child: CircularProgressIndicator( - color: orangeC, + color: homeContext.colorScheme.primary, ), ); } @@ -135,7 +136,7 @@ class HistoryQuery extends StatelessWidget { child: Builder( builder: (context) => Expanded( child: RefreshIndicator( - color: orangeC, + color: context.colorScheme.primary, onRefresh: () async => refetch!.call(), child: ListView( key: keyListTransactions, diff --git a/lib/widgets/history_view.dart b/lib/widgets/history_view.dart index 50af7b41f4c74e6ee8c5d94afc724d4d9f79c3e1..0e400cc983b06e08f72b89d455132a38ef2c2603 100644 --- a/lib/widgets/history_view.dart +++ b/lib/widgets/history_view.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/duniter_indexer.dart'; @@ -72,7 +73,7 @@ class HistoryView extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 20), child: Text( answer['dateDelimiter'], - style: scaledTextStyle(fontSize: 19, color: orangeC, fontWeight: FontWeight.w300), + style: scaledTextStyle(fontSize: 19, color: context.colorScheme.primary, fontWeight: FontWeight.w300), ), ), TransactionTile( diff --git a/lib/widgets/idty_status.dart b/lib/widgets/idty_status.dart index bd221e0a25b5acc566b969e7f18c842d1f478e6e..31b290606164a3bd1ba724859cd1227378bfd584 100644 --- a/lib/widgets/idty_status.dart +++ b/lib/widgets/idty_status.dart @@ -1,6 +1,8 @@ import 'package:durt2/durt2.dart' show Durt, IdtyStatus, WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; +import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/widgets/commons/animated_text.dart'; @@ -8,15 +10,14 @@ import 'package:gecko/widgets/name_by_address.dart'; import 'package:provider/provider.dart'; class IdentityStatus extends StatelessWidget { - const IdentityStatus( - {super.key, required this.address, this.color = Colors.black}); + const IdentityStatus({super.key, required this.address, this.color}); final String address; - final Color color; + final Color? color; @override Widget build(BuildContext context) { - final walletData = Durt.i.walletService.walletDataBox.get(address) ?? - WalletData(address: address); + final walletData = Durt.i.walletService.walletDataBox.get(address) ?? WalletData(address: address); + final finalColor = color ?? context.colorScheme.onSecondaryContainer; return Consumer<SubstrateSdk>(builder: (context, sub, _) { return FutureBuilder( @@ -32,18 +33,9 @@ class IdentityStatus extends StatelessWidget { final resStatus = walletData.identityStatus; final nameByAddress = resStatus == IdtyStatus.validated - ? NameByAddress( - wallet: walletData, - size: 18, - color: Colors.black, - fontWeight: FontWeight.w500, - fontStyle: FontStyle.normal) + ? NameByAddress(wallet: walletData, size: 18, color: finalColor, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal) : NameByAddress( - wallet: walletData, - size: 16, - color: Colors.grey[700]!, - fontWeight: FontWeight.w500, - fontStyle: FontStyle.italic); + wallet: walletData, size: 16, color: homeContext.colorScheme.onSurfaceVariant, fontWeight: FontWeight.w500, fontStyle: FontStyle.italic); final Map<IdtyStatus, String> statusText = { IdtyStatus.none: '', @@ -59,27 +51,22 @@ class IdentityStatus extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ nameByAddress, - showText(statusText[resStatus]!, - bold: resStatus == IdtyStatus.validated, - size: scaleSize(15)), + showText(context, statusText[resStatus]!, bold: resStatus == IdtyStatus.validated, size: scaleSize(15)), ], ); }); }); } - AnimatedFadeOutIn showText(String text, - {double size = 18, bool bold = false}) { + AnimatedFadeOutIn showText(BuildContext context, String text, {double size = 18, bool bold = false}) { + final finalColor = color ?? context.colorScheme.onSecondaryContainer; return AnimatedFadeOutIn<String>( data: text, duration: const Duration(milliseconds: 150), builder: (value) => Text( value, textAlign: TextAlign.center, - style: TextStyle( - fontSize: size, - color: bold ? color : Colors.black, - fontWeight: bold ? FontWeight.w500 : FontWeight.w400), + style: TextStyle(fontSize: size, color: bold ? finalColor : finalColor, fontWeight: bold ? FontWeight.w500 : FontWeight.w400), ), ); } diff --git a/lib/widgets/name_by_address.dart b/lib/widgets/name_by_address.dart index ca2724bca0ab147a197c8a60819416b66b907562..8d2887386e39b83fbd9a10c8288e75672df529a4 100644 --- a/lib/widgets/name_by_address.dart +++ b/lib/widgets/name_by_address.dart @@ -1,6 +1,7 @@ import 'package:durt2/durt2.dart' show WalletData; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/queries_indexer.dart'; @@ -13,10 +14,9 @@ import 'package:provider/provider.dart'; import 'package:truncate/truncate.dart'; class NameByAddress extends StatelessWidget { - const NameByAddress( - {super.key, required this.wallet, this.size = 20, this.color = Colors.black, this.fontWeight = FontWeight.w400, this.fontStyle = FontStyle.normal}); + const NameByAddress({super.key, required this.wallet, this.size = 20, this.color, this.fontWeight = FontWeight.w400, this.fontStyle = FontStyle.normal}); final WalletData wallet; - final Color color; + final Color? color; final double size; final FontWeight fontWeight; final FontStyle fontStyle; @@ -24,9 +24,10 @@ class NameByAddress extends StatelessWidget { @override Widget build(BuildContext context) { final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); + final finalColor = color ?? Theme.of(context).colorScheme.onSurface; if (indexerEndpoint == '') { - return WalletName(wallet: wallet, size: size, color: color); + return WalletName(wallet: wallet, size: size, color: finalColor); } return GraphQLProvider( @@ -57,16 +58,16 @@ class NameByAddress extends StatelessWidget { g1WalletsBox.put(wallet.address, G1WalletsList(address: wallet.address, username: duniterIndexer.walletNameIndexer[wallet.address])); if (duniterIndexer.walletNameIndexer[wallet.address] == null) { - return WalletName(wallet: wallet, size: size, color: color); + return WalletName(wallet: wallet, size: size, color: finalColor); } return Text( - color == Colors.grey[700]! + finalColor == homeContext.colorScheme.onSurfaceVariant ? '(${duniterIndexer.walletNameIndexer[wallet.address]!})' : truncate(duniterIndexer.walletNameIndexer[wallet.address]!, 19), style: scaledTextStyle( fontSize: size, - color: color, + color: finalColor, fontWeight: fontWeight, fontStyle: fontStyle, ), diff --git a/lib/widgets/payment_popup.dart b/lib/widgets/payment_popup.dart index 9727898f8e96f4db0328f24dbb77469056ad50ec..2b8197f3b90c38031964dc437d03dc8731b33704 100644 --- a/lib/widgets/payment_popup.dart +++ b/lib/widgets/payment_popup.dart @@ -4,6 +4,7 @@ import 'package:durt2/durt2.dart' show Durt, WalletData; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/text_input_formaters.dart'; @@ -140,8 +141,8 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { child: Container( // On fixe la hauteur maximale du bottom sheet height: bottomSheetHeight, - decoration: const ShapeDecoration( - color: Color(0xffffeed1), + decoration: ShapeDecoration( + color: context.colorScheme.tertiary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topRight: Radius.circular(shapeSize), @@ -205,7 +206,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { alignment: Alignment.center, padding: const EdgeInsets.all(0), child: DropdownButton( - dropdownColor: const Color(0xffffeed1), + dropdownColor: context.colorScheme.tertiary, elevation: 12, key: keyDropdownWallets, value: defaultWallet, @@ -257,7 +258,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { value: wallet, key: keySelectThisWallet(wallet.address), child: Container( - color: const Color(0xffffeed1), + color: context.colorScheme.tertiary, width: scaleSize(isTall ? 315 : 310), padding: const EdgeInsets.all(10), child: Row( @@ -315,8 +316,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { onTap: () => infoFeesPopup(context), child: Row( children: [ - Icon(Icons.info_outlined, - color: orangeC, size: scaleSize(21)), + Icon(Icons.info_outlined, color: context.colorScheme.primary, size: scaleSize(21)), ScaledSizedBox(width: 5), Text( 'fees'.tr(args: [ @@ -324,7 +324,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { currencyName ]), style: scaledTextStyle( - color: orangeC, + color: context.colorScheme.primary, fontSize: 13, fontWeight: FontWeight.w500, ), @@ -396,10 +396,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { ), contentPadding: EdgeInsets.all(scaleSize(6)), ), - style: scaledTextStyle( - fontSize: 22, - color: Colors.black, - fontWeight: FontWeight.w600), + style: scaledTextStyle(fontSize: 22, color: context.colorScheme.onSurface, fontWeight: FontWeight.w600), ), ), if (walletViewProvider.isCommentVisible) @@ -461,8 +458,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { } }, maxLines: 1, - style: scaledTextStyle( - fontSize: 13, color: Colors.black87), + style: scaledTextStyle(fontSize: 13, color: context.colorScheme.onSurface), decoration: InputDecoration( hintText: 'optionalComment'.tr(), hintStyle: @@ -521,7 +517,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) { style: ElevatedButton.styleFrom( foregroundColor: Colors.white, elevation: 4, - backgroundColor: orangeC, + backgroundColor: context.colorScheme.primary, ), onPressed: canValidate ? () async { @@ -556,11 +552,11 @@ Future<void> infoFeesPopup(BuildContext context) async { barrierDismissible: true, builder: (BuildContext context) { return AlertDialog( - backgroundColor: backgroundColor, + backgroundColor: context.colorScheme.surface, content: Column( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.info_outlined, color: orangeC, size: 40), + Icon(Icons.info_outlined, color: context.colorScheme.primary, size: 40), ScaledSizedBox(height: 20), Text( 'feesExplanation'.tr(), diff --git a/lib/widgets/scan_derivations_info.dart b/lib/widgets/scan_derivations_info.dart index f4f1e80de5d3972024c55acb394b6d5caaa61c52..ccb34b20995fd581b228bdc4418a6a8f31a481d3 100644 --- a/lib/widgets/scan_derivations_info.dart +++ b/lib/widgets/scan_derivations_info.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/providers/generate_wallets.dart'; import 'package:provider/provider.dart'; @@ -40,7 +40,7 @@ class ScanDerivationsInfo extends StatelessWidget { height: 22, width: 22, child: CircularProgressIndicator( - color: orangeC, + color: context.colorScheme.primary, strokeWidth: scaleSize(3), ), ), diff --git a/lib/widgets/transaction_in_progress_tile.dart b/lib/widgets/transaction_in_progress_tile.dart index dc5f833b630de7096fe31e23307e8f5dd62dae6e..65438a6aa3d09868a3c2ac3bf5da24637d78e1e7 100644 --- a/lib/widgets/transaction_in_progress_tile.dart +++ b/lib/widgets/transaction_in_progress_tile.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/transaction_content.dart'; @@ -99,7 +100,7 @@ class _TransactionInProgressTuleState extends State<TransactionInProgressTule> { decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( - color: orangeC, + color: context.colorScheme.primary, width: 2, ), ), diff --git a/lib/widgets/transaction_tile.dart b/lib/widgets/transaction_tile.dart index 7482a229196e60bd564c8019b2715d182262a70e..722f076d6530ce2c1dbae8ddc059010f09c0a250 100644 --- a/lib/widgets/transaction_tile.dart +++ b/lib/widgets/transaction_tile.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; +import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/transaction.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -40,23 +42,12 @@ class TransactionTile extends StatelessWidget { vertical: scaleSize(4), ), decoration: BoxDecoration( - color: Colors.white, + color: context.colorScheme.surfaceContainer, borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - // Soft ambient shadow - color: Colors.black.withValues(alpha: 0.04), - blurRadius: 6, - spreadRadius: 2, - offset: const Offset(0, 2), - ), - BoxShadow( - // Sharper direct shadow - color: Colors.black.withValues(alpha: 0.08), - blurRadius: 1, - offset: const Offset(0, 1), - ), - ], + // border: Border.all( + // color: Colors.grey.withValues(alpha: 0.2), + // width: 1, + // ), ), child: ListTile( key: keyTransaction(newKey), @@ -68,7 +59,7 @@ class TransactionTile extends StatelessWidget { decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( - color: Colors.grey.withValues(alpha: 0.6), + color: context.colorScheme.onSecondaryContainer, width: 1, ), ), @@ -86,6 +77,7 @@ class TransactionTile extends StatelessWidget { fontSize: 15, fontFamily: 'Monospace', fontWeight: FontWeight.w500, + color: context.colorScheme.onSecondaryContainer, ), ), ScaledSizedBox(height: 4), @@ -93,7 +85,7 @@ class TransactionTile extends StatelessWidget { text: TextSpan( style: scaledTextStyle( fontSize: 13, - color: Colors.grey[700], + color: homeContext.colorScheme.onSurfaceVariant, ), children: <TextSpan>[ TextSpan(text: dateForm), diff --git a/lib/widgets/ud_unit_display.dart b/lib/widgets/ud_unit_display.dart index 09b0ec31538005d691c5c126b07d509fc193f7fc..60f399c472ad4175b6047d6ea5e29efe83b60e02 100644 --- a/lib/widgets/ud_unit_display.dart +++ b/lib/widgets/ud_unit_display.dart @@ -8,34 +8,67 @@ class UdUnitDisplay extends StatelessWidget { required this.size, required this.color, this.fontWeight = FontWeight.normal, + this.valuePrefix = "", }); final double size; final Color color; final FontWeight fontWeight; + final String valuePrefix; + @override Widget build(BuildContext context) { final bool isUdUnit = configBox.get('isUdUnit') ?? false; - return isUdUnit - ? Row( - mainAxisAlignment: MainAxisAlignment.end, + + Widget prefixWidget = const SizedBox.shrink(); + if (valuePrefix.isNotEmpty) { + prefixWidget = Text( + valuePrefix, + style: TextStyle( + fontSize: size, + color: color == Colors.white ? color : Colors.red, + fontWeight: fontWeight, + ), + ); + } + + if (isUdUnit) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (valuePrefix.isNotEmpty) ...[ + prefixWidget, + const SizedBox(width: 0.5), + ], + Text( + 'ud'.tr(args: ['']), + style: TextStyle(fontSize: size, color: color, fontWeight: fontWeight), + ), + const SizedBox(width: 2.0), + Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'ud'.tr(args: ['']), - style: TextStyle(fontSize: size, color: color, fontWeight: fontWeight), + currencyName, + style: TextStyle(fontSize: size * 0.65, fontWeight: fontWeight, color: color), ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - currencyName, - style: TextStyle(fontSize: size * 0.65, fontWeight: fontWeight, color: color), - ), - const SizedBox(height: 15) - ], - ) + const SizedBox(height: 15) ], ) - : Text(currencyName, style: TextStyle(fontSize: size, color: color, fontWeight: fontWeight)); + ], + ); + } else { + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (valuePrefix.isNotEmpty) ...[ + prefixWidget, + const SizedBox(width: 0.5), + ], + Text(currencyName, style: TextStyle(fontSize: size, color: color, fontWeight: fontWeight)), + ], + ); + } } } diff --git a/lib/widgets/wallet_header.dart b/lib/widgets/wallet_header.dart index 850cec57ed0f1decfa98b5b3029aa8b4216c3fca..b0f7fbd28baa8bb71a7088951b31a72645aeb18f 100644 --- a/lib/widgets/wallet_header.dart +++ b/lib/widgets/wallet_header.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:durt2/durt2.dart' show IdtyStatus; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -115,17 +116,19 @@ class _WalletHeaderState extends State<WalletHeader> { } } - Widget _buildContent(BuildContext context, bool hasIdentity, bool isOwner, bool isPickerOpen, String newCustomImagePath, DuniterIndexer duniterIndexer) { + Widget _buildContent(BuildContext context, BigInt currentWalletBalance, bool hasIdentity, bool isOwner, bool isPickerOpen, String newCustomImagePath, + DuniterIndexer duniterIndexer) { const double avatarSize = 90; - final walletOptions = Provider.of<WalletOptionsProvider>(context); + final walletOptions = Provider.of<WalletOptionsProvider>(context, listen: false); Provider.of<SubstrateSdk>(context); //To refresh header color on block changes - final balance = walletOptions.balanceCache[widget.address] ?? 0; - final isEmptyWallet = balance == 0; + + final balance = walletOptions.balanceCache[widget.address] == null ? currentWalletBalance : BigInt.from(walletOptions.balanceCache[widget.address] ?? 0); + + final isEmptyWallet = balance == BigInt.zero; return Container( decoration: BoxDecoration( - color: isEmptyWallet ? Colors.grey[300] : headerColor, - borderRadius: BorderRadius.circular(8), + color: isEmptyWallet ? context.colorScheme.error : context.colorScheme.tertiary, ), padding: EdgeInsets.only( left: scaleSize(16), @@ -258,6 +261,7 @@ class _WalletHeaderState extends State<WalletHeader> { fontSize: 20, fontFamily: 'Monospace', fontWeight: FontWeight.w600, + color: context.colorScheme.onSecondaryContainer, ), ), ), @@ -269,7 +273,7 @@ class _WalletHeaderState extends State<WalletHeader> { icon: Icon( Icons.copy, size: scaleSize(20), - color: orangeC.withValues(alpha: 0.5), + color: context.colorScheme.primary.withValues(alpha: 0.5), ), onPressed: () { Clipboard.setData(ClipboardData(text: widget.address)); @@ -310,7 +314,7 @@ class _WalletHeaderState extends State<WalletHeader> { children: [ IdentityStatus( address: widget.address, - color: orangeC, + color: context.colorScheme.primary, ), SizedBox(width: scaleSize(8)), Certifications( @@ -320,7 +324,7 @@ class _WalletHeaderState extends State<WalletHeader> { Icon( Icons.chevron_right, size: scaleSize(15), - color: orangeC.withValues(alpha: 0.5), + color: context.colorScheme.primary.withValues(alpha: 0.5), ), ], ), @@ -339,7 +343,7 @@ class _WalletHeaderState extends State<WalletHeader> { Widget _buildLoadingHeader() { const double avatarSize = 90; return Container( - color: headerColor, + color: context.colorScheme.tertiary, padding: EdgeInsets.only( left: scaleSize(16), right: scaleSize(16), @@ -455,6 +459,7 @@ class _WalletHeaderState extends State<WalletHeader> { if (cached != null) { return _buildContent( context, + cached.balance, cached.hasIdentity, cached.isOwner, _isPickerOpen, @@ -478,6 +483,7 @@ class _WalletHeaderState extends State<WalletHeader> { final data = snapshot.data!; return _buildContent( context, + data.balance, data.hasIdentity, data.isOwner, _isPickerOpen, diff --git a/lib/widgets/wallet_tile.dart b/lib/widgets/wallet_tile.dart index 72e428862568224b7372b72a093c3b82a20ef186..3fa6f165094894955fea422e812fc54e0645d140 100644 --- a/lib/widgets/wallet_tile.dart +++ b/lib/widgets/wallet_tile.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:durt2/durt2.dart' show WalletData; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -63,14 +64,7 @@ class WalletTile extends StatelessWidget { topLeft: Radius.circular(12), topRight: Radius.circular(12), ), - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - const Color(0xFFFFFFF0), - yellowC.withValues(alpha: 0.3), - ], - ), + color: context.colorScheme.secondary.withValues(alpha: context.isDarkTheme ? 1 : 0.3), ), child: repository.imagePath == null || repository.imagePath == '' ? Padding( @@ -98,7 +92,7 @@ class WalletTile extends StatelessWidget { ), Container( decoration: BoxDecoration( - color: isDefault ? orangeC.withValues(alpha: 0.9) : yellowC.withValues(alpha: 0.9), + color: isDefault ? context.colorScheme.primary.withValues(alpha: 0.9) : context.colorScheme.secondary.withValues(alpha: 0.9), borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(12), bottomRight: Radius.circular(12), @@ -113,14 +107,14 @@ class WalletTile extends StatelessWidget { NameByAddress( wallet: repository, size: 16, - color: isDefault ? Colors.white : Colors.black87, + color: isDefault ? Colors.white : context.colorScheme.onSurface, fontWeight: FontWeight.w600, ), ScaledSizedBox(height: 4), Balance( address: repository.address, size: 14, - color: isDefault ? Colors.white : Colors.black87, + color: isDefault ? Colors.white : context.colorScheme.onSurface, ), ], ), diff --git a/lib/widgets/wallet_tile_membre.dart b/lib/widgets/wallet_tile_membre.dart index 4045fd8944e4a28b6bbae3ecc2f38780ac3859d4..45f7b6b6d958dfe369a3a6cf378cb1a7dd1bd63e 100644 --- a/lib/widgets/wallet_tile_membre.dart +++ b/lib/widgets/wallet_tile_membre.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:durt2/durt2.dart' show WalletData; import 'package:flutter/material.dart'; +import 'package:gecko/extensions.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/scale_functions.dart'; import 'package:gecko/models/widgets_keys.dart'; @@ -64,14 +65,7 @@ class WalletTileMembre extends StatelessWidget { topLeft: Radius.circular(12), topRight: Radius.circular(12), ), - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - const Color(0xFFFFFFF0), - yellowC.withValues(alpha: 0.3), - ], - ), + color: context.colorScheme.secondary.withValues(alpha: context.isDarkTheme ? 1 : 0.3), ), child: wallet.imagePath == null || wallet.imagePath == '' ? Padding( @@ -101,7 +95,7 @@ class WalletTileMembre extends StatelessWidget { top: scaleSize(16), child: Image.asset( 'assets/medal.png', - color: orangeC.withValues(alpha: 0.8), + color: context.colorScheme.primary.withValues(alpha: 0.8), height: scaleSize(28), ), ), @@ -110,7 +104,7 @@ class WalletTileMembre extends StatelessWidget { ), Container( decoration: BoxDecoration( - color: isDefault ? orangeC.withValues(alpha: 0.9) : yellowC.withValues(alpha: 0.9), + color: isDefault ? context.colorScheme.primary.withValues(alpha: 0.9) : context.colorScheme.secondary.withValues(alpha: 0.9), borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(12), bottomRight: Radius.circular(12), @@ -129,20 +123,20 @@ class WalletTileMembre extends StatelessWidget { NameByAddress( wallet: wallet, size: 16, - color: isDefault ? Colors.white : Colors.black87, + color: isDefault ? Colors.white : context.colorScheme.onSurface, fontWeight: FontWeight.w600, ), ScaledSizedBox(height: 4), Balance( address: wallet.address, size: 14, - color: isDefault ? Colors.white : Colors.black87, + color: isDefault ? Colors.white : context.colorScheme.onSurface, ), ], ), Certifications( address: wallet.address, - color: isDefault ? Colors.white : Colors.black87, + color: isDefault ? Colors.white : context.colorScheme.onSurface, size: 15, ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 22129e9f67b4e5c4d751f248f6543b5fc847b618..e59f30184c0e356bc443b7e6cdeab92b2c87b326 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: gecko description: Pay with G1. publish_to: "none" -version: 0.1.27+108 +version: 0.1.28+109 environment: sdk: ^3.5.3 diff --git a/scripts/deploy-ios.sh b/scripts/deploy-ios.sh index 5a38a136915203c93256e0d52e513f4f10da8bba..48dd53029d6e5534f11164d1b10479681bb1cf25 100755 --- a/scripts/deploy-ios.sh +++ b/scripts/deploy-ios.sh @@ -2,6 +2,15 @@ set -e +# Function to clean up Info.plist +cleanup() { + echo "Cleaning up Info.plist..." + git checkout ios/Runner/Info.plist +} + +# Trap ERR and EXIT signals to ensure cleanup +trap cleanup ERR EXIT + # Load environment variables if [ -f .env ]; then export $(cat .env | sed 's/#.*//g' | xargs) @@ -17,6 +26,11 @@ BUILD=$(awk -F '+' '{ print $2 }' <<<$fVersion) echo "Building Gecko iOS v${VERSION}+${BUILD}" +# Temporarily replace build name and number in Info.plist +echo "Updating Info.plist with version ${VERSION} and build number ${BUILD}" +sed -i '' "s|\$(FLUTTER_BUILD_NAME)|${VERSION}|g" ios/Runner/Info.plist +sed -i '' "s|\$(FLUTTER_BUILD_NUMBER)|${BUILD}|g" ios/Runner/Info.plist + # get dependencies fvm flutter pub get @@ -41,9 +55,7 @@ xcrun altool --upload-app \ --file "$IPA_PATH" \ --username "$APPLE_ID" \ --password "$APP_SPECIFIC_PASSWORD" \ - --bundle-id "$BUNDLE_ID" \ - --bundle-version "$VERSION" \ - --bundle-short-version-string "$BUILD" + --bundle-id "$BUNDLE_ID" if [ $? -eq 0 ]; then echo "Successfully uploaded to App Store" @@ -52,4 +64,4 @@ else exit 1 fi -exit 0 \ No newline at end of file +exit 0