diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/lib/globals.dart b/lib/globals.dart index e573a7a..115be3d 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:gecko/models/chestData.dart'; -import 'package:gecko/models/walletData.dart'; +import 'package:gecko/models/chest_data.dart'; +import 'package:gecko/models/wallet_data.dart'; import 'package:hive/hive.dart'; import 'package:logger/logger.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -28,7 +28,7 @@ double ratio; var log = Logger(); // Colors -Color orangeC = Color(0xffd07316); -Color yellowC = Color(0xffFFD68E); -Color floattingYellow = Color(0xffEFEFBF); -Color backgroundColor = Color(0xFFF5F5F5); +Color orangeC = const Color(0xffd07316); +Color yellowC = const Color(0xffFFD68E); +Color floattingYellow = const Color(0xffEFEFBF); +Color backgroundColor = const Color(0xFFF5F5F5); diff --git a/lib/main.dart b/lib/main.dart index 36cfc48..e1c3f5b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,22 +13,24 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// ignore_for_file: avoid_print + import 'dart:async'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/cesiumPlus.dart'; -import 'package:gecko/models/changePin.dart'; -import 'package:gecko/models/chestData.dart'; -import 'package:gecko/models/generateWallets.dart'; +import 'package:gecko/models/cesium_plus.dart'; +import 'package:gecko/models/change_pin.dart'; +import 'package:gecko/models/chest_data.dart'; +import 'package:gecko/models/generate_wallets.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/home.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:gecko/screens/home.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/screens/myWallets/walletsHome.dart'; +import 'package:gecko/screens/myWallets/wallets_home.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:path_provider/path_provider.dart'; @@ -38,7 +40,7 @@ import 'package:responsive_framework/responsive_framework.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; -final bool enableSentry = true; +const bool enableSentry = true; Future main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -106,7 +108,7 @@ Future main() async { } class Gecko extends StatelessWidget { - Gecko(this.randomEndpoint); + const Gecko(this.randomEndpoint, {Key key}) : super(key: key); final String randomEndpoint; @override @@ -145,28 +147,28 @@ class Gecko extends StatelessWidget { minWidth: 480, defaultScale: true, breakpoints: [ - ResponsiveBreakpoint.resize(480, name: MOBILE), - ResponsiveBreakpoint.autoScale(800, name: TABLET), - ResponsiveBreakpoint.resize(1000, name: DESKTOP), + const ResponsiveBreakpoint.resize(480, name: MOBILE), + const ResponsiveBreakpoint.autoScale(800, name: TABLET), + const ResponsiveBreakpoint.resize(1000, name: DESKTOP), ], background: Container(color: backgroundColor)), title: 'Ğecko', theme: ThemeData( - appBarTheme: AppBarTheme( - color: const Color(0xffFFD58D), - foregroundColor: const Color(0xFF000000), + appBarTheme: const AppBarTheme( + color: Color(0xffFFD58D), + foregroundColor: Color(0xFF000000), ), - primaryColor: Color(0xffFFD58D), - textTheme: TextTheme( + primaryColor: const Color(0xffFFD58D), + textTheme: const TextTheme( bodyText1: TextStyle(), bodyText2: TextStyle(), ).apply( - bodyColor: Color(0xFF000000), + bodyColor: const Color(0xFF000000), ), colorScheme: ColorScheme.fromSwatch() .copyWith(secondary: Colors.grey[850]), ), - home: HomeScreen(), + home: const HomeScreen(), initialRoute: "/", routes: { '/mywallets': (context) => WalletsHome(), diff --git a/lib/models/cesiumPlus.dart b/lib/models/cesium_plus.dart similarity index 96% rename from lib/models/cesiumPlus.dart rename to lib/models/cesium_plus.dart index 47ebef1..8d73d00 100644 --- a/lib/models/cesiumPlus.dart +++ b/lib/models/cesium_plus.dart @@ -7,10 +7,6 @@ import 'package:http/http.dart' as http; import 'package:path_provider/path_provider.dart'; class CesiumPlusProvider with ChangeNotifier { - // String pubkey = ''; - // CesiumPlusProvider(this.pubkey); - var decodedBytes; - var avatar64; TextEditingController cesiumName = TextEditingController(); int iAvatar = 0; bool isComplete = false; diff --git a/lib/models/changePin.dart b/lib/models/change_pin.dart similarity index 90% rename from lib/models/changePin.dart rename to lib/models/change_pin.dart index 3c85b2e..b65e74c 100644 --- a/lib/models/changePin.dart +++ b/lib/models/change_pin.dart @@ -3,11 +3,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/chestData.dart'; +import 'package:gecko/models/chest_data.dart'; class ChangePinProvider with ChangeNotifier { bool ischangedPin = false; - TextEditingController newPin = new TextEditingController(); + TextEditingController newPin = TextEditingController(); Future get badWallet => null; diff --git a/lib/models/chestData.dart b/lib/models/chest_data.dart similarity index 90% rename from lib/models/chestData.dart rename to lib/models/chest_data.dart index a053289..923a385 100644 --- a/lib/models/chestData.dart +++ b/lib/models/chest_data.dart @@ -1,6 +1,6 @@ import 'package:hive_flutter/hive_flutter.dart'; -part 'chestData.g.dart'; +part 'chest_data.g.dart'; @HiveType(typeId: 1) class ChestData extends HiveObject { @@ -29,6 +29,6 @@ class ChestData extends HiveObject { @override String toString() { - return this.name; + return name; } } diff --git a/lib/models/chestData.g.dart b/lib/models/chest_data.g.dart similarity index 98% rename from lib/models/chestData.g.dart rename to lib/models/chest_data.g.dart index 9beaa42..ca25dff 100644 --- a/lib/models/chestData.g.dart +++ b/lib/models/chest_data.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'chestData.dart'; +part of 'chest_data.dart'; // ************************************************************************** // TypeAdapterGenerator diff --git a/lib/models/generateWallets.dart b/lib/models/generate_wallets.dart similarity index 95% rename from lib/models/generateWallets.dart rename to lib/models/generate_wallets.dart index d74666f..3b8cec8 100644 --- a/lib/models/generateWallets.dart +++ b/lib/models/generate_wallets.dart @@ -5,8 +5,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/chestData.dart'; -import 'package:gecko/models/walletData.dart'; +import 'package:gecko/models/chest_data.dart'; +import 'package:gecko/models/wallet_data.dart'; import 'package:pdf/pdf.dart'; import 'package:pdf/widgets.dart' as pw; import 'package:printing/printing.dart'; @@ -100,7 +100,7 @@ class GenerateWalletsProvider with ChangeNotifier { } int getRandomInt() { - var rng = new Random(); + var rng = Random(); return rng.nextInt(12); } @@ -131,7 +131,7 @@ class GenerateWalletsProvider with ChangeNotifier { Future generateMnemonic() async { try { generatedMnemonic = await DubpRust.genMnemonic(language: Language.french); - this.actualWallet = await generateWallet(this.generatedMnemonic); + actualWallet = await generateWallet(generatedMnemonic); walletIsGenerated = true; } catch (e) { log.e(e); @@ -141,7 +141,7 @@ class GenerateWalletsProvider with ChangeNotifier { Future generateWallet(generatedMnemonic) async { try { - this.actualWallet = await DubpRust.genWalletFromMnemonic( + actualWallet = await DubpRust.genWalletFromMnemonic( language: Language.french, mnemonic: generatedMnemonic, secretCodeType: SecretCodeType.letters, @@ -151,10 +151,10 @@ class GenerateWalletsProvider with ChangeNotifier { } mnemonicController.text = generatedMnemonic; - pin.text = this.actualWallet.pin; + pin.text = actualWallet.pin; // notifyListeners(); - return this.actualWallet; + return actualWallet; } Future changePinCode({bool reload}) async { @@ -177,7 +177,7 @@ class GenerateWalletsProvider with ChangeNotifier { final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData()); final pdf = pw.Document(); - const imageProvider = const AssetImage('assets/icon/gecko_final.png'); + const imageProvider = AssetImage('assets/icon/gecko_final.png'); final geckoLogo = await flutterImageProvider(imageProvider); pdf.addPage( diff --git a/lib/models/history.dart b/lib/models/history.dart index ff762f0..19a15fa 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -3,8 +3,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/home.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletData.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/screens/history.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:jdenticon_dart/jdenticon_dart.dart'; @@ -42,7 +42,7 @@ class HistoryProvider with ChangeNotifier { return 'false'; } if (barcode != null) { - this.outputPubkey.text = barcode; + outputPubkey.text = barcode; isPubkey(context, barcode); } else { return 'false'; @@ -77,7 +77,7 @@ class HistoryProvider with ChangeNotifier { String isPubkey(context, pubkey, {bool goHistory}) { HomeProvider _homeProvider = Provider.of(context, listen: false); - final RegExp regExp = new RegExp( + final RegExp regExp = RegExp( r'^[a-zA-Z0-9]+$', caseSensitive: false, multiLine: false, @@ -91,9 +91,9 @@ class HistoryProvider with ChangeNotifier { this.pubkey = pubkey; getShortPubkey(pubkey); - this.outputPubkey.text = pubkey; + outputPubkey.text = pubkey; - if (goHistory == null) goHistory = false; + goHistory ??= false; if (goHistory) { isHistoryScreen = true; @@ -144,13 +144,13 @@ class HistoryProvider with ChangeNotifier { var transBC = []; int i = 0; - final currentBase = 0; + const currentBase = 0; double currentUD = 10.54; for (final trans in txs) { var direction = trans['direction']; final transaction = trans['node']; - var output; + String output; if (direction == "RECEIVED") { for (String line in transaction['outputs']) { if (line.contains(_pubkey)) { @@ -241,15 +241,15 @@ class HistoryProvider with ChangeNotifier { } else { _message = "Vous êtes connecté au noeud\n${endPointGVA.split('/')[2]}"; } - final snackBar = - SnackBar(content: Text(_message), duration: Duration(seconds: 2)); + final snackBar = SnackBar( + content: Text(_message), duration: const Duration(seconds: 2)); isFirstBuild = false; ScaffoldMessenger.of(context).showSnackBar(snackBar); } } void resetdHistory() { - this.outputPubkey.text = ''; + outputPubkey.text = ''; notifyListeners(); } @@ -259,7 +259,7 @@ class HistoryProvider with ChangeNotifier { } snackCopyKey(context) { - final snackBar = SnackBar( + const snackBar = SnackBar( content: Text("Cette clé publique a été copié dans votre presse-papier."), duration: Duration(seconds: 2)); diff --git a/lib/models/home.dart b/lib/models/home.dart index 1b67d41..69fe956 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -9,14 +9,14 @@ import 'package:flutter/services.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; import 'package:gecko/screens/history.dart'; -import 'package:gecko/screens/myWallets/walletsHome.dart'; +import 'package:gecko/screens/myWallets/wallets_home.dart'; import 'package:package_info/package_info.dart'; class HomeProvider with ChangeNotifier { int _currentIndex = 0; bool isSearching; - Icon searchIcon = Icon(Icons.search); - final TextEditingController searchQuery = new TextEditingController(); + Icon searchIcon = const Icon(Icons.search); + final TextEditingController searchQuery = TextEditingController(); Widget appBarTitle = Text('Ğecko', style: TextStyle(color: Colors.grey[850])); Widget appBarExplorer = Text('Explorateur', style: TextStyle(color: Colors.grey[850])); @@ -57,7 +57,7 @@ class HomeProvider with ChangeNotifier { String _endpoint; int _statusCode = 0; - final _client = new HttpClient(); + final _client = HttpClient(); _client.connectionTimeout = const Duration(milliseconds: 1000); do { diff --git a/lib/models/myWallets.dart b/lib/models/my_wallets.dart similarity index 88% rename from lib/models/myWallets.dart rename to lib/models/my_wallets.dart index 53d0da0..886202a 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/my_wallets.dart @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/walletData.dart'; +import 'package:gecko/models/wallet_data.dart'; class MyWalletsProvider with ChangeNotifier { List listWallets = []; @@ -41,12 +41,12 @@ class MyWalletsProvider with ChangeNotifier { if (_id.isEmpty) return WalletData(); int _chest = _id[0]; int _nbr = _id[1]; - var _targetedWallet; + WalletData _targetedWallet; walletBox.toMap().forEach((key, value) { if (value.chest == _chest && value.number == _nbr) { _targetedWallet = value; - return false; + return; } }); @@ -86,19 +86,19 @@ class MyWalletsProvider with ChangeNotifier { barrierDismissible: true, // user must tap button! builder: (BuildContext context) { return AlertDialog( - title: - Text('Êtes-vous sûr de vouloir supprimer tous vos trousseaux ?'), - content: SingleChildScrollView(child: Text('')), + title: const Text( + 'Êtes-vous sûr de vouloir supprimer tous vos trousseaux ?'), + content: const SingleChildScrollView(child: Text('')), actions: [ TextButton( - child: Text("Non"), + child: const Text("Non"), onPressed: () { Navigator.pop(context, false); }, ), TextButton( - key: Key('confirmDeletingAllWallets'), - child: Text("Oui"), + key: const Key('confirmDeletingAllWallets'), + child: const Text("Oui"), onPressed: () { Navigator.pop(context, true); }, diff --git a/lib/models/walletData.dart b/lib/models/wallet_data.dart similarity index 77% rename from lib/models/walletData.dart rename to lib/models/wallet_data.dart index 2c4a82d..f4ce723 100644 --- a/lib/models/walletData.dart +++ b/lib/models/wallet_data.dart @@ -1,6 +1,6 @@ import 'package:hive_flutter/hive_flutter.dart'; -part 'walletData.g.dart'; +part 'wallet_data.g.dart'; @HiveType(typeId: 0) class WalletData extends HiveObject { @@ -25,16 +25,16 @@ class WalletData extends HiveObject { // representation of WalletData when debugging @override String toString() { - return this.name; + return name; } // creates the ':'-separated string from the WalletData String inLine() { - return "${this.chest}:${this.number}:${this.name}:${this.derivation}:${this.imageName}"; + return "$chest:$number:$name:$derivation:$imageName"; } // returns only the id part of the ':'-separated string List id() { - return [this.chest, this.number]; + return [chest, number]; } } diff --git a/lib/models/walletData.g.dart b/lib/models/wallet_data.g.dart similarity index 97% rename from lib/models/walletData.g.dart rename to lib/models/wallet_data.g.dart index 36d6a0b..4ef937a 100644 --- a/lib/models/walletData.g.dart +++ b/lib/models/wallet_data.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'walletData.dart'; +part of 'wallet_data.dart'; // ************************************************************************** // TypeAdapterGenerator diff --git a/lib/models/walletOptions.dart b/lib/models/wallet_options.dart similarity index 90% rename from lib/models/walletOptions.dart rename to lib/models/wallet_options.dart index 5b0f832..19c8099 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/wallet_options.dart @@ -8,18 +8,18 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletData.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; import 'package:image_picker/image_picker.dart'; import 'package:truncate/truncate.dart'; import 'package:qrscan/qrscan.dart' as scanner; class WalletOptionsProvider with ChangeNotifier { TextEditingController pubkey = TextEditingController(); - TextEditingController _newWalletName = TextEditingController(); + final TextEditingController _newWalletName = TextEditingController(); bool isWalletUnlock = false; bool ischangedPin = false; - TextEditingController newPin = new TextEditingController(); + TextEditingController newPin = TextEditingController(); bool isEditing = false; bool isBalanceBlur = true; FocusNode walletNameFocus = FocusNode(); @@ -32,7 +32,7 @@ class WalletOptionsProvider with ChangeNotifier { Future _getPubkeyFromDewif( String _dewif, _pin, int _pinLenght, int derivation) async { String _pubkey; - RegExp regExp = new RegExp( + RegExp regExp = RegExp( r'^[A-Z0-9]+$', caseSensitive: false, multiLine: false, @@ -47,7 +47,7 @@ class WalletOptionsProvider with ChangeNotifier { List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys( dewif: _dewif, secretCode: _pin, accountsIndex: [derivation]); _pubkey = _pubkeysTmp[0]; - this.pubkey.text = _pubkey; + pubkey.text = _pubkey; notifyListeners(); return _pubkey; @@ -60,7 +60,7 @@ class WalletOptionsProvider with ChangeNotifier { } else { try { _pubkey = await DubpRust.getDewifPublicKey(dewif: _dewif, pin: _pin); - this.pubkey.text = _pubkey; + pubkey.text = _pubkey; notifyListeners(); return _pubkey; } catch (e) { @@ -82,7 +82,7 @@ class WalletOptionsProvider with ChangeNotifier { if ((_localPubkey = await _getPubkeyFromDewif( _localDewif, _pin, _pinLenght, _wallet.derivation)) != 'false') { - this.pubkey.text = _localPubkey; + pubkey.text = _localPubkey; isWalletUnlock = true; return _localDewif; } else { @@ -91,7 +91,7 @@ class WalletOptionsProvider with ChangeNotifier { } catch (e) { // _homeProvider.playSound('non', 0.6); log.e('ERROR READING FILE: $e'); - this.pubkey.clear(); + pubkey.clear(); return 'bad'; } } @@ -142,16 +142,16 @@ class WalletOptionsProvider with ChangeNotifier { barrierDismissible: true, builder: (BuildContext context) { return AlertDialog( - title: Text('Choisissez un nouveau nom pour ce portefeuille'), + title: const Text('Choisissez un nouveau nom pour ce portefeuille'), content: SingleChildScrollView( child: ListBody( children: [ TextField( - controller: this._newWalletName, + controller: _newWalletName, maxLines: 1, textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( + decoration: const InputDecoration(), + style: const TextStyle( fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.bold)), @@ -160,7 +160,7 @@ class WalletOptionsProvider with ChangeNotifier { ), actions: [ TextButton( - child: Text("Valider"), + child: const Text("Valider"), onPressed: () { WidgetsBinding.instance.addPostFrameCallback((_) async { // await _renameWallet(_walletName, this._newWalletName.text, @@ -219,20 +219,20 @@ class WalletOptionsProvider with ChangeNotifier { 'Êtes-vous sûr de vouloir supprimer le portefeuille "$_walletName" ?'), content: SingleChildScrollView( child: ListBody( - children: [ + children: const [ Text('Vous pourrez restaurer ce portefeuille plus tard.'), ], ), ), actions: [ TextButton( - child: Text("Non", key: Key('cancelDeleting')), + child: const Text("Non", key: Key('cancelDeleting')), onPressed: () { Navigator.pop(context, false); }, ), TextButton( - child: Text("Oui", key: Key('confirmDeleting')), + child: const Text("Oui", key: Key('confirmDeleting')), onPressed: () { Navigator.pop(context, true); }, @@ -244,7 +244,7 @@ class WalletOptionsProvider with ChangeNotifier { } snackCopyKey(context) { - final snackBar = SnackBar( + const snackBar = SnackBar( content: Text("Cette clé publique a été copié dans votre presse-papier."), duration: Duration(seconds: 2)); diff --git a/lib/screens/commonElements.dart b/lib/screens/common_elements.dart similarity index 91% rename from lib/screens/commonElements.dart rename to lib/screens/common_elements.dart index 78c6621..4056d56 100644 --- a/lib/screens/commonElements.dart +++ b/lib/screens/common_elements.dart @@ -5,22 +5,22 @@ import 'package:gecko/globals.dart'; class CommonElements { // Exemple de Widget Widget exemple(String data) { - return Text('Coucou'); + return const Text('Coucou'); } Widget bubbleSpeak(String text, {double long, Key textKey}) { return Bubble( padding: long == null - ? BubbleEdges.all(18) + ? const BubbleEdges.all(18) : BubbleEdges.symmetric(horizontal: long, vertical: 30), elevation: 5, color: Colors.white, - margin: BubbleEdges.fromLTRB(10, 0, 20, 10), + margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), // nip: BubbleNip.leftTop, child: Text( text, key: textKey, - style: TextStyle( + style: const TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), ), ); @@ -28,15 +28,15 @@ class CommonElements { Widget bubbleSpeakRich(List text, {Key textKey}) { return Bubble( - padding: BubbleEdges.all(18), + padding: const BubbleEdges.all(18), elevation: 5, color: Colors.white, - margin: BubbleEdges.fromLTRB(10, 0, 20, 10), + margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), // nip: BubbleNip.leftTop, child: RichText( key: textKey, text: TextSpan( - style: TextStyle( + style: const TextStyle( fontSize: 18.0, color: Colors.black, ), @@ -87,7 +87,7 @@ class CommonElements { top: 70, right: 90, child: Text(progress == 12 ? '11/11' : '$progress/11', - style: TextStyle(fontSize: 12, color: Colors.black)), + style: const TextStyle(fontSize: 12, color: Colors.black)), ), ]); } @@ -102,7 +102,7 @@ class CommonElements { return Container( child: ClipOval( child: Material( - color: Color(0xffFFD58D), // button color + color: const Color(0xffFFD58D), // button color child: InkWell( splashColor: orangeC, // inkwell color child: Padding( @@ -113,7 +113,7 @@ class CommonElements { }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -207,14 +207,14 @@ class GeckoSpeechAppBar extends StatelessWidget with PreferredSizeWidget { GeckoSpeechAppBar( this.title, { Key key, - }) : preferredSize = Size.fromHeight(105.4), + }) : preferredSize = const Size.fromHeight(105.4), super(key: key); @override Widget build(BuildContext context) { return AppBar( leading: IconButton( - icon: Container( + icon: SizedBox( height: 30, child: Image.asset('assets/onBoarding/gecko_bar.png')), onPressed: () => Navigator.popUntil( diff --git a/lib/screens/history.dart b/lib/screens/history.dart index b92ada5..b5dd1b6 100644 --- a/lib/screens/history.dart +++ b/lib/screens/history.dart @@ -1,15 +1,15 @@ import 'dart:io'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/cesiumPlus.dart'; +import 'package:gecko/models/cesium_plus.dart'; import 'package:gecko/models/home.dart'; -import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/queries.dart'; import 'package:gecko/models/history.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/screens/myWallets/unlockingWallet.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'dart:ui'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; @@ -22,7 +22,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { final nRepositories = 20; // HistoryProvider _historyProvider; final _formKey = GlobalKey(); - FocusNode _pubkeyFocus = FocusNode(); + final FocusNode _pubkeyFocus = FocusNode(); List cesiumData; final double avatarsSize = 80; @@ -30,12 +30,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { FetchMoreOptions opts; final GlobalKey _scaffoldKey = GlobalKey(); + HistoryScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); HistoryProvider _historyProvider = Provider.of(context); HomeProvider _homeProvider = Provider.of(context); - this._outputPubkey.text = _historyProvider.pubkey; + _outputPubkey.text = _historyProvider.pubkey; log.i('Build pubkey : ' + _historyProvider.pubkey); WidgetsBinding.instance.addPostFrameCallback((_) {}); @@ -45,7 +47,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { title: _homeProvider.appBarExplorer, actions: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 16), child: IconButton( icon: _homeProvider.searchIcon, color: Colors.grey[850], @@ -81,9 +83,9 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { } })) ], - backgroundColor: Color(0xffFFD58D), + backgroundColor: const Color(0xffFFD58D), ), - floatingActionButton: Container( + floatingActionButton: SizedBox( height: 80.0, width: 80.0, child: FittedBox( @@ -92,11 +94,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { onPressed: () async { await _historyProvider.scan(context); }, - child: Container( + child: SizedBox( height: 40.0, width: 40.0, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 3), + padding: const EdgeInsets.symmetric(horizontal: 3), child: Image.asset('assets/qrcode-scan.png'))), backgroundColor: floattingYellow, //smoothYellow, //Color.fromARGB(500, 204, 255, 255), @@ -104,7 +106,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { ), ), body: Column(children: [ - SizedBox(height: 0), + const SizedBox(height: 0), if (_historyProvider.pubkey != '') historyQuery(context, _historyProvider), ])); @@ -139,7 +141,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { if (result.hasException) { log.e('Error GVA: ' + result.exception.toString()); - return Column(children: [ + return Column(children: const [ SizedBox(height: 50), Text( "Aucun noeud GVA valide n'a pu être trouvé.\nVeuillez réessayer ultérieurement.", @@ -171,10 +173,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { child: Builder( builder: (context) => Expanded( child: ListView( - key: Key('listTransactions'), + key: const Key('listTransactions'), controller: scrollController, children: [ - SizedBox(height: 20), + const SizedBox(height: 20), if (_historyProvider.pubkey != '') Row( mainAxisAlignment: @@ -214,7 +216,8 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { if (_avatar.hasData) { return SingleChildScrollView( padding: - EdgeInsets.all(0.0), + const EdgeInsets.all( + 0.0), child: Image.file( _avatar.data[0], height: avatarsSize)); @@ -225,7 +228,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { height: avatarsSize); })), GestureDetector( - key: Key('copyPubkey'), + key: const Key('copyPubkey'), onTap: () { Clipboard.setData(ClipboardData( text: _historyProvider.pubkey)); @@ -234,7 +237,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { child: Text( _historyProvider.getShortPubkey( _historyProvider.pubkey), - style: TextStyle( + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.w800, fontFamily: 'Monospace')), @@ -257,7 +260,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { ], ), )), - SizedBox(width: 0) + const SizedBox(width: 0) ]), if (_isFirstExec) Row( @@ -274,25 +277,22 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { _historyProvider.pubkey), initialData: '...', builder: (context, snapshot) { - return Text( - snapshot.data != null - ? snapshot.data - : '-', - style: - TextStyle(fontSize: 20)); + return Text(snapshot.data ?? '-', + style: const TextStyle( + fontSize: 20)); })) ]), - SizedBox(height: 18), + const SizedBox(height: 18), if (_isFirstExec) Container( padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), child: Text(balance.toString() + ' Ğ1', textAlign: TextAlign.center, - style: TextStyle(fontSize: 18.0))), - SizedBox(height: 20), + style: const TextStyle(fontSize: 18.0))), + const SizedBox(height: 20), ElevatedButton( - key: Key('switchPayHistory'), + key: const Key('switchPayHistory'), style: ElevatedButton.styleFrom( elevation: 1, primary: Colors.grey[50], // background @@ -344,32 +344,32 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { child: Column( mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 20), - Text('Commentaire:', style: TextStyle(fontSize: 20.0)), + const SizedBox(height: 20), + const Text('Commentaire:', style: TextStyle(fontSize: 20.0)), Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: TextField( controller: _historyProvider.payComment, maxLines: 2, textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( + decoration: const InputDecoration(), + style: const TextStyle( fontSize: 22, color: Colors.black, fontWeight: FontWeight.bold))), - SizedBox(height: 20), - Text('Montant (DU/Ğ1):', style: TextStyle(fontSize: 20.0)), + const SizedBox(height: 20), + const Text('Montant (DU/Ğ1):', style: TextStyle(fontSize: 20.0)), Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: TextFormField( - style: TextStyle(fontSize: 22), + style: const TextStyle(fontSize: 22), controller: _historyProvider.payAmount, textAlign: TextAlign.center, maxLines: 1, keyboardType: TextInputType.number, decoration: InputDecoration( - contentPadding: - EdgeInsets.symmetric(vertical: 25.0, horizontal: 10.0), + contentPadding: const EdgeInsets.symmetric( + vertical: 25.0, horizontal: 10.0), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0)), ), @@ -412,7 +412,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { int keyID = 0; return _historyProvider.transBC == null - ? Text('Aucune transaction à afficher.') + ? const Text('Aucune transaction à afficher.') : Column(children: [ for (var repository in _historyProvider.transBC) Padding( @@ -427,14 +427,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { fontWeight: FontWeight.w700), textAlign: TextAlign.center), title: Text(repository[3], - style: TextStyle( + style: const TextStyle( fontSize: 15.0, fontFamily: 'Monospace'), textAlign: TextAlign.center), subtitle: Text(repository[6] != '' ? repository[6] : '-', - style: TextStyle(fontSize: 12.0), + style: const TextStyle(fontSize: 12.0), textAlign: TextAlign.center), trailing: Text("${repository[4]} Ğ1", - style: TextStyle(fontSize: 14.0), + style: const TextStyle(fontSize: 14.0), textAlign: TextAlign.justify), dense: true, isThreeLine: false, @@ -445,14 +445,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { if (result.isLoading) Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ CircularProgressIndicator(), ], ), // if (_historyProvider.isTheEnd) // What I did before ... if (!_historyProvider.pageInfo['hasPreviousPage']) Column( - children: [ + children: const [ SizedBox(height: 15), Text("Début de l'historique.", textAlign: TextAlign.center, diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 22b74d7..fcc22a8 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -3,16 +3,18 @@ import 'package:gecko/globals.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/home.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/screens/myWallets/unlockingWallet.dart'; -import 'package:gecko/screens/onBoarding/0_noKeychainFound.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; +import 'package:gecko/screens/onBoarding/0_no_keychain_found.dart'; import 'dart:ui'; import 'package:gecko/screens/settings.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; class HomeScreen extends StatelessWidget { + const HomeScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -46,7 +48,7 @@ class HomeScreen extends StatelessWidget { Expanded( child: ListView(padding: EdgeInsets.zero, children: [ DrawerHeader( - child: Column(children: [ + child: Column(children: const [ SizedBox(height: 0), Image( image: AssetImage('assets/icon/gecko_final.png'), @@ -57,8 +59,8 @@ class HomeScreen extends StatelessWidget { ), ), ListTile( - key: Key('parameters'), - title: Text('Paramètres'), + key: const Key('parameters'), + title: const Text('Paramètres'), onTap: () { Navigator.pop(context); Navigator.push( @@ -70,34 +72,33 @@ class HomeScreen extends StatelessWidget { }, ), ListTile( - title: Text('A propos'), + title: const Text('A propos'), onTap: () { // Update the state of the app. // ... }, ), ])), - Container( - child: Align( - alignment: FractionalOffset.bottomCenter, - child: Text('Ğecko v$appVersion'))), - SizedBox(height: 20) + Align( + alignment: FractionalOffset.bottomCenter, + child: Text('Ğecko v$appVersion')), + const SizedBox(height: 20) ], ), ), appBar: AppBar( leading: Builder( builder: (context) => IconButton( - key: Key('drawerMenu'), - icon: new Icon(Icons.menu, color: Colors.grey[850]), + key: const Key('drawerMenu'), + icon: Icon(Icons.menu, color: Colors.grey[850]), onPressed: () => Scaffold.of(context).openDrawer(), )), title: _homeProvider.appBarTitle, actions: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 16), child: IconButton( - key: Key('searchIcon'), + key: const Key('searchIcon'), icon: _homeProvider.searchIcon, color: Colors.grey[850], onPressed: () { @@ -107,7 +108,7 @@ class HomeScreen extends StatelessWidget { color: Colors.grey[850], ); _homeProvider.appBarTitle = TextField( - key: Key('searchInput'), + key: const Key('searchInput'), autofocus: true, controller: _homeProvider.searchQuery, onChanged: (text) { @@ -133,9 +134,9 @@ class HomeScreen extends StatelessWidget { } })) ], - backgroundColor: Color(0xffFFD58D), + backgroundColor: const Color(0xffFFD58D), ), - backgroundColor: Color(0xffF9F9F1), + backgroundColor: const Color(0xffF9F9F1), body: Builder( builder: (ctx) => StatefulWrapper( onInit: () { @@ -146,10 +147,10 @@ class HomeScreen extends StatelessWidget { }, child: Column(children: [ Padding( - padding: EdgeInsets.only(top: 20), + padding: const EdgeInsets.only(top: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ SizedBox(width: 7), Image( image: @@ -157,10 +158,10 @@ class HomeScreen extends StatelessWidget { height: 180), ])), Padding( - padding: EdgeInsets.only(top: 15), + padding: const EdgeInsets.only(top: 15), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Text( "y'a pas de lézard !", textAlign: TextAlign.center, @@ -171,7 +172,7 @@ class HomeScreen extends StatelessWidget { ) ])), Padding( - padding: EdgeInsets.only(top: 60), + padding: const EdgeInsets.only(top: 60), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -179,10 +180,11 @@ class HomeScreen extends StatelessWidget { Container( child: ClipOval( child: Material( - color: Color(0xffFFD58D), // button color + color: const Color( + 0xffFFD58D), // button color child: InkWell( splashColor: orangeC, // inkwell color - child: Padding( + child: const Padding( padding: EdgeInsets.all(22), child: Image( image: AssetImage( @@ -194,7 +196,7 @@ class HomeScreen extends StatelessWidget { }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -206,8 +208,8 @@ class HomeScreen extends StatelessWidget { ], ), ), - SizedBox(height: 12), - Text( + const SizedBox(height: 12), + const Text( "Payer par QR-Code", textAlign: TextAlign.center, style: TextStyle( @@ -216,7 +218,7 @@ class HomeScreen extends StatelessWidget { ]) ])), Padding( - padding: EdgeInsets.only(top: 50), + padding: const EdgeInsets.only(top: 50), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -224,10 +226,11 @@ class HomeScreen extends StatelessWidget { Container( child: ClipOval( child: Material( - color: Color(0xffFFD58D), // button color + color: const Color( + 0xffFFD58D), // button color child: InkWell( splashColor: orangeC, // inkwell color - child: Padding( + child: const Padding( padding: EdgeInsets.symmetric( horizontal: 20, vertical: 16), child: Image( @@ -245,7 +248,7 @@ class HomeScreen extends StatelessWidget { }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -257,24 +260,25 @@ class HomeScreen extends StatelessWidget { ], ), ), - SizedBox(height: 12), - Text( + const SizedBox(height: 12), + const Text( "Explorer\n", textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 16), ) ]), - SizedBox(width: 140), + const SizedBox(width: 140), Column(children: [ Container( child: ClipOval( - key: Key('manageWallets'), + key: const Key('manageWallets'), child: Material( - color: Color(0xffFFD58D), // button color + color: const Color( + 0xffFFD58D), // button color child: InkWell( splashColor: orangeC, // inkwell color - child: Padding( + child: const Padding( padding: EdgeInsets.all(23), child: Image( image: AssetImage( @@ -296,12 +300,12 @@ class HomeScreen extends StatelessWidget { : Navigator.push(context, MaterialPageRoute( builder: (context) { - return NoKeyChainScreen(); + return const NoKeyChainScreen(); })); }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -313,8 +317,8 @@ class HomeScreen extends StatelessWidget { ], ), ), - SizedBox(height: 12), - Text( + const SizedBox(height: 12), + const Text( "Gérer mes\nportefeuilles", textAlign: TextAlign.center, style: TextStyle( @@ -351,7 +355,8 @@ class HomeScreen extends StatelessWidget { class StatefulWrapper extends StatefulWidget { final Function onInit; final Widget child; - const StatefulWrapper({@required this.onInit, @required this.child}); + const StatefulWrapper({Key key, @required this.onInit, @required this.child}) + : super(key: key); @override _StatefulWrapperState createState() => _StatefulWrapperState(); } diff --git a/lib/screens/myWallets/cesiumWalletOptions.dart b/lib/screens/myWallets/cesium_wallet_options.dart similarity index 88% rename from lib/screens/myWallets/cesiumWalletOptions.dart rename to lib/screens/myWallets/cesium_wallet_options.dart index da1b043..319bbbe 100644 --- a/lib/screens/myWallets/cesiumWalletOptions.dart +++ b/lib/screens/myWallets/cesium_wallet_options.dart @@ -3,10 +3,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/history.dart'; -import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/queries.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; import 'package:flutter/services.dart'; @@ -42,8 +42,9 @@ class CesiumWalletOptions extends StatelessWidget { _walletOptions.nameController.text.length >= 15 ? _nbrLinesName = 2 : _nbrLinesName = 1; - if (_walletOptions.nameController.text.length >= 26 && isTall) + if (_walletOptions.nameController.text.length >= 26 && isTall) { _nbrLinesName = 3; + } _walletOptions.walletID = [0, cesiumWallet.number]; @@ -71,7 +72,7 @@ class CesiumWalletOptions extends StatelessWidget { resizeToAvoidBottomInset: false, appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { _walletOptions.isEditing = false; _walletOptions.isBalanceBlur = true; @@ -98,11 +99,11 @@ class CesiumWalletOptions extends StatelessWidget { end: Alignment.bottomCenter, colors: [ yellowC, - Color(0xfffafafa), + const Color(0xfffafafa), ], )), child: Row(children: [ - SizedBox(width: 25), + const SizedBox(width: 25), InkWell( onTap: () async { await _walletOptions.changeAvatar(); @@ -119,7 +120,7 @@ class CesiumWalletOptions extends StatelessWidget { Image.asset( 'assets/walletOptions/camera.png', ), - SizedBox(height: 100) + const SizedBox(height: 100) ])), Column(children: [ Row(children: [ @@ -127,14 +128,14 @@ class CesiumWalletOptions extends StatelessWidget { SizedBox( width: 260, child: TextField( - key: Key('walletName'), + key: const Key('walletName'), autofocus: false, focusNode: _walletOptions.walletNameFocus, enabled: _walletOptions.isEditing, controller: _walletOptions.nameController, maxLines: _nbrLinesName, textAlign: TextAlign.center, - decoration: InputDecoration( + decoration: const InputDecoration( border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, @@ -163,7 +164,7 @@ class CesiumWalletOptions extends StatelessWidget { } if (result.isLoading) { - return Text('Loading'); + return const Text('Loading'); } // List repositories = result.data['viewer']['repositories']['nodes']; @@ -190,7 +191,7 @@ class CesiumWalletOptions extends StatelessWidget { sigmaY: _walletOptions.isBalanceBlur ? 5 : 0), - child: Text('$wBalanceUD', + child: Text(wBalanceUD, style: TextStyle( fontSize: isTall ? 20 : 18, color: Colors.black)), @@ -208,9 +209,9 @@ class CesiumWalletOptions extends StatelessWidget { // ); }, ), - SizedBox(height: 5), + const SizedBox(height: 5), InkWell( - key: Key('displayBalance'), + key: const Key('displayBalance'), onTap: () { _walletOptions.bluringBalance(); }, @@ -220,15 +221,15 @@ class CesiumWalletOptions extends StatelessWidget { : 'assets/walletOptions/icon_oeuil_close.png', )), ]), - SizedBox(width: 0), + const SizedBox(width: 0), Column(children: [ InkWell( - key: Key('renameWallet'), + key: const Key('renameWallet'), onTap: () async { _isNewNameValid = _walletOptions .editWalletName(_walletOptions.walletID); await Future.delayed( - Duration(milliseconds: 30)); + const Duration(milliseconds: 30)); _walletOptions.walletNameFocus.requestFocus(); }, child: ClipRRect( @@ -239,7 +240,7 @@ class CesiumWalletOptions extends StatelessWidget { width: 20, height: 20), )), - SizedBox( + const SizedBox( height: 60, ) ]) @@ -254,11 +255,11 @@ class CesiumWalletOptions extends StatelessWidget { return snapshot.data != null ? Image.memory(snapshot.data, height: isTall ? 300 : 270) - : Text('-', style: TextStyle(fontSize: 20)); + : const Text('-', style: TextStyle(fontSize: 20)); }), SizedBox(height: 15 * ratio), GestureDetector( - key: Key('copyPubkey'), + key: const Key('copyPubkey'), onTap: () { Clipboard.setData( ClipboardData(text: _walletOptions.pubkey.text)); @@ -267,30 +268,29 @@ class CesiumWalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 30), + const SizedBox(width: 30), Image.asset( 'assets/walletOptions/key.png', ), - SizedBox(width: 10), + const SizedBox(width: 10), Text("${shortPubkey.split(':')[0]}:", - style: TextStyle( + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.w800, fontFamily: 'Monospace', color: Colors.black)), Text(shortPubkey.split(':')[1], - style: TextStyle( + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.w800, fontFamily: 'Monospace')), - SizedBox(width: 15), + const SizedBox(width: 15), SizedBox( height: 40, child: ElevatedButton( style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( - borderRadius: - new BorderRadius.circular(8), + borderRadius: BorderRadius.circular(8), ), elevation: 1, primary: orangeC, // background @@ -305,7 +305,7 @@ class CesiumWalletOptions extends StatelessWidget { Image.asset( 'assets/walletOptions/copy-white.png', ), - SizedBox(width: 7), + const SizedBox(width: 7), Text('Copier', style: TextStyle( fontSize: 15, @@ -314,7 +314,7 @@ class CesiumWalletOptions extends StatelessWidget { ]))), SizedBox(height: 10 * ratio), InkWell( - key: Key('displayHistory'), + key: const Key('displayHistory'), onTap: () { _historyProvider.isPubkey(ctx, _walletOptions.pubkey.text, goHistory: true); @@ -322,18 +322,18 @@ class CesiumWalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 30), + const SizedBox(width: 30), Image.asset( 'assets/walletOptions/clock.png', ), - SizedBox(width: 12), - Text('Historique des transactions', + const SizedBox(width: 12), + const Text('Historique des transactions', style: TextStyle(fontSize: 20, color: Colors.black)), ]))), SizedBox(height: 12 * ratio), InkWell( - key: Key('setDefaultWallet'), + key: const Key('setDefaultWallet'), onTap: !_walletOptions.isDefaultWallet ? () { defaultWallet = cesiumWallet; @@ -346,14 +346,14 @@ class CesiumWalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 31), + const SizedBox(width: 31), CircleAvatar( backgroundColor: Colors.grey[ _walletOptions.isDefaultWallet ? 300 : 500], child: Image.asset( 'assets/walletOptions/android-checkmark.png', )), - SizedBox(width: 12), + const SizedBox(width: 12), Text( _walletOptions.isDefaultWallet ? 'Ce portefeuille est celui par defaut' @@ -367,7 +367,7 @@ class CesiumWalletOptions extends StatelessWidget { SizedBox(height: 17 * ratio), if (!_walletOptions.isDefaultWallet) InkWell( - key: Key('deleteWallet'), + key: const Key('deleteWallet'), onTap: !_walletOptions.isDefaultWallet ? () async { await _walletOptions.deleteWallet( @@ -381,12 +381,12 @@ class CesiumWalletOptions extends StatelessWidget { } : null, child: Row(children: [ - SizedBox(width: 33), + const SizedBox(width: 33), Image.asset( 'assets/walletOptions/trash.png', ), - SizedBox(width: 14), - Text('Supprimer ce portefeuille', + const SizedBox(width: 14), + const Text('Supprimer ce portefeuille', style: TextStyle( fontSize: 20, color: Color(0xffD80000))), ])), diff --git a/lib/screens/myWallets/changePin.dart b/lib/screens/myWallets/change_pin.dart similarity index 66% rename from lib/screens/myWallets/changePin.dart rename to lib/screens/myWallets/change_pin.dart index 563b247..2d51a04 100644 --- a/lib/screens/myWallets/changePin.dart +++ b/lib/screens/myWallets/change_pin.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/changePin.dart'; +import 'package:gecko/models/change_pin.dart'; import 'dart:io'; import 'package:provider/provider.dart'; @@ -13,7 +13,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { {Key keyMyWallets, @required this.walletName, @required this.oldPin}) : super(key: keyMyWallets); final String walletName; - final oldPin; + final String oldPin; Directory appPath; NewWallet _newWalletFile; @@ -32,7 +32,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { resizeToAvoidBottomInset: false, appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { _changePin.newPin.text = ''; Navigator.of(context).pop(); @@ -44,7 +44,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { body: Center( child: SafeArea( child: Column(children: [ - SizedBox(height: 80), + const SizedBox(height: 80), Text( 'Choisissez un code secret autogénéré :', textAlign: TextAlign.center, @@ -53,33 +53,31 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { color: Colors.grey[600], fontWeight: FontWeight.w400), ), - SizedBox(height: 30), - Container( - child: Stack( - alignment: Alignment.centerRight, - children: [ - TextField( - enabled: true, - controller: _changePin.newPin, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 30.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - IconButton( - icon: Icon(Icons.replay), - color: orangeC, - onPressed: () async { - _newWalletFile = - await _changePin.changePin(walletName, oldPin); - }, - ), - ], - ), + const SizedBox(height: 30), + Stack( + alignment: Alignment.centerRight, + children: [ + TextField( + enabled: true, + controller: _changePin.newPin, + maxLines: 1, + textAlign: TextAlign.center, + decoration: const InputDecoration(), + style: const TextStyle( + fontSize: 30.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + IconButton( + icon: const Icon(Icons.replay), + color: orangeC, + onPressed: () async { + _newWalletFile = + await _changePin.changePin(walletName, oldPin); + }, + ), + ], ), - SizedBox(height: 30), + const SizedBox(height: 30), SizedBox( width: 200, height: 50, @@ -96,7 +94,8 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { context, _newWalletFile); } : null, - child: Text('Confirmer', style: TextStyle(fontSize: 28))), + child: const Text('Confirmer', + style: TextStyle(fontSize: 28))), ) ]))))); } diff --git a/lib/screens/myWallets/chooseChest.dart b/lib/screens/myWallets/choose_chest.dart similarity index 86% rename from lib/screens/myWallets/chooseChest.dart rename to lib/screens/myWallets/choose_chest.dart index c26ec36..479e0e4 100644 --- a/lib/screens/myWallets/chooseChest.dart +++ b/lib/screens/myWallets/choose_chest.dart @@ -1,7 +1,7 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:flutter/material.dart'; import 'package:gecko/screens/onBoarding/1.dart'; import 'package:carousel_slider/carousel_slider.dart'; @@ -12,6 +12,8 @@ class ChooseChest extends StatelessWidget { TextEditingController tplController = TextEditingController(); CarouselController buttonCarouselController = CarouselController(); + ChooseChest({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,13 +24,13 @@ class ChooseChest extends StatelessWidget { return Scaffold( appBar: AppBar( - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Sélectionner mon coffre'), )), body: SafeArea( child: Column(children: [ - SizedBox(height: 190), + const SizedBox(height: 190), CarouselSlider( carouselController: buttonCarouselController, options: CarouselOptions( @@ -48,10 +50,10 @@ class ChooseChest extends StatelessWidget { Image.asset( 'assets/chests/${i.value.imageName}', ), - SizedBox(height: 30), + const SizedBox(height: 30), Text( i.value.name, - style: TextStyle(fontSize: 21), + style: const TextStyle(fontSize: 21), ), ]); }, @@ -59,13 +61,13 @@ class ChooseChest extends StatelessWidget { }).toList(), ), Image.asset('assets/chests/vector.png'), - SizedBox(height: 15), - Text( + const SizedBox(height: 15), + const Text( 'Choisir un autre\ncoffre', textAlign: TextAlign.center, style: TextStyle(fontSize: 13), ), - SizedBox(height: 80), + const SizedBox(height: 80), SizedBox( width: 400, height: 70, @@ -91,9 +93,9 @@ class ChooseChest extends StatelessWidget { ), ), ), - SizedBox(height: 20), + const SizedBox(height: 20), InkWell( - key: Key('createNewChest'), + key: const Key('createNewChest'), onTap: () { Navigator.push( context, @@ -110,7 +112,7 @@ class ChooseChest extends StatelessWidget { color: orangeC, fontWeight: FontWeight.w600))), )), - SizedBox(height: 10), + const SizedBox(height: 10), ]), )); } diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirm_wallet_storage.dart similarity index 82% rename from lib/screens/myWallets/confirmWalletStorage.dart rename to lib/screens/myWallets/confirm_wallet_storage.dart index 02b0298..c31bbe7 100644 --- a/lib/screens/myWallets/confirmWalletStorage.dart +++ b/lib/screens/myWallets/confirm_wallet_storage.dart @@ -3,9 +3,9 @@ import 'dart:async'; import 'package:dubp/dubp.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:provider/provider.dart'; // ignore: must_be_immutable @@ -19,10 +19,10 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { String generatedMnemonic; NewWallet generatedWallet; - TextEditingController _mnemonicController = TextEditingController(); - TextEditingController _inputRestoreWord = TextEditingController(); + final TextEditingController _mnemonicController = TextEditingController(); + final TextEditingController _inputRestoreWord = TextEditingController(); TextEditingController walletName = TextEditingController(); - FocusNode _wordFocus = FocusNode(); + final FocusNode _wordFocus = FocusNode(); @override Widget build(BuildContext context) { @@ -35,7 +35,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { Provider.of(context); final int _currentChest = _myWalletProvider.getCurrentChest(); - this._mnemonicController.text = generatedMnemonic; + _mnemonicController.text = generatedMnemonic; return WillPopScope( onWillPop: () { _generateWalletProvider.isAskedWordValid = false; @@ -46,20 +46,20 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { resizeToAvoidBottomInset: false, appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { Navigator.of(context).pop(); _generateWalletProvider.isAskedWordValid = false; _generateWalletProvider.askedWordColor = Colors.black; }), - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Enregistrer ce trousseau'), )), body: Center( child: Column(children: [ - SizedBox(height: 15), - Container( + const SizedBox(height: 15), + SizedBox( width: 360, child: Text( 'Quel est le ${_generateWalletProvider.nbrWord + 1}ème mot de votre phrase de restauration ?', @@ -70,11 +70,11 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { fontWeight: FontWeight.w400), )), TextFormField( - key: Key('askedWord'), + key: const Key('askedWord'), focusNode: _wordFocus, autofocus: true, enabled: !_generateWalletProvider.isAskedWordValid, - controller: this._inputRestoreWord, + controller: _inputRestoreWord, textInputAction: TextInputAction.next, onChanged: (value) { _generateWalletProvider.checkAskedWord( @@ -82,13 +82,13 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { }, maxLines: 1, textAlign: TextAlign.center, - decoration: InputDecoration(), + decoration: const InputDecoration(), style: TextStyle( fontSize: 30.0, color: _generateWalletProvider.askedWordColor, fontWeight: FontWeight.w500)), - SizedBox(height: 12), - Container( + const SizedBox(height: 12), + SizedBox( width: 360, child: Text( 'Choisissez un nom pour votre premier portefeuille :', @@ -99,21 +99,21 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { fontWeight: FontWeight.w400), )), TextFormField( - key: Key('walletName'), + key: const Key('walletName'), focusNode: _generateWalletProvider.walletNameFocus, inputFormatters: [ FilteringTextInputFormatter.allow( RegExp('[A-Za-z|0-9|\\-|_| ]')), ], - controller: this.walletName, + controller: walletName, textInputAction: TextInputAction.next, onChanged: (v) { _generateWalletProvider.nameChanged(); }, maxLines: 1, textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( + decoration: const InputDecoration(), + style: const TextStyle( fontSize: 30.0, color: Colors.black, fontWeight: FontWeight.w500)), @@ -124,7 +124,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { width: 200, height: 50, child: ElevatedButton( - key: Key('confirmStorage'), + key: const Key('confirmStorage'), style: ElevatedButton.styleFrom( elevation: 12, primary: Colors @@ -133,7 +133,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { ), onPressed: (_generateWalletProvider .isAskedWordValid && - this.walletName.text != '') + walletName.text != '') ? () { _generateWalletProvider.storeHDWChest( generatedWallet, @@ -154,12 +154,12 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { context, ModalRoute.withName('/')); } : null, - child: Text('Confirmer', + child: const Text('Confirmer', style: TextStyle(fontSize: 28))), ))), - SizedBox(height: 70), - Text('TRICHE PENDANT ALPHA: ' + this._mnemonicController.text, - style: TextStyle( + const SizedBox(height: 70), + Text('TRICHE PENDANT ALPHA: ' + _mnemonicController.text, + style: const TextStyle( fontSize: 10.0, color: Colors.black, fontWeight: FontWeight.normal)), diff --git a/lib/screens/myWallets/generateWallets.dart b/lib/screens/myWallets/generate_wallets.dart similarity index 70% rename from lib/screens/myWallets/generateWallets.dart rename to lib/screens/myWallets/generate_wallets.dart index b1d623e..8b7bd5e 100644 --- a/lib/screens/myWallets/generateWallets.dart +++ b/lib/screens/myWallets/generate_wallets.dart @@ -1,7 +1,7 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/screens/myWallets/confirmWalletStorage.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/screens/myWallets/confirm_wallet_storage.dart'; import 'package:flutter/material.dart'; import 'package:printing/printing.dart'; import 'package:provider/provider.dart'; @@ -15,8 +15,10 @@ class GenerateWalletsScreen extends StatelessWidget { String currentText = ""; var pinColor = Colors.grey[300]; - GlobalKey _toolTipSentence = GlobalKey(); - GlobalKey _toolTipSecret = GlobalKey(); + final GlobalKey _toolTipSentence = GlobalKey(); + final GlobalKey _toolTipSecret = GlobalKey(); + + GenerateWalletsScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -27,18 +29,18 @@ class GenerateWalletsScreen extends StatelessWidget { return Scaffold( appBar: AppBar( - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Générer un trousseau'), )), - floatingActionButton: Container( + floatingActionButton: SizedBox( height: 80.0, width: 80.0, child: FittedBox( child: FloatingActionButton( heroTag: "buttonGenerateWallet", onPressed: () => _generateWalletProvider.generateMnemonic(), - child: Container( + child: SizedBox( height: 40.0, width: 40.0, child: Icon(Icons.replay, color: Colors.grey[850]), @@ -49,7 +51,7 @@ class GenerateWalletsScreen extends StatelessWidget { body: Builder( builder: (ctx) => SafeArea( child: Column(children: [ - SizedBox(height: 20), + const SizedBox(height: 20), toolTips(_toolTipSentence, 'Phrase de restauration:', "Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"), TextField( @@ -57,45 +59,43 @@ class GenerateWalletsScreen extends StatelessWidget { controller: _generateWalletProvider.mnemonicController, maxLines: 3, textAlign: TextAlign.center, - decoration: InputDecoration( + decoration: const InputDecoration( contentPadding: EdgeInsets.all(15.0), ), - style: TextStyle( + style: const TextStyle( fontSize: 22.0, color: Colors.black, fontWeight: FontWeight.w400)), - SizedBox(height: 8), + const SizedBox(height: 8), toolTips(_toolTipSecret, 'Code secret:', "Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"), - Container( - child: Stack( - alignment: Alignment.centerRight, - children: [ - TextField( - key: Key('generatedPin'), - enabled: false, - controller: _generateWalletProvider.pin, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 30.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - IconButton( - icon: Icon(Icons.replay), - color: orangeC, - onPressed: () { - _generateWalletProvider.changePinCode( - reload: false); - }, - ), - ], - ), + Stack( + alignment: Alignment.centerRight, + children: [ + TextField( + key: const Key('generatedPin'), + enabled: false, + controller: _generateWalletProvider.pin, + maxLines: 1, + textAlign: TextAlign.center, + decoration: const InputDecoration(), + style: const TextStyle( + fontSize: 30.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + IconButton( + icon: const Icon(Icons.replay), + color: orangeC, + onPressed: () { + _generateWalletProvider.changePinCode( + reload: false); + }, + ), + ], ), - SizedBox(height: 20), + const SizedBox(height: 20), ElevatedButton( - key: Key('storeKeychain'), + key: const Key('storeKeychain'), style: ElevatedButton.styleFrom( primary: yellowC, // background onPrimary: Colors.black, // foreground @@ -117,9 +117,9 @@ class GenerateWalletsScreen extends StatelessWidget { ); } : null, - child: Text('Enregistrer ce trousseau', + child: const Text('Enregistrer ce trousseau', style: TextStyle(fontSize: 20))), - SizedBox(height: 20), + const SizedBox(height: 20), GestureDetector( onTap: () { Navigator.push( @@ -130,7 +130,7 @@ class GenerateWalletsScreen extends StatelessWidget { }), ); }, - child: Icon(Icons.print)) + child: const Icon(Icons.print)) ]), ))); } @@ -142,21 +142,21 @@ class GenerateWalletsScreen extends StatelessWidget { _toolTip.ensureTooltipVisible(); }, child: Tooltip( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), key: _key, - showDuration: Duration(seconds: 5), + showDuration: const Duration(seconds: 5), message: _message, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(width: 20), + const SizedBox(width: 20), Column(children: [ SizedBox( width: 30, height: 25, child: Icon(Icons.info_outline, size: 22, color: orangeC)), - SizedBox(height: 1) + const SizedBox(height: 1) ]), Text( _text, @@ -165,14 +165,14 @@ class GenerateWalletsScreen extends StatelessWidget { color: Colors.grey[600], fontWeight: FontWeight.w400), ), - SizedBox(width: 45) + const SizedBox(width: 45) ]))); } } // ignore: must_be_immutable class PrintWallet extends StatelessWidget { - PrintWallet(this.sentence); + const PrintWallet(this.sentence, {Key key}) : super(key: key); final String sentence; @@ -182,7 +182,7 @@ class PrintWallet extends StatelessWidget { Provider.of(context); return MaterialApp( home: Scaffold( - appBar: AppBar(title: Text('Imprimer ce trousseau')), + appBar: AppBar(title: const Text('Imprimer ce trousseau')), body: PdfPreview( build: (format) => _generateWalletProvider.printWallet(sentence), ), diff --git a/lib/screens/myWallets/importWallet.dart b/lib/screens/myWallets/import_wallet.dart similarity index 76% rename from lib/screens/myWallets/importWallet.dart rename to lib/screens/myWallets/import_wallet.dart index d7c7b55..ed33ff4 100644 --- a/lib/screens/myWallets/importWallet.dart +++ b/lib/screens/myWallets/import_wallet.dart @@ -1,13 +1,15 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; +import 'package:gecko/models/generate_wallets.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:provider/provider.dart'; class ImportWalletScreen extends StatelessWidget { + const ImportWalletScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -28,25 +30,24 @@ class ImportWalletScreen extends StatelessWidget { child: Scaffold( appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { _generateWalletProvider.resetImportView(); Navigator.of(context).pop(); }), - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Importer un portefeuille'), )), body: Builder( builder: (ctx) => SafeArea( child: Column(children: [ - SizedBox(height: 20), + const SizedBox(height: 20), TextFormField( onChanged: (text) { - if (_debounce?.isActive ?? false) - // _generateWalletProvider.canImport = false; - // _generateWalletProvider.reloadBuild(); + if (_debounce?.isActive ?? false) { _debounce.cancel(); + } _debounce = Timer(const Duration(milliseconds: 200), () { _generateWalletProvider @@ -77,13 +78,12 @@ class ImportWalletScreen extends StatelessWidget { ), ), ), - SizedBox(height: 15), + const SizedBox(height: 15), TextFormField( onChanged: (text) { - if (_debounce?.isActive ?? false) - // _generateWalletProvider.canImport = false; - // _generateWalletProvider.reloadBuild(); + if (_debounce?.isActive ?? false) { _debounce.cancel(); + } _debounce = Timer(const Duration(milliseconds: 200), () { _generateWalletProvider @@ -115,7 +115,7 @@ class ImportWalletScreen extends StatelessWidget { ), ), ), - SizedBox(height: 15), + const SizedBox(height: 15), GestureDetector( onTap: () { Clipboard.setData(ClipboardData( @@ -125,41 +125,39 @@ class ImportWalletScreen extends StatelessWidget { }, child: Text( _generateWalletProvider.cesiumPubkey.text, - style: TextStyle( + style: const TextStyle( fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.bold, fontFamily: 'Monospace'), )), - SizedBox(height: 20), + const SizedBox(height: 20), toolTips(_toolTipSecret, 'Code secret:', "Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"), - Container( - child: Stack( - alignment: Alignment.centerRight, - children: [ - TextField( - enabled: false, - controller: _generateWalletProvider.pin, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 30.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - IconButton( - icon: Icon(Icons.replay), - color: orangeC, - onPressed: () { - _generateWalletProvider.changePinCode( - reload: true); - }, - ), - ], - ), + Stack( + alignment: Alignment.centerRight, + children: [ + TextField( + enabled: false, + controller: _generateWalletProvider.pin, + maxLines: 1, + textAlign: TextAlign.center, + decoration: const InputDecoration(), + style: const TextStyle( + fontSize: 30.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + IconButton( + icon: const Icon(Icons.replay), + color: orangeC, + onPressed: () { + _generateWalletProvider.changePinCode( + reload: true); + }, + ), + ], ), - SizedBox(height: 30), + const SizedBox(height: 30), ElevatedButton( style: ElevatedButton.styleFrom( primary: yellowC, // background @@ -180,7 +178,7 @@ class ImportWalletScreen extends StatelessWidget { }); } : null, - child: Text('Importer ce portefeuille Cesium', + child: const Text('Importer ce portefeuille Cesium', style: TextStyle(fontSize: 20))), ]), )))); @@ -193,21 +191,21 @@ class ImportWalletScreen extends StatelessWidget { _toolTip.ensureTooltipVisible(); }, child: Tooltip( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), key: _key, - showDuration: Duration(seconds: 5), + showDuration: const Duration(seconds: 5), message: _message, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(width: 20), + const SizedBox(width: 20), Column(children: [ SizedBox( width: 30, height: 25, child: Icon(Icons.info_outline, size: 22, color: orangeC)), - SizedBox(height: 1) + const SizedBox(height: 1) ]), Text( _text, @@ -216,7 +214,7 @@ class ImportWalletScreen extends StatelessWidget { color: Colors.grey[600], fontWeight: FontWeight.w400), ), - SizedBox(width: 45) + const SizedBox(width: 45) ]))); } } diff --git a/lib/screens/myWallets/unlockingWallet.dart b/lib/screens/myWallets/unlocking_wallet.dart similarity index 87% rename from lib/screens/myWallets/unlockingWallet.dart rename to lib/screens/myWallets/unlocking_wallet.dart index 3307717..7e810a2 100644 --- a/lib/screens/myWallets/unlockingWallet.dart +++ b/lib/screens/myWallets/unlocking_wallet.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:gecko/models/history.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:provider/provider.dart'; @@ -22,7 +22,7 @@ class UnlockingWallet extends StatelessWidget { StreamController errorController; final formKey = GlobalKey(); bool hasError = false; - var pinColor = Color(0xffF9F9F1); + var pinColor = const Color(0xffF9F9F1); var walletPin = ''; String resultPay; @@ -42,11 +42,11 @@ class UnlockingWallet extends StatelessWidget { // backgroundColor: Colors.brown[600], body: SafeArea( child: Column(children: [ - SizedBox(height: 20), + const SizedBox(height: 20), Expanded( child: Column(children: [ - SizedBox(height: 150), - Text( + const SizedBox(height: 150), + const Text( 'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.', textAlign: TextAlign.center, style: TextStyle( @@ -54,7 +54,7 @@ class UnlockingWallet extends StatelessWidget { color: Colors.black, fontWeight: FontWeight.w400), ), - SizedBox(height: 50), + const SizedBox(height: 50), pinForm(context, _pinLenght, wallet.number, wallet.derivation), ]), ), @@ -106,14 +106,14 @@ class UnlockingWallet extends StatelessWidget { activeFillColor: hasError ? Colors.blueAccent : Colors.black, ), cursorColor: Colors.black, - animationDuration: Duration(milliseconds: 300), - textStyle: TextStyle(fontSize: 20, height: 1.6), - backgroundColor: Color(0xffF9F9F1), + animationDuration: const Duration(milliseconds: 300), + textStyle: const TextStyle(fontSize: 20, height: 1.6), + backgroundColor: const Color(0xffF9F9F1), enableActiveFill: false, errorAnimationController: errorController, controller: _enterPin, keyboardType: TextInputType.text, - boxShadows: [ + boxShadows: const [ BoxShadow( offset: Offset(0, 1), color: Colors.black12, @@ -124,7 +124,7 @@ class UnlockingWallet extends StatelessWidget { log.d("Completed"); _myWalletProvider.pinCode = _pin; final resultWallet = await _walletOptions.readLocalWallet( - context, this.wallet, _pin.toUpperCase(), _pinLenght); + context, wallet, _pin.toUpperCase(), _pinLenght); // _myWalletProvider.pinCode = _pin.toUpperCase(); _myWalletProvider.pinLenght = _pinLenght; @@ -140,7 +140,6 @@ class UnlockingWallet extends StatelessWidget { if (action == "mywallets") { Navigator.pushNamed(formKey.currentContext, '/mywallets'); } else if (action == "pay") { - print("Go payments"); resultPay = await _historyProvider.pay(context, _pin.toUpperCase()); await _paymentsResult(context); @@ -148,8 +147,8 @@ class UnlockingWallet extends StatelessWidget { } }, onChanged: (value) { - if (pinColor != Color(0xFFA4B600)) { - pinColor = Color(0xFFA4B600); + if (pinColor != const Color(0xFFA4B600)) { + pinColor = const Color(0xFFA4B600); } }, )), @@ -165,10 +164,10 @@ class UnlockingWallet extends StatelessWidget { title: Text(resultPay == "Success" ? 'Paiement effecuté avec succès !' : "Une erreur s'est produite lors du paiement"), - content: SingleChildScrollView(child: Text('')), + content: const SingleChildScrollView(child: Text('')), actions: [ TextButton( - child: Text("OK"), + child: const Text("OK"), onPressed: () { Navigator.popUntil( context, diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/wallet_options.dart similarity index 88% rename from lib/screens/myWallets/walletOptions.dart rename to lib/screens/myWallets/wallet_options.dart index dfc28b3..7efbf30 100644 --- a/lib/screens/myWallets/walletOptions.dart +++ b/lib/screens/myWallets/wallet_options.dart @@ -3,10 +3,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/history.dart'; -import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/queries.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; import 'package:flutter/services.dart'; @@ -42,8 +42,9 @@ class WalletOptions extends StatelessWidget { _walletOptions.nameController.text.length >= 15 ? _nbrLinesName = 2 : _nbrLinesName = 1; - if (_walletOptions.nameController.text.length >= 26 && isTall) + if (_walletOptions.nameController.text.length >= 26 && isTall) { _nbrLinesName = 3; + } _walletOptions.walletID = [0, wallet.number]; @@ -71,7 +72,7 @@ class WalletOptions extends StatelessWidget { resizeToAvoidBottomInset: false, appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { _walletOptions.isEditing = false; _walletOptions.isBalanceBlur = true; @@ -98,11 +99,11 @@ class WalletOptions extends StatelessWidget { end: Alignment.bottomCenter, colors: [ yellowC, - Color(0xfffafafa), + const Color(0xfffafafa), ], )), child: Row(children: [ - SizedBox(width: 25), + const SizedBox(width: 25), InkWell( onTap: () async { await _walletOptions.changeAvatar(); @@ -119,7 +120,7 @@ class WalletOptions extends StatelessWidget { Image.asset( 'assets/walletOptions/camera.png', ), - SizedBox(height: 100) + const SizedBox(height: 100) ])), Column(children: [ Row(children: [ @@ -127,14 +128,14 @@ class WalletOptions extends StatelessWidget { SizedBox( width: 260, child: TextField( - key: Key('walletName'), + key: const Key('walletName'), autofocus: false, focusNode: _walletOptions.walletNameFocus, enabled: _walletOptions.isEditing, controller: _walletOptions.nameController, maxLines: _nbrLinesName, textAlign: TextAlign.center, - decoration: InputDecoration( + decoration: const InputDecoration( border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, @@ -163,7 +164,7 @@ class WalletOptions extends StatelessWidget { } if (result.isLoading) { - return Text('Loading'); + return const Text('Loading'); } // List repositories = result.data['viewer']['repositories']['nodes']; @@ -190,7 +191,7 @@ class WalletOptions extends StatelessWidget { sigmaY: _walletOptions.isBalanceBlur ? 5 : 0), - child: Text('$wBalanceUD', + child: Text(wBalanceUD, style: TextStyle( fontSize: isTall ? 20 : 18, color: Colors.black)), @@ -208,9 +209,9 @@ class WalletOptions extends StatelessWidget { // ); }, ), - SizedBox(height: 5), + const SizedBox(height: 5), InkWell( - key: Key('displayBalance'), + key: const Key('displayBalance'), onTap: () { _walletOptions.bluringBalance(); }, @@ -220,15 +221,15 @@ class WalletOptions extends StatelessWidget { : 'assets/walletOptions/icon_oeuil_close.png', )), ]), - SizedBox(width: 0), + const SizedBox(width: 0), Column(children: [ InkWell( - key: Key('renameWallet'), + key: const Key('renameWallet'), onTap: () async { _isNewNameValid = _walletOptions .editWalletName(_walletOptions.walletID); await Future.delayed( - Duration(milliseconds: 30)); + const Duration(milliseconds: 30)); _walletOptions.walletNameFocus.requestFocus(); }, child: ClipRRect( @@ -239,7 +240,7 @@ class WalletOptions extends StatelessWidget { width: 20, height: 20), )), - SizedBox( + const SizedBox( height: 60, ) ]) @@ -254,11 +255,11 @@ class WalletOptions extends StatelessWidget { return snapshot.data != null ? Image.memory(snapshot.data, height: isTall ? 300 : 270) - : Text('-', style: TextStyle(fontSize: 20)); + : const Text('-', style: TextStyle(fontSize: 20)); }), SizedBox(height: 15 * ratio), GestureDetector( - key: Key('copyPubkey'), + key: const Key('copyPubkey'), onTap: () { Clipboard.setData( ClipboardData(text: _walletOptions.pubkey.text)); @@ -267,30 +268,29 @@ class WalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 30), + const SizedBox(width: 30), Image.asset( 'assets/walletOptions/key.png', ), - SizedBox(width: 10), + const SizedBox(width: 10), Text("${shortPubkey.split(':')[0]}:", - style: TextStyle( + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.w800, fontFamily: 'Monospace', color: Colors.black)), Text(shortPubkey.split(':')[1], - style: TextStyle( + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.w800, fontFamily: 'Monospace')), - SizedBox(width: 15), + const SizedBox(width: 15), SizedBox( height: 40, child: ElevatedButton( style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( - borderRadius: - new BorderRadius.circular(8), + borderRadius: BorderRadius.circular(8), ), elevation: 1, primary: orangeC, // background @@ -305,7 +305,7 @@ class WalletOptions extends StatelessWidget { Image.asset( 'assets/walletOptions/copy-white.png', ), - SizedBox(width: 7), + const SizedBox(width: 7), Text('Copier', style: TextStyle( fontSize: 15, @@ -314,7 +314,7 @@ class WalletOptions extends StatelessWidget { ]))), SizedBox(height: 10 * ratio), InkWell( - key: Key('displayHistory'), + key: const Key('displayHistory'), onTap: () { _historyProvider.isPubkey(ctx, _walletOptions.pubkey.text, goHistory: true); @@ -322,18 +322,18 @@ class WalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 30), + const SizedBox(width: 30), Image.asset( 'assets/walletOptions/clock.png', ), - SizedBox(width: 12), - Text('Historique des transactions', + const SizedBox(width: 12), + const Text('Historique des transactions', style: TextStyle(fontSize: 20, color: Colors.black)), ]))), SizedBox(height: 12 * ratio), InkWell( - key: Key('setDefaultWallet'), + key: const Key('setDefaultWallet'), onTap: !_walletOptions.isDefaultWallet ? () { defaultWallet = wallet; @@ -346,14 +346,14 @@ class WalletOptions extends StatelessWidget { child: SizedBox( height: 50, child: Row(children: [ - SizedBox(width: 31), + const SizedBox(width: 31), CircleAvatar( backgroundColor: Colors.grey[ _walletOptions.isDefaultWallet ? 300 : 500], child: Image.asset( 'assets/walletOptions/android-checkmark.png', )), - SizedBox(width: 12), + const SizedBox(width: 12), Text( _walletOptions.isDefaultWallet ? 'Ce portefeuille est celui par defaut' @@ -367,7 +367,7 @@ class WalletOptions extends StatelessWidget { SizedBox(height: 17 * ratio), if (!_walletOptions.isDefaultWallet) InkWell( - key: Key('deleteWallet'), + key: const Key('deleteWallet'), onTap: !_walletOptions.isDefaultWallet ? () async { await _walletOptions.deleteWallet( @@ -381,12 +381,12 @@ class WalletOptions extends StatelessWidget { } : null, child: Row(children: [ - SizedBox(width: 33), + const SizedBox(width: 33), Image.asset( 'assets/walletOptions/trash.png', ), - SizedBox(width: 14), - Text('Supprimer ce portefeuille', + const SizedBox(width: 14), + const Text('Supprimer ce portefeuille', style: TextStyle( fontSize: 20, color: Color(0xffD80000))), ])), diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/wallets_home.dart similarity index 83% rename from lib/screens/myWallets/walletsHome.dart rename to lib/screens/myWallets/wallets_home.dart index 350b771..81b5be9 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -1,21 +1,23 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/chestData.dart'; -import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/chest_data.dart'; +import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/queries.dart'; -import 'package:gecko/models/walletData.dart'; -import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/models/wallet_options.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/screens/commonElements.dart'; -import 'package:gecko/screens/myWallets/chooseChest.dart'; -import 'package:gecko/screens/myWallets/walletOptions.dart'; -import 'package:gecko/screens/onBoarding/0_noKeychainFound.dart'; +import 'package:gecko/screens/common_elements.dart'; +import 'package:gecko/screens/myWallets/choose_chest.dart'; +import 'package:gecko/screens/myWallets/wallet_options.dart'; +import 'package:gecko/screens/onBoarding/0_no_keychain_found.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; class WalletsHome extends StatelessWidget { final _derivationKey = GlobalKey(); + WalletsHome({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -43,7 +45,7 @@ class WalletsHome extends StatelessWidget { child: Scaffold( appBar: AppBar( leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), + icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { Navigator.popUntil( context, @@ -51,12 +53,13 @@ class WalletsHome extends StatelessWidget { ); }), title: Text(_currentChest.name, - key: Key('myWallets'), style: TextStyle(color: Colors.grey[850])), - backgroundColor: Color(0xffFFD58D), + key: const Key('myWallets'), + style: TextStyle(color: Colors.grey[850])), + backgroundColor: const Color(0xffFFD58D), ), body: SafeArea( child: !isWalletsExists - ? NoKeyChainScreen() + ? const NoKeyChainScreen() : _currentChest.isCesium ? cesiumWalletOptions(context) : myWalletsTiles(context), @@ -66,14 +69,14 @@ class WalletsHome extends StatelessWidget { } Widget cesiumWalletOptions(BuildContext context) { - return Column(children: [ + return Column(children: const [ Center(child: Text('This is a Cesium wallet')), ]); } Widget chestOptions(BuildContext context) { return Column(children: [ - SizedBox(height: 50), + const SizedBox(height: 50), SizedBox( height: 120, width: 445, @@ -87,7 +90,7 @@ class WalletsHome extends StatelessWidget { onPrimary: Colors.black, // foreground ), onPressed: () => null, - label: Text( + label: const Text( " Paramétrer ce coffre", style: TextStyle( fontSize: 25, @@ -96,7 +99,7 @@ class WalletsHome extends StatelessWidget { ), ), )), - SizedBox(height: 30), + const SizedBox(height: 30), SizedBox( height: 120, width: 445, @@ -113,7 +116,7 @@ class WalletsHome extends StatelessWidget { return ChooseChest(); }), ), - label: Text( + label: const Text( " Changer de coffre", style: TextStyle( fontSize: 25, @@ -122,7 +125,7 @@ class WalletsHome extends StatelessWidget { ), ), )), - SizedBox(height: 30) + const SizedBox(height: 30) ]); } @@ -135,12 +138,12 @@ class WalletsHome extends StatelessWidget { final bool isWalletsExists = _myWalletProvider.checkIfWalletExist(); if (!isWalletsExists) { - return Text(''); + return const Text(''); } if (_myWalletProvider.listWallets.isEmpty) { return Expanded( - child: Column(children: [ + child: Column(children: const [ Center( child: Text( 'Veuillez générer votre premier portefeuille', @@ -154,9 +157,9 @@ class WalletsHome extends StatelessWidget { _myWalletProvider.getDefaultWallet(configBox.get('currentChest')); return CustomScrollView(slivers: [ - SliverToBoxAdapter(child: SizedBox(height: 20)), + const SliverToBoxAdapter(child: SizedBox(height: 20)), SliverGrid.count( - key: Key('listWallets'), + key: const Key('listWallets'), crossAxisCount: 2, childAspectRatio: 1, crossAxisSpacing: 0, @@ -164,7 +167,7 @@ class WalletsHome extends StatelessWidget { children: [ for (WalletData _repository in _listWallets) Padding( - padding: EdgeInsets.all(16), + padding: const EdgeInsets.all(16), child: GestureDetector( onTap: () async { await _walletOptions.readLocalWallet( @@ -185,14 +188,15 @@ class WalletsHome extends StatelessWidget { // })); }, child: ClipOvalShadow( - shadow: Shadow( + shadow: const Shadow( color: Colors.transparent, offset: Offset(0, 0), blurRadius: 5, ), clipper: CustomClipperOval(), child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(12)), + borderRadius: + const BorderRadius.all(Radius.circular(12)), child: Column(children: [ Expanded( child: Container( @@ -203,7 +207,7 @@ class WalletsHome extends StatelessWidget { radius: 0.6, colors: [ Colors.green[400], - Color(0xFFE7E7A6), + const Color(0xFFE7E7A6), ], )), child: @@ -217,29 +221,30 @@ class WalletsHome extends StatelessWidget { )), // balanceBuilder(context, _walletOptions.pubkey.text), ListTile( - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(12))), // contentPadding: const EdgeInsets.only(left: 7.0), tileColor: _repository.id()[1] == defaultWallet.id()[1] ? orangeC - : Color(0xffFFD58D), + : const Color(0xffFFD58D), // leading: Text('IMAGE'), // subtitle: Text(_repository.split(':')[3], // style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')), title: Center( child: Padding( - padding: EdgeInsets.symmetric(horizontal: 5), + padding: + const EdgeInsets.symmetric(horizontal: 5), child: Text( - '${_repository.name}', + _repository.name, textAlign: TextAlign.center, style: TextStyle( fontSize: 17.0, color: _repository.id()[1] == defaultWallet.id()[1] - ? Color(0xffF9F9F1) + ? const Color(0xffF9F9F1) : Colors.black, fontStyle: FontStyle.italic), ), @@ -292,7 +297,7 @@ class WalletsHome extends StatelessWidget { } if (result.isLoading) { - return Text('Loading'); + return const Text('Loading'); } String wBalanceUD; if (result.data['balance'] == null) { @@ -310,13 +315,13 @@ class WalletsHome extends StatelessWidget { Widget addNewDerivation(context) { return Padding( - padding: EdgeInsets.all(16), + padding: const EdgeInsets.all(16), child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(12)), + borderRadius: const BorderRadius.all(Radius.circular(12)), child: Column(children: [ Expanded( child: InkWell( - key: Key('addDerivation'), + key: const Key('addDerivation'), onTap: () { showDialog( context: context, @@ -328,7 +333,7 @@ class WalletsHome extends StatelessWidget { width: double.infinity, height: double.infinity, decoration: BoxDecoration(color: floattingYellow), - child: Center( + child: const Center( child: Text( '+', style: TextStyle( @@ -355,21 +360,21 @@ class WalletsHome extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text('Nom du portefeuille:'), + const Text('Nom du portefeuille:'), Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: TextFormField( - key: Key('DerivationNameKey'), + key: const Key('DerivationNameKey'), controller: _newDerivationName, textAlign: TextAlign.center, autofocus: true, ), ), - SizedBox(height: 20), + const SizedBox(height: 20), Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( - key: Key('validDerivation'), + key: const Key('validDerivation'), style: ElevatedButton.styleFrom( elevation: 1, primary: yellowC, // background @@ -381,7 +386,7 @@ class WalletsHome extends StatelessWidget { context, _newDerivationName.text) .then((_) => _newDerivationName.text == ''); }, - child: Text("Créer")), + child: const Text("Créer")), ) ], ), @@ -402,7 +407,7 @@ class CustomClipperOval extends CustomClipper { @override Rect getClip(Size size) { return Rect.fromCircle( - center: new Offset(size.width / 2, size.width / 2), + center: Offset(size.width / 2, size.width / 2), radius: size.width / 2 + 3); } @@ -417,20 +422,21 @@ class ClipOvalShadow extends StatelessWidget { final CustomClipper clipper; final Widget child; - ClipOvalShadow({ + const ClipOvalShadow({ + Key key, @required this.shadow, @required this.clipper, @required this.child, - }); + }) : super(key: key); @override Widget build(BuildContext context) { return CustomPaint( painter: _ClipOvalShadowPainter( - clipper: this.clipper, - shadow: this.shadow, + clipper: clipper, + shadow: shadow, ), - child: ClipRect(child: child, clipper: this.clipper), + child: ClipRect(child: child, clipper: clipper), ); } } @@ -444,7 +450,7 @@ class _ClipOvalShadowPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { var paint = shadow.toPaint(); - var clipRect = clipper.getClip(size).shift(Offset(0, 0)); + var clipRect = clipper.getClip(size).shift(const Offset(0, 0)); canvas.drawOval(clipRect, paint); } diff --git a/lib/screens/onBoarding/0_noKeychainFound.dart b/lib/screens/onBoarding/0_no_keychain_found.dart similarity index 79% rename from lib/screens/onBoarding/0_noKeychainFound.dart rename to lib/screens/onBoarding/0_no_keychain_found.dart index c69d4d6..31745a7 100644 --- a/lib/screens/onBoarding/0_noKeychainFound.dart +++ b/lib/screens/onBoarding/0_no_keychain_found.dart @@ -1,16 +1,14 @@ +// ignore_for_file: file_names import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; -import 'package:gecko/screens/myWallets/importWallet.dart'; +import 'package:gecko/screens/common_elements.dart'; +import 'package:gecko/screens/myWallets/import_wallet.dart'; import 'package:gecko/screens/onBoarding/1.dart'; -// import 'package:gecko/models/home.dart'; -// import 'package:provider/provider.dart'; -// ignore: must_be_immutable class NoKeyChainScreen extends StatelessWidget { - TextEditingController tplController = TextEditingController(); + const NoKeyChainScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -25,16 +23,16 @@ class NoKeyChainScreen extends StatelessWidget { common.onboardingProgressBar(context, 'Mes portefeuilles', 0), common.bubbleSpeak( "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.", - textKey: Key('textOnboarding')), - SizedBox(height: 90), + textKey: const Key('textOnboarding')), + const SizedBox(height: 90), Container( child: ClipOval( child: Material( - color: Color(0xffFFD58D), // button color + color: const Color(0xffFFD58D), // button color child: InkWell( - key: Key('goStep1'), + key: const Key('goStep1'), splashColor: orangeC, // inkwell color - child: Padding( + child: const Padding( padding: EdgeInsets.all(8), child: Image( image: AssetImage('assets/onBoarding/wallet.png'), @@ -47,7 +45,7 @@ class NoKeyChainScreen extends StatelessWidget { }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -59,8 +57,8 @@ class NoKeyChainScreen extends StatelessWidget { ], ), ), - SizedBox(height: 15), - Text( + const SizedBox(height: 15), + const Text( "Créer un nouveau\nportefeuille", textAlign: TextAlign.center, style: TextStyle( @@ -68,15 +66,15 @@ class NoKeyChainScreen extends StatelessWidget { fontSize: 16, fontWeight: FontWeight.w500), ), - SizedBox(height: 70), + const SizedBox(height: 70), Container( child: ClipOval( child: Material( - color: Color(0xffFFD58D), // button color + color: const Color(0xffFFD58D), // button color child: InkWell( splashColor: orangeC, // inkwell color child: Padding( - padding: EdgeInsets.all(12), + padding: const EdgeInsets.all(12), child: // Image( // image: AssetImage('assets/cesium_bw3.png'), @@ -86,11 +84,11 @@ class NoKeyChainScreen extends StatelessWidget { ), onTap: () { Navigator.push(context, - SlideLeftRoute(page: ImportWalletScreen())); + SlideLeftRoute(page: const ImportWalletScreen())); }), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ @@ -102,8 +100,8 @@ class NoKeyChainScreen extends StatelessWidget { ], ), ), - SizedBox(height: 10), - Text( + const SizedBox(height: 10), + const Text( "Importer un\nportefeuille Cesium", textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontSize: 13), diff --git a/lib/screens/onBoarding/1.dart b/lib/screens/onBoarding/1.dart index d58c8a3..6cbd97c 100644 --- a/lib/screens/onBoarding/1.dart +++ b/lib/screens/onBoarding/1.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/2.dart'; // import 'package:gecko/models/home.dart'; // import 'package:provider/provider.dart'; @@ -11,6 +13,8 @@ class OnboardingStepOne extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 1; + OnboardingStepOne({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -24,8 +28,8 @@ class OnboardingStepOne extends StatelessWidget { context, 'Nouveau portefeuilles', progress), common.bubbleSpeak( "Il semblerait que vous n’ayez pas encore de trousseau.\n\nUn trousseau vous permet de gérer un ou plusieurs portefeuilles.", - textKey: Key('step1')), - SizedBox(height: 90), + textKey: const Key('step1')), + const SizedBox(height: 90), Image.asset( 'assets/onBoarding/keys-and-wallets-horizontal.png', height: 200, @@ -37,7 +41,7 @@ class OnboardingStepOne extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep2'), + key: const Key('goStep2'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -49,10 +53,10 @@ class OnboardingStepOne extends StatelessWidget { FaderTransition( page: OnboardingStepTwo(), isFast: true)); }, - child: Text('Créer mon trousseau', + child: const Text('Créer mon trousseau', style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart index 12c8211..8a92869 100644 --- a/lib/screens/onBoarding/10.dart +++ b/lib/screens/onBoarding/10.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/11.dart'; // ignore: must_be_immutable @@ -9,6 +11,8 @@ class OnboardingStepTwelve extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 9; + OnboardingStepTwelve({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,9 +26,9 @@ class OnboardingStepTwelve extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Si un jour vous changez de téléphone, votre code secret sera différent, mais il vous suffira de me redonner votre phrase de restauration pour recréer votre trousseau.", - textKey: Key('step10'), + textKey: const Key('step10'), ), - SizedBox(height: 10), + const SizedBox(height: 10), Image.asset( 'assets/onBoarding/plusieurs-codes-secrets-un-trousseau.png', height: 410 * ratio, @@ -36,7 +40,7 @@ class OnboardingStepTwelve extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep11'), + key: const Key('goStep11'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -49,7 +53,7 @@ class OnboardingStepTwelve extends StatelessWidget { page: OnboardingStepThirteen(), isFast: true), ); }, - child: Text("Générer le code secret", + child: const Text("Générer le code secret", style: TextStyle(fontSize: 20))), ))), SizedBox(height: isTall ? 80 : 40), diff --git a/lib/screens/onBoarding/11.dart b/lib/screens/onBoarding/11.dart index d0173cc..38cc330 100644 --- a/lib/screens/onBoarding/11.dart +++ b/lib/screens/onBoarding/11.dart @@ -1,10 +1,12 @@ +// ignore_for_file: file_names + import 'dart:ui'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/12.dart'; import 'package:provider/provider.dart'; @@ -13,6 +15,8 @@ class OnboardingStepThirteen extends StatelessWidget { NewWallet generatedWallet; final int progress = 10; + OnboardingStepThirteen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -32,51 +36,49 @@ class OnboardingStepThirteen extends StatelessWidget { // initialData: '...', builder: (context, snapshot) { generatedWallet = snapshot.data; - return Visibility(visible: false, child: Text('')); + return const Visibility(visible: false, child: Text('')); }), common.onboardingProgressBar( context, 'Ma phrase de restauration', progress), common.bubbleSpeakRich( [ - TextSpan( + const TextSpan( text: "Et voilà votre code secret !\n\nMémorisez-le ou notez-le, car il vous sera demandé "), - TextSpan( + const TextSpan( text: 'à chaque fois', style: TextStyle(fontWeight: FontWeight.bold)), - TextSpan( + const TextSpan( text: " que vous voudrez effectuer un paiement sur cet appareil."), ], - textKey: Key('step11'), + textKey: const Key('step11'), ), - SizedBox(height: 100), - Container( - child: Stack( - alignment: Alignment.centerRight, - children: [ - TextField( - key: Key('generatedPin'), - enabled: false, - controller: _generateWalletProvider.pin, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - letterSpacing: 5, - fontSize: 35.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - IconButton( - icon: Icon(Icons.replay), - color: orangeC, - onPressed: () async { - generatedWallet = await _generateWalletProvider - .changePinCode(reload: false); - }, - ), - ], - ), + const SizedBox(height: 100), + Stack( + alignment: Alignment.centerRight, + children: [ + TextField( + key: const Key('generatedPin'), + enabled: false, + controller: _generateWalletProvider.pin, + maxLines: 1, + textAlign: TextAlign.center, + decoration: const InputDecoration(), + style: const TextStyle( + letterSpacing: 5, + fontSize: 35.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + IconButton( + icon: const Icon(Icons.replay), + color: orangeC, + onPressed: () async { + generatedWallet = await _generateWalletProvider + .changePinCode(reload: false); + }, + ), + ], ), Expanded( child: Align( @@ -85,25 +87,25 @@ class OnboardingStepThirteen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('changeSecretCode'), + key: const Key('changeSecretCode'), style: ElevatedButton.styleFrom( elevation: 5, - primary: Color(0xffFFD58D), + primary: const Color(0xffFFD58D), onPrimary: Colors.black, // foreground ), onPressed: () async { generatedWallet = await _generateWalletProvider .changePinCode(reload: false); }, - child: Text("Choisir un autre code secret", + child: const Text("Choisir un autre code secret", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 25), + const SizedBox(height: 25), SizedBox( width: 400, height: 62, child: ElevatedButton( - key: Key('goStep12'), + key: const Key('goStep12'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -120,10 +122,10 @@ class OnboardingStepThirteen extends StatelessWidget { isFast: true), ); }, - child: Text("J'ai noté mon code secret", + child: const Text("J'ai noté mon code secret", style: TextStyle(fontSize: 20))), ), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index ce6361f..d715a47 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -1,13 +1,15 @@ +// ignore_for_file: file_names + import 'dart:async'; import 'dart:ui'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/models/walletOptions.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/models/wallet_options.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/13_congratulations.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:provider/provider.dart'; @@ -22,7 +24,7 @@ class OnboardingStepFourteen extends StatelessWidget { NewWallet generatedWallet; final int progress = 11; final formKey = GlobalKey(); - var pinColor = Color(0xFFA4B600); + var pinColor = const Color(0xFFA4B600); bool hasError = false; @override @@ -43,7 +45,7 @@ class OnboardingStepFourteen extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Avez-vous bien mémorisé votre code secret ?\n\nVérifions ça ensemble !\n\nTapez votre code secret dans le champ ci-dessous (après c’est fini, promis-juré-gecko).", - textKey: Key('step12'), + textKey: const Key('step12'), ), SizedBox(height: isTall ? 80 : 10), pinForm(context, _walletOptions, _pinLenght, 1, 3) @@ -70,7 +72,7 @@ class OnboardingStepFourteen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30), child: PinCodeTextField( - key: Key('formKey2'), + key: const Key('formKey2'), autoFocus: true, appContext: context, pastedTextStyle: TextStyle( @@ -98,14 +100,14 @@ class OnboardingStepFourteen extends StatelessWidget { activeFillColor: hasError ? Colors.blueAccent : Colors.black, ), cursorColor: Colors.black, - animationDuration: Duration(milliseconds: 300), - textStyle: TextStyle(fontSize: 20, height: 1.6), - backgroundColor: Color(0xffF9F9F1), + animationDuration: const Duration(milliseconds: 300), + textStyle: const TextStyle(fontSize: 20, height: 1.6), + backgroundColor: const Color(0xffF9F9F1), enableActiveFill: false, errorAnimationController: errorController, controller: _enterPin, keyboardType: TextInputType.text, - boxShadows: [ + boxShadows: const [ BoxShadow( offset: Offset(0, 1), color: Colors.black12, @@ -140,8 +142,8 @@ class OnboardingStepFourteen extends StatelessWidget { } }, onChanged: (value) { - if (pinColor != Color(0xFFA4B600)) { - pinColor = Color(0xFFA4B600); + if (pinColor != const Color(0xFFA4B600)) { + pinColor = const Color(0xFFA4B600); } }, )), diff --git a/lib/screens/onBoarding/13_congratulations.dart b/lib/screens/onBoarding/13_congratulations.dart index 58ad16a..ac73743 100644 --- a/lib/screens/onBoarding/13_congratulations.dart +++ b/lib/screens/onBoarding/13_congratulations.dart @@ -1,13 +1,17 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; // ignore: must_be_immutable class OnboardingStepFiveteen extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 12; + OnboardingStepFiveteen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -21,7 +25,7 @@ class OnboardingStepFiveteen extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !", - textKey: Key('step13'), + textKey: const Key('step13'), ), SizedBox(height: isTall ? 20 : 10), Image.asset( @@ -35,7 +39,7 @@ class OnboardingStepFiveteen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goWalletHome'), + key: const Key('goWalletHome'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -51,10 +55,10 @@ class OnboardingStepFiveteen extends StatelessWidget { '/mywallets', ); }, - child: Text("Accéder à mes portefeuilles", + child: const Text("Accéder à mes portefeuilles", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/2.dart b/lib/screens/onBoarding/2.dart index 0d7a3f9..19e2cbf 100644 --- a/lib/screens/onBoarding/2.dart +++ b/lib/screens/onBoarding/2.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/3.dart'; // import 'package:gecko/screens/commonElements.dart'; // import 'package:gecko/models/home.dart'; @@ -12,6 +14,8 @@ class OnboardingStepTwo extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 2; + OnboardingStepTwo({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -25,9 +29,9 @@ class OnboardingStepTwo extends StatelessWidget { context, 'Nouveau portefeuilles', progress), common.bubbleSpeak( "Un trousseau est créé à partir d’une phrase de restauration.", - textKey: Key('step2'), + textKey: const Key('step2'), ), - SizedBox(height: 70), + const SizedBox(height: 70), Image.asset( 'assets/onBoarding/keys-and-wallets-horizontal-plus-phrase.png'), Expanded( @@ -37,7 +41,7 @@ class OnboardingStepTwo extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep3'), + key: const Key('goStep3'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -50,10 +54,11 @@ class OnboardingStepTwo extends StatelessWidget { page: OnboardingStepFor(), isFast: true), ); }, - child: Text("D'accord", style: TextStyle(fontSize: 20)), + child: const Text("D'accord", + style: TextStyle(fontSize: 20)), ), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/3.dart b/lib/screens/onBoarding/3.dart index 6d589cc..815741b 100644 --- a/lib/screens/onBoarding/3.dart +++ b/lib/screens/onBoarding/3.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/4.dart'; // ignore: must_be_immutable @@ -9,6 +11,8 @@ class OnboardingStepFor extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 3; + OnboardingStepFor({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,7 +26,7 @@ class OnboardingStepFor extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Si un jour vous changez de téléphone, il vous suffira de me redonner votre phrase de restauration pour recréer votre trousseau.", - textKey: Key('step3'), + textKey: const Key('step3'), ), SizedBox(height: isTall ? 15 : 0), // Row(children: [ @@ -41,7 +45,7 @@ class OnboardingStepFor extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep4'), + key: const Key('goStep4'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -54,10 +58,10 @@ class OnboardingStepFor extends StatelessWidget { page: OnboardingStepFive(), isFast: true), ); }, - child: Text("J'ai compris", + child: const Text("J'ai compris", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/4.dart b/lib/screens/onBoarding/4.dart index 8d1feec..bd0317b 100644 --- a/lib/screens/onBoarding/4.dart +++ b/lib/screens/onBoarding/4.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/5.dart'; // ignore: must_be_immutable @@ -9,6 +11,8 @@ class OnboardingStepFive extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 4; + OnboardingStepFive({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,7 +26,7 @@ class OnboardingStepFive extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "Par contre, attention :\n\nDans une blockchain, il n’y a pas de procédure de récupération de trousseau.\n\nSi vous perdez votre phrase de restauration, je ne pourrai pas vous la communiquer, et vous ne pourrez donc plus jamais accéder à votre compte.", - textKey: Key('step4'), + textKey: const Key('step4'), ), SizedBox(height: isTall ? 30 : 10), Image.asset( @@ -36,7 +40,7 @@ class OnboardingStepFive extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep5'), + key: const Key('goStep5'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -49,10 +53,10 @@ class OnboardingStepFive extends StatelessWidget { page: OnboardingStepSeven(), isFast: true), ); }, - child: Text("J'ai compris", + child: const Text("J'ai compris", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/5.dart b/lib/screens/onBoarding/5.dart index 426770f..dbe5ee7 100644 --- a/lib/screens/onBoarding/5.dart +++ b/lib/screens/onBoarding/5.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/6.dart'; // ignore: must_be_immutable @@ -9,6 +11,8 @@ class OnboardingStepSeven extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 5; + OnboardingStepSeven({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,15 +26,15 @@ class OnboardingStepSeven extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeakRich( [ - TextSpan(text: "Munissez-vous d'"), - TextSpan( + const TextSpan(text: "Munissez-vous d'"), + const TextSpan( text: 'un papier et d’un crayon\n', style: TextStyle(fontWeight: FontWeight.bold)), - TextSpan( + const TextSpan( text: "afin de pouvoir noter votre phrase de restauration."), ], - textKey: Key('step5'), + textKey: const Key('step5'), ), Expanded( child: Align( @@ -53,7 +57,7 @@ class OnboardingStepSeven extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep6'), + key: const Key('goStep6'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -66,10 +70,10 @@ class OnboardingStepSeven extends StatelessWidget { page: OnboardingStepEight(), isFast: true), ); }, - child: Text("J'ai de quoi noter", + child: const Text("J'ai de quoi noter", style: TextStyle(fontSize: 20))), ), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/onBoarding/6.dart b/lib/screens/onBoarding/6.dart index 54155cf..741947d 100644 --- a/lib/screens/onBoarding/6.dart +++ b/lib/screens/onBoarding/6.dart @@ -1,8 +1,10 @@ +// ignore_for_file: file_names + import 'dart:ui'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/7.dart'; // ignore: must_be_immutable @@ -10,6 +12,8 @@ class OnboardingStepEight extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 6; + OnboardingStepEight({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -23,7 +27,7 @@ class OnboardingStepEight extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.", - textKey: Key('step6'), + textKey: const Key('step6'), ), SizedBox(height: isTall ? 61 : 31), // SizedBox(height: 30), @@ -36,7 +40,7 @@ class OnboardingStepEight extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep7'), + key: const Key('goStep7'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -49,10 +53,10 @@ class OnboardingStepEight extends StatelessWidget { page: OnboardingStepNine(), isFast: false), ); }, - child: Text("Afficher ma phrase", + child: const Text("Afficher ma phrase", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } @@ -60,16 +64,16 @@ class OnboardingStepEight extends StatelessWidget { Widget sentanceArray(BuildContext context) { return Container( - padding: EdgeInsets.symmetric(horizontal: 12), + padding: const EdgeInsets.symmetric(horizontal: 12), child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.black), color: Colors.grey[300], - borderRadius: BorderRadius.all( - const Radius.circular(10), + borderRadius: const BorderRadius.all( + Radius.circular(10), )), // color: Colors.grey[300], - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, @@ -81,14 +85,14 @@ Widget sentanceArray(BuildContext context) { arrayCell("3:curseur"), arrayCell("4:relatif"), ]), - SizedBox(height: 15), + const SizedBox(height: 15), Row(children: [ arrayCell("5:embellir"), arrayCell("6:cultiver"), arrayCell("7:bureau"), arrayCell("8:ossature"), ]), - SizedBox(height: 15), + const SizedBox(height: 15), Row(children: [ arrayCell("9:labial"), arrayCell("10:science"), @@ -99,20 +103,20 @@ Widget sentanceArray(BuildContext context) { } Widget arrayCell(dataWord) { - return Container( + return SizedBox( width: 102, child: Column( children: [ ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 1, sigmaY: 1), child: Text(dataWord.split(':')[0], - style: TextStyle(fontSize: 14, color: Colors.black)), + style: const TextStyle(fontSize: 14, color: Colors.black)), ), - SizedBox(height: 2), + const SizedBox(height: 2), ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), child: Text(dataWord.split(':')[1], - style: TextStyle(fontSize: 20, color: Colors.black)), + style: const TextStyle(fontSize: 20, color: Colors.black)), ) ], )); diff --git a/lib/screens/onBoarding/7.dart b/lib/screens/onBoarding/7.dart index 7d5fc06..be94bc4 100644 --- a/lib/screens/onBoarding/7.dart +++ b/lib/screens/onBoarding/7.dart @@ -1,8 +1,10 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/8.dart'; import 'package:printing/printing.dart'; import 'package:provider/provider.dart'; @@ -12,6 +14,8 @@ class OnboardingStepNine extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 6; + OnboardingStepNine({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -29,7 +33,7 @@ class OnboardingStepNine extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeak( "C'est le moment de noter votre phrase !", - textKey: Key('step7'), + textKey: const Key('step7'), long: 60, ), SizedBox(height: isTall ? 100 : 70), @@ -56,24 +60,24 @@ class OnboardingStepNine extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('generateMnemonic'), + key: const Key('generateMnemonic'), style: ElevatedButton.styleFrom( elevation: 5, - primary: Color(0xffFFD58D), + primary: const Color(0xffFFD58D), onPrimary: Colors.black, // foreground ), onPressed: () { _generateWalletProvider.reloadBuild(); }, - child: Text("Choisir une autre phrase", + child: const Text("Choisir une autre phrase", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 25), + const SizedBox(height: 25), SizedBox( width: 400, height: 62, child: ElevatedButton( - key: Key('goStep8'), + key: const Key('goStep8'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -97,10 +101,10 @@ class OnboardingStepNine extends StatelessWidget { isFast: true), ); }, - child: Text("J'ai noté ma phrase", + child: const Text("J'ai noté ma phrase", style: TextStyle(fontSize: 20))), ), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } @@ -112,7 +116,7 @@ Widget sentanceArray(BuildContext context) { return FutureBuilder( future: _generateWalletProvider.generateWordList(), - initialData: [ + initialData: const [ '1:...', '2:...', '3:...', @@ -129,16 +133,16 @@ Widget sentanceArray(BuildContext context) { builder: (context, formatedArray) { // print(formatedArray.data); return Container( - padding: EdgeInsets.symmetric(horizontal: 12), + padding: const EdgeInsets.symmetric(horizontal: 12), child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.black), color: Colors.grey[300], - borderRadius: BorderRadius.all( - const Radius.circular(10), + borderRadius: const BorderRadius.all( + Radius.circular(10), )), // color: Colors.grey[300], - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, @@ -150,14 +154,14 @@ Widget sentanceArray(BuildContext context) { arrayCell(formatedArray.data[2]), arrayCell(formatedArray.data[3]), ]), - SizedBox(height: 15), + const SizedBox(height: 15), Row(children: [ arrayCell(formatedArray.data[4]), arrayCell(formatedArray.data[5]), arrayCell(formatedArray.data[6]), arrayCell(formatedArray.data[7]), ]), - SizedBox(height: 15), + const SizedBox(height: 15), Row(children: [ arrayCell(formatedArray.data[8]), arrayCell(formatedArray.data[9]), @@ -169,20 +173,20 @@ Widget sentanceArray(BuildContext context) { } Widget arrayCell(dataWord) { - return Container( + return SizedBox( width: 102, child: Column(children: [ - Text(dataWord.split(':')[0], style: TextStyle(fontSize: 14)), - SizedBox(height: 2), + Text(dataWord.split(':')[0], style: const TextStyle(fontSize: 14)), + const SizedBox(height: 2), Text(dataWord.split(':')[1], key: Key('word${dataWord.split(':')[0]}'), - style: TextStyle(fontSize: 19, color: Colors.black)), + style: const TextStyle(fontSize: 19, color: Colors.black)), ])); } // ignore: must_be_immutable class PrintWallet extends StatelessWidget { - PrintWallet(this.sentence); + const PrintWallet(this.sentence, {Key key}) : super(key: key); final String sentence; @@ -192,7 +196,7 @@ class PrintWallet extends StatelessWidget { Provider.of(context); return MaterialApp( home: Scaffold( - appBar: AppBar(title: Text('Imprimer ce trousseau')), + appBar: AppBar(title: const Text('Imprimer ce trousseau')), body: PdfPreview( build: (format) => _generateWalletProvider.printWallet(sentence), ), diff --git a/lib/screens/onBoarding/8.dart b/lib/screens/onBoarding/8.dart index 3a16dde..9afcda8 100644 --- a/lib/screens/onBoarding/8.dart +++ b/lib/screens/onBoarding/8.dart @@ -1,10 +1,12 @@ +// ignore_for_file: file_names + import 'dart:ui'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/models/generate_wallets.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/9.dart'; import 'package:provider/provider.dart'; @@ -21,7 +23,7 @@ class OnboardingStepTen extends StatelessWidget { TextEditingController tplController = TextEditingController(); TextEditingController wordController = TextEditingController(); - TextEditingController _mnemonicController = TextEditingController(); + final TextEditingController _mnemonicController = TextEditingController(); final int progress = 7; @@ -31,7 +33,7 @@ class OnboardingStepTen extends StatelessWidget { GenerateWalletsProvider _generateWalletProvider = Provider.of(context); CommonElements common = CommonElements(); - this._mnemonicController.text = generatedMnemonic; + _mnemonicController.text = generatedMnemonic; return WillPopScope( onWillPop: () { @@ -60,11 +62,11 @@ class OnboardingStepTen extends StatelessWidget { text: " de votre phrase de restauration :", style: TextStyle(fontSize: 16 * ratio)), ], - textKey: Key('step8'), + textKey: const Key('step8'), ), SizedBox(height: isTall ? 70 : 10), Text('${_generateWalletProvider.nbrWord + 1}', - key: Key('askedWord'), + key: const Key('askedWord'), style: TextStyle( fontSize: isTall ? 17 : 10, color: orangeC, @@ -79,10 +81,10 @@ class OnboardingStepTen extends StatelessWidget { )), width: 430, child: TextFormField( - key: Key('inputWord'), + key: const Key('inputWord'), autofocus: true, enabled: !_generateWalletProvider.isAskedWordValid, - controller: this.wordController, + controller: wordController, textInputAction: TextInputAction.next, onChanged: (value) { _generateWalletProvider.checkAskedWord( @@ -100,7 +102,7 @@ class OnboardingStepTen extends StatelessWidget { : "${_generateWalletProvider.nbrWordAlpha} mot de votre phrase de restauration", fillColor: Colors.grey[300], filled: true, - contentPadding: EdgeInsets.all(12), + contentPadding: const EdgeInsets.all(12), ), style: TextStyle( fontSize: 40.0, @@ -115,7 +117,7 @@ class OnboardingStepTen extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep9'), + key: const Key('goStep9'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -129,10 +131,10 @@ class OnboardingStepTen extends StatelessWidget { isFast: true), ); }, - child: Text("Continuer", + child: const Text("Continuer", style: TextStyle(fontSize: 20))), )))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), ))); } diff --git a/lib/screens/onBoarding/9.dart b/lib/screens/onBoarding/9.dart index 67b9cc5..35b285e 100644 --- a/lib/screens/onBoarding/9.dart +++ b/lib/screens/onBoarding/9.dart @@ -1,7 +1,9 @@ +// ignore_for_file: file_names + import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; -import 'package:gecko/screens/commonElements.dart'; +import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/onBoarding/10.dart'; // ignore: must_be_immutable @@ -9,6 +11,8 @@ class OnboardingStepEleven extends StatelessWidget { TextEditingController tplController = TextEditingController(); final int progress = 8; + OnboardingStepEleven({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); @@ -22,15 +26,16 @@ class OnboardingStepEleven extends StatelessWidget { context, 'Ma phrase de restauration', progress), common.bubbleSpeakRich( [ - TextSpan(text: "Super !\n\nJe vais maintenant créer votre "), - TextSpan( + const TextSpan( + text: "Super !\n\nJe vais maintenant créer votre "), + const TextSpan( text: 'code secret.', style: TextStyle(fontWeight: FontWeight.bold)), - TextSpan( + const TextSpan( text: " \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."), ], - textKey: Key('step9'), + textKey: const Key('step9'), ), SizedBox(height: isTall ? 50 : 10), Image.asset( @@ -44,7 +49,7 @@ class OnboardingStepEleven extends StatelessWidget { width: 400, height: 62, child: ElevatedButton( - key: Key('goStep10'), + key: const Key('goStep10'), style: ElevatedButton.styleFrom( elevation: 5, primary: orangeC, @@ -57,10 +62,10 @@ class OnboardingStepEleven extends StatelessWidget { page: OnboardingStepTwelve(), isFast: true), ); }, - child: Text("J'ai compris", + child: const Text("J'ai compris", style: TextStyle(fontSize: 20))), ))), - SizedBox(height: 80), + const SizedBox(height: 80), ]), )); } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 366cfdb..462c76c 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:gecko/models/home.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/screens/myWallets/generateWallets.dart'; +import 'package:gecko/models/my_wallets.dart'; +import 'package:gecko/screens/myWallets/generate_wallets.dart'; import 'dart:io'; -import 'package:gecko/screens/myWallets/importWallet.dart'; +import 'package:gecko/screens/myWallets/import_wallet.dart'; import 'package:gecko/globals.dart'; import 'package:provider/provider.dart'; @@ -22,7 +22,9 @@ class SettingsScreen extends StatelessWidget { var pinColor = Colors.grey[300]; Directory appPath; - MyWalletsProvider _myWallets = MyWalletsProvider(); + final MyWalletsProvider _myWallets = MyWalletsProvider(); + + SettingsScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -32,12 +34,12 @@ class SettingsScreen extends StatelessWidget { // getAppDirectory(); return Scaffold( appBar: AppBar( - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Paramètres'), )), body: Column(children: [ - SizedBox(height: 40), + const SizedBox(height: 40), SizedBox( height: 70, width: 500, @@ -50,19 +52,19 @@ class SettingsScreen extends StatelessWidget { onPressed: () => Navigator.push( context, MaterialPageRoute(builder: (context) { - return ImportWalletScreen(); + return const ImportWalletScreen(); }), ).then((value) => { if (value == true) {Navigator.pop(context)} }), - child: Text("Importer un portefeuille Cesium", + child: const Text("Importer un portefeuille Cesium", style: TextStyle(fontSize: 16)))), - SizedBox(height: 30), + const SizedBox(height: 30), SizedBox( height: 70, width: 500, child: ElevatedButton( - key: Key('generateKeychain'), + key: const Key('generateKeychain'), style: ElevatedButton.styleFrom( elevation: 5, primary: yellowC, // background @@ -76,7 +78,7 @@ class SettingsScreen extends StatelessWidget { ).then((value) => { if (value == true) {Navigator.pop(context)} }), - child: Text("Générer un nouveau trousseau", + child: const Text("Générer un nouveau trousseau", style: TextStyle(fontSize: 16)))), Expanded( child: Align( @@ -85,7 +87,7 @@ class SettingsScreen extends StatelessWidget { height: 100, width: 500, child: ElevatedButton( - key: Key('deleteAllWallets'), + key: const Key('deleteAllWallets'), style: ElevatedButton.styleFrom( elevation: 5, primary: Colors.redAccent, // background @@ -97,9 +99,9 @@ class SettingsScreen extends StatelessWidget { .deleteAllWallet(context) .then((v) => _homeProvider.rebuildWidget()) }, - child: Text("EFFACER TOUS MES PORTEFEUILLES", + child: const Text("EFFACER TOUS MES PORTEFEUILLES", style: TextStyle(fontSize: 20)))))), - SizedBox(height: 50), + const SizedBox(height: 50), ])); } } diff --git a/lib/screens/templateScreen.dart b/lib/screens/template_screen.dart similarity index 79% rename from lib/screens/templateScreen.dart rename to lib/screens/template_screen.dart index cf6dfd6..10b9cf4 100644 --- a/lib/screens/templateScreen.dart +++ b/lib/screens/template_screen.dart @@ -9,17 +9,19 @@ import 'package:flutter/material.dart'; class TemplateScreen extends StatelessWidget { TextEditingController tplController = TextEditingController(); + TemplateScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); // HomeProvider _homeProvider = Provider.of(context); return Scaffold( appBar: AppBar( - title: SizedBox( + title: const SizedBox( height: 22, child: Text('Template screen'), )), - floatingActionButton: Container( + floatingActionButton: SizedBox( height: 80.0, width: 80.0, child: FittedBox( @@ -28,10 +30,10 @@ class TemplateScreen extends StatelessWidget { onPressed: () => Navigator.push( context, MaterialPageRoute(builder: (context) { - return HomeScreen(); + return const HomeScreen(); }), ), - child: Container( + child: SizedBox( height: 40.0, width: 40.0, child: Icon(Icons.home, color: Colors.grey[850]), @@ -41,20 +43,20 @@ class TemplateScreen extends StatelessWidget { ))), body: SafeArea( child: Column(children: [ - SizedBox(height: 20), + const SizedBox(height: 20), TextField( enabled: true, controller: tplController, maxLines: 1, textAlign: TextAlign.center, - decoration: InputDecoration( + decoration: const InputDecoration( contentPadding: EdgeInsets.all(15.0), ), - style: TextStyle( + style: const TextStyle( fontSize: 22.0, color: Colors.black, fontWeight: FontWeight.w400)), - SizedBox(height: 20), + const SizedBox(height: 20), ElevatedButton( style: ElevatedButton.styleFrom( primary: yellowC, // background @@ -64,12 +66,13 @@ class TemplateScreen extends StatelessWidget { Navigator.push( context, MaterialPageRoute(builder: (context) { - return HomeScreen(); + return const HomeScreen(); }), ); }, - child: Text('Retour Accueil', style: TextStyle(fontSize: 20))), - SizedBox(height: 20), + child: const Text('Retour Accueil', + style: TextStyle(fontSize: 20))), + const SizedBox(height: 20), GestureDetector( onTap: () { Navigator.popUntil( @@ -77,7 +80,7 @@ class TemplateScreen extends StatelessWidget { ModalRoute.withName('/'), ); }, - child: Icon(Icons.home)) + child: const Icon(Icons.home)) ]), )); } diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..fc41ebe --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,24 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import connectivity_plus_macos +import package_info +import package_info_plus_macos +import path_provider_macos +import printing +import sentry_flutter +import shared_preferences_macos + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) + FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) + FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin")) + SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..bfee57a --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* gecko.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "gecko.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* gecko.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* gecko.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0930; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..1e2f67b --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..3c4935a Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..ed4cc16 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..483be61 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bcbf36d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..9c0a652 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..e71a726 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..8a31fe2 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..537341a --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..b374696 --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = gecko + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.gecko + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..2722837 --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/pubspec.lock b/pubspec.lock index fcfb1ab..7ff1640 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -326,6 +326,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.9.2" + flutter_lints: + dependency: "direct main" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" flutter_logs: dependency: "direct main" description: @@ -577,6 +584,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.3.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logger: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 9ee5f91..b5a9772 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,6 +55,7 @@ dependencies: xml: ^5.3.0 assorted_layout_widgets: ^5.2.1 carousel_slider: ^4.0.0 + flutter_lints: ^1.0.4 flutter_icons: android: "ic_launcher" diff --git a/test_driver/app_test.dart b/test_driver/app_test.dart index c540836..72a15f9 100644 --- a/test_driver/app_test.dart +++ b/test_driver/app_test.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter_driver/flutter_driver.dart'; +import 'package:gecko/globals.dart'; import 'package:test/test.dart'; // import 'package:flutter/services.dart'; @@ -108,7 +109,7 @@ void main() { await sleep(300); await tapOn('generateKeychain'); while (await getText('generatedPin') == '') { - print('Waiting for pin code generation...'); + log.i('Waiting for pin code generation...'); await sleep(100); } pinCode = await getText('generatedPin'); @@ -125,13 +126,10 @@ void main() { // *** Begin of tests *** // test('OnBoarding - Open wallets management', ( - {timeout: Timeout.none}) async { + {timeout = Timeout.none}) async { // await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers await driver.tap(manageWalletsFinder); - print( - '####################################################################'); - // If a wallet exist, go to delete theme all if (!await isPresent(find.byValueKey('goStep1'))) { await goBack(); @@ -154,7 +152,7 @@ void main() { }); test('OnBoarding - Go to create restore sentance', ( - {timeout: Timeout.none}) async { + {timeout = Timeout.none}) async { await tapOn('goStep1'); await tapOn('goStep2'); await tapOn('goStep3'); @@ -170,11 +168,11 @@ void main() { }); test('OnBoarding - Generate sentance and confirme it', ( - {timeout: Timeout.none}) async { + {timeout = Timeout.none}) async { await tapOn('goStep7'); while (await getText('word1') == '...') { - print('Waiting for Mnemonic generation...'); + log.i('Waiting for Mnemonic generation...'); await sleep(100); } @@ -220,7 +218,7 @@ void main() { await selectWord(); }); test('OnBoarding - Generate secret code and confirm it', ( - {timeout: Timeout.none}) async { + {timeout = Timeout.none}) async { expect(await getText('step9'), "Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."); @@ -228,12 +226,14 @@ void main() { await tapOn('goStep11'); while (await getText('generatedPin') == '') { - print('Waiting for pin code generation...'); + log.i('Waiting for pin code generation...'); await sleep(100); } // Change secret code 4 times - for (int i = 0; i < 4; i++) await tapOn('changeSecretCode'); + for (int i = 0; i < 4; i++) { + await tapOn('changeSecretCode'); + } await sleep(500); pinCode = await getText('generatedPin'); @@ -255,7 +255,7 @@ void main() { }); test('My wallets - Rename first derivation', ( - {timeout: const Duration(seconds: 2)}) async { + {timeout = const Duration(seconds: 2)}) async { await tapOn('goWalletHome'); expect(await getText('myWallets'), "Mes portefeuilles"); @@ -278,7 +278,7 @@ void main() { }); test('My wallets - Create a derivations, open thems, tap all buttons', ( - {timeout: const Duration(seconds: 2)}) async { + {timeout = const Duration(seconds: 2)}) async { await driver.waitFor(find.text('Renommage wallet 1'), timeout: timeout); // Add a second derivation await createDerivation('Derivation 2'); @@ -321,7 +321,7 @@ void main() { }); test('My wallets - Extra tests', ( - {timeout: const Duration(seconds: 2)}) async { + {timeout = const Duration(seconds: 2)}) async { // Add derivation 5,6 and 7 await driver.waitFor(find.text('Derivation 4'), timeout: timeout); await createDerivation('Derivation 5'); @@ -404,7 +404,7 @@ void main() { }); test('Search - Search Pi profile, navigate in history transactions', ( - {timeout: const Duration(seconds: 2)}) async { + {timeout = const Duration(seconds: 2)}) async { await driver.waitFor(find.text('Derivation 20'), timeout: timeout); await goBack(); await goBack(); @@ -436,7 +436,7 @@ void main() { }, timeout: Timeout(Duration(minutes: globalTimeout))); test('Wallet generation - Fast wallets generations', ( - {timeout: const Duration(seconds: 2)}) async { + {timeout = const Duration(seconds: 2)}) async { await driver.waitFor(find.text('Commentaire:'), timeout: timeout); await goBack(); await goBack(); diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..5d61367 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,95 @@ +cmake_minimum_required(VERSION 3.15) +project(gecko LANGUAGES CXX) + +set(BINARY_NAME "gecko") + +cmake_policy(SET CMP0063 NEW) + +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Configure build options. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() + +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") + +# Flutter library and tool build rules. +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..b02c548 --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,103 @@ +cmake_minimum_required(VERSION 3.15) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..25cb188 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,20 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + PrintingPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PrintingPlugin")); + SentryFlutterPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SentryFlutterPlugin")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..fcd7a40 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,18 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + connectivity_plus_windows + printing + sentry_flutter +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..0b899a0 --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.15) +project(runner LANGUAGES CXX) + +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) +apply_standard_settings(${BINARY_NAME}) +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..ed275d2 --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "A new Flutter project." "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "gecko" "\0" + VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "gecko.exe" "\0" + VALUE "ProductName", "gecko" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..b43b909 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..aa55141 --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"gecko", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..c977c4a --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..d19bdbb --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + if (target_length == 0) { + return std::string(); + } + std::string utf8_string; + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..c10f08d --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..17ba431 --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_