diff --git a/lib/main.dart b/lib/main.dart index 7efdea8..f84ff3b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:dubp/dubp.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/cesiumPlus.dart'; @@ -17,32 +19,11 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:catcher/catcher.dart'; -// import 'dart:io'; -// import 'package:flutter_logs/flutter_logs.dart'; -// import 'package:downloads_path_provider/downloads_path_provider.dart'; - final bool enableSentry = true; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - // var downloadsDirectory = DownloadsPathProvider.downloadsDirectory; - // File logFile = File(downloadsDirectory.toString() + '/gecko.log'); - - // await FlutterLogs.initLogs( - // logLevelsEnabled: [ - // LogLevel.INFO, - // LogLevel.WARNING, - // LogLevel.ERROR, - // LogLevel.SEVERE - // ], - // timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, - // directoryStructure: DirectoryStructure.FOR_EVENT, - // logTypesEnabled: ["Locations", "APIs"], - // logFileExtension: LogFileExtension.LOG, - // logsWriteDirectoryName: downloadsDirectory.toString(), - // logsExportDirectoryName: downloadsDirectory.toString()); - HomeProvider _homeProvider = HomeProvider(); await _homeProvider.getAppPath(); await _homeProvider.createDefaultAvatar(); @@ -55,23 +36,33 @@ Future main() async { endPointGVA = await _homeProvider.getValidEndpoint(); if (kReleaseMode && enableSentry) { - CatcherOptions debugOptions = CatcherOptions(DialogReportMode(), [ - SentryHandler(SentryClient(SentryOptions( - dsn: - "https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110"))) - ]); - // CatcherOptions releaseOptions = CatcherOptions(NotificationReportMode(), [ - // EmailManualHandler(["poka@p2p.legal"]) + // CatcherOptions debugOptions = CatcherOptions(DialogReportMode(), [ + // SentryHandler(SentryClient(SentryOptions( + // dsn: + // "https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110"))) // ]); - Catcher(rootWidget: Gecko(endPointGVA, _store), debugConfig: debugOptions); + // // CatcherOptions releaseOptions = CatcherOptions(NotificationReportMode(), [ + // // EmailManualHandler(["poka@p2p.legal"]) + // // ]); + // Catcher(rootWidget: Gecko(endPointGVA, _store), debugConfig: debugOptions); - // await SentryFlutter.init( - // (options) { - // options.dsn = - // 'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110'; - // }, - // appRunner: () => runApp(Gecko(endPointGVA, _store)), - // ); + await SentryFlutter.init((options) { + options.dsn = + 'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110'; + }, appRunner: () => runApp(Gecko(endPointGVA, _store))); + + // runZoned>( + // () async { + // runApp(Gecko(endPointGVA, _store)); + // }, + // onError: (dynamic error, StackTrace stackTrace) { + // print("=================== CAUGHT DART ERROR"); + // // Sentry.captureException( + // // error, + // // stackTrace: stackTrace, + // // ); + // }, + // )); } else { print('Debug mode enabled: No sentry alerte'); @@ -108,6 +99,8 @@ class Gecko extends StatelessWidget { } } + // HistoryProvider _historyProvider = Provider.of(context); + // HistoryProvider('').snackNode(context); return MultiProvider( providers: [ // Provider(create: (context) => HistoryProvider()), diff --git a/lib/models/history.dart b/lib/models/history.dart index 966d14c..0585c29 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/home.dart'; +import 'package:gecko/screens/history.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; @@ -64,6 +65,12 @@ class HistoryProvider with ChangeNotifier { isHistoryScreen = false; historySwitchButtun = "Voir l'historique"; _homeProvider.handleSearchEnd(); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return HistoryScreen(); + }), + ); notifyListeners(); return pubkey; @@ -202,8 +209,8 @@ class HistoryProvider with ChangeNotifier { } final snackBar = SnackBar(content: Text(_message), duration: Duration(seconds: 2)); - Scaffold.of(context).showSnackBar(snackBar); isFirstBuild = false; + Scaffold.of(context).showSnackBar(snackBar); } } diff --git a/lib/models/home.dart b/lib/models/home.dart index c8eeeca..afacee6 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -17,6 +17,9 @@ class HomeProvider with ChangeNotifier { Icon searchIcon = Icon(Icons.search); final TextEditingController searchQuery = new TextEditingController(); Widget appBarTitle = Text('Ğecko', style: TextStyle(color: Colors.grey[850])); + Widget appBarExplorer = + Text('Explorateur', style: TextStyle(color: Colors.grey[850])); + List currentTab = [HistoryScreen(), WalletsHome()]; get currentIndex => _currentIndex; @@ -124,6 +127,8 @@ class HomeProvider with ChangeNotifier { color: Colors.grey[850], ); appBarTitle = Text('Ğecko', style: TextStyle(color: Colors.grey[850])); + appBarExplorer = + Text('Explorateur', style: TextStyle(color: Colors.grey[850])); isSearching = false; searchQuery.clear(); diff --git a/lib/screens/history.dart b/lib/screens/history.dart index 8a41aa5..f1f40f7 100644 --- a/lib/screens/history.dart +++ b/lib/screens/history.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/cesiumPlus.dart'; +import 'package:gecko/models/home.dart'; import 'package:gecko/models/queries.dart'; import 'package:gecko/models/history.dart'; import 'package:flutter/material.dart'; @@ -28,14 +29,55 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { @override Widget build(BuildContext context) { HistoryProvider _historyProvider = Provider.of(context); + HomeProvider _homeProvider = Provider.of(context); this._outputPubkey.text = _historyProvider.pubkey; print('Build pubkey : ' + _historyProvider.pubkey); // _historyProvider.snackNode(context); - WidgetsBinding.instance.addPostFrameCallback((_) { - _historyProvider.snackNode(context); - }); + WidgetsBinding.instance.addPostFrameCallback((_) {}); return Scaffold( + appBar: AppBar( + title: _homeProvider.appBarExplorer, + actions: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: IconButton( + icon: _homeProvider.searchIcon, + color: Colors.grey[850], + onPressed: () { + if (_homeProvider.searchIcon.icon == Icons.search) { + _homeProvider.searchIcon = Icon( + Icons.close, + color: Colors.grey[850], + ); + _homeProvider.appBarExplorer = TextField( + autofocus: true, + controller: _homeProvider.searchQuery, + onChanged: (text) { + print("Clé tappé: $text"); + final String searchResult = + _historyProvider.isPubkey(context, text); + if (searchResult != '') { + _homeProvider.currentIndex = 0; + } + }, + style: TextStyle( + color: Colors.grey[850], + ), + decoration: InputDecoration( + prefixIcon: + Icon(Icons.search, color: Colors.grey[850]), + hintText: "Rechercher ...", + hintStyle: TextStyle(color: Colors.grey[850])), + ); + _homeProvider.handleSearchStart(); + } else { + _homeProvider.handleSearchEnd(); + } + })) + ], + backgroundColor: Color(0xffFFD58D), + ), floatingActionButton: Container( height: 80.0, width: 80.0, diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 96b8aea..01c8403 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -2,6 +2,7 @@ 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/screens/myWallets/walletsHome.dart'; import 'dart:ui'; import 'package:gecko/screens/settings.dart'; import 'package:provider/provider.dart'; @@ -11,230 +12,248 @@ class HomeScreen extends StatelessWidget { Widget build(BuildContext context) { HomeProvider _homeProvider = Provider.of(context); HistoryProvider _historyProvider = Provider.of(context); - return Scaffold( - drawer: Drawer( - child: Column( - children: [ - Expanded( - child: ListView(padding: EdgeInsets.zero, children: [ - DrawerHeader( - child: Column(children: [ - SizedBox(height: 0), - Image( - image: AssetImage('assets/icon/gecko_final.png'), - height: 130), - ]), - decoration: BoxDecoration( - color: Color(0xffD28928), - ), - ), - ListTile( - title: Text('Paramètres'), - onTap: () { - Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return SettingsScreen(); - }), - ); - }, - ), - ListTile( - title: Text('A propos'), - onTap: () { - // Update the state of the app. - // ... - }, - ), - ])), - Container( - child: Align( - alignment: FractionalOffset.bottomCenter, - child: Text('Ğecko v$appVersion'))), - SizedBox(height: 20) - ], - ), - ), - appBar: AppBar( - leading: Builder( - builder: (context) => IconButton( - icon: new Icon(Icons.menu, color: Colors.grey[850]), - onPressed: () => Scaffold.of(context).openDrawer(), - )), - title: _homeProvider.appBarTitle, - actions: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 16), - child: IconButton( - icon: _homeProvider.searchIcon, - color: Colors.grey[850], - onPressed: () { - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) { - // return SearchList(); - // }), - // ); + // _historyProvider.snackNode(context); - if (_homeProvider.searchIcon.icon == Icons.search) { - _homeProvider.searchIcon = Icon( - Icons.close, - color: Colors.grey[850], - ); - _homeProvider.appBarTitle = TextField( - autofocus: true, - controller: _homeProvider.searchQuery, - onChanged: (text) { - print("Clé tappé: $text"); - final String searchResult = - _historyProvider.isPubkey(context, text); - if (searchResult != '') { - _homeProvider.currentIndex = 0; - } - }, - style: TextStyle( - color: Colors.grey[850], - ), - decoration: InputDecoration( - prefixIcon: - Icon(Icons.search, color: Colors.grey[850]), - hintText: "Rechercher ...", - hintStyle: TextStyle(color: Colors.grey[850])), - ); - _homeProvider.handleSearchStart(); - } else { - _homeProvider.handleSearchEnd(); - } - })) - ], - backgroundColor: Color(0xffFFD58D), - ), - backgroundColor: Color(0xffF9F9F1), - body: // _homeProvider.currentTab[_homeProvider.currentIndex], - Column(children: [ - Padding( - padding: EdgeInsets.only(top: 22), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image( - image: AssetImage('assets/icon/gecko_final.png'), - height: 180), - ])), - Padding( - padding: EdgeInsets.only(top: 15), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "L’application de paiement Ğ1\nplus mobile qu’un lésard du Vietnam", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 15), - ) - ])), - Padding( - padding: EdgeInsets.only(top: 60), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column(children: [ - ClipOval( - child: Material( - color: Color(0xffFFD58D), // button color - child: Padding( - padding: EdgeInsets.all(17), - child: InkWell( - splashColor: Colors.black, // inkwell color - child: Image( - image: AssetImage('assets/qrcode-scan.png'), - height: 58), - onTap: () {}, - )), - ), - ), - SizedBox(height: 5), - Text( - "Payer par QR-Code", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 13), - ) - ]) - ])), - Padding( - padding: EdgeInsets.only(top: 60), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column(children: [ - ClipOval( - child: Material( - color: Color(0xffFFD58D), // button color - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 18, vertical: 14), - child: InkWell( - splashColor: Colors.black, // inkwell color - child: Image( - image: AssetImage('assets/blockchain.png'), - height: 65), - onTap: () {}, - )), - ), - ), - SizedBox(height: 5), - Text( - "Explorer\n", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 13), - ) + return Scaffold( + resizeToAvoidBottomInset: false, + drawer: Drawer( + child: Column( + children: [ + Expanded( + child: ListView(padding: EdgeInsets.zero, children: [ + DrawerHeader( + child: Column(children: [ + SizedBox(height: 0), + Image( + image: AssetImage('assets/icon/gecko_final.png'), + height: 130), ]), - SizedBox(width: 160), - Column(children: [ - ClipOval( - child: Material( - color: Color(0xffFFD58D), // button color - child: Padding( - padding: EdgeInsets.all(20), - child: InkWell( - splashColor: Colors.black, // inkwell color - child: Image( - image: AssetImage('assets/lock.png'), - height: 50), - onTap: () {}, - )), - ), - ), - SizedBox(height: 5), - Text( - "Gérer mes\nportefeuilles", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 13), - ) - ]) - ])) - ]), - // bottomNavigationBar: BottomNavigationBar( - // backgroundColor: Color(0xffFFD58D), - // fixedColor: Colors.grey[850], - // unselectedItemColor: Color(0xffBD935C), - // type: BottomNavigationBarType.fixed, - // onTap: (index) { - // _homeProvider.currentIndex = index; - // }, - // currentIndex: _homeProvider.currentIndex, - // items: [ - // BottomNavigationBarItem( - // icon: Image.asset('assets/block-space-disabled.png', height: 26), - // activeIcon: Image.asset('assets/blockchain.png', height: 26), - // label: 'Explorateur', - // ), - // BottomNavigationBarItem( - // icon: Icon(Icons.lock), - // label: 'Mes portefeuilles', - // ), - // ], - // ), - ); + decoration: BoxDecoration( + color: Color(0xffD28928), + ), + ), + ListTile( + title: Text('Paramètres'), + onTap: () { + Navigator.pop(context); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return SettingsScreen(); + }), + ); + }, + ), + ListTile( + title: Text('A propos'), + onTap: () { + // Update the state of the app. + // ... + }, + ), + ])), + Container( + child: Align( + alignment: FractionalOffset.bottomCenter, + child: Text('Ğecko v$appVersion'))), + SizedBox(height: 20) + ], + ), + ), + appBar: AppBar( + leading: Builder( + builder: (context) => IconButton( + icon: new Icon(Icons.menu, color: Colors.grey[850]), + onPressed: () => Scaffold.of(context).openDrawer(), + )), + title: _homeProvider.appBarTitle, + actions: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: IconButton( + icon: _homeProvider.searchIcon, + color: Colors.grey[850], + onPressed: () { + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) { + // return SearchList(); + // }), + // ); + + if (_homeProvider.searchIcon.icon == Icons.search) { + _homeProvider.searchIcon = Icon( + Icons.close, + color: Colors.grey[850], + ); + _homeProvider.appBarTitle = TextField( + autofocus: true, + controller: _homeProvider.searchQuery, + onChanged: (text) { + print("Clé tappé: $text"); + final String searchResult = + _historyProvider.isPubkey(context, text); + if (searchResult != '') { + _homeProvider.currentIndex = 0; + } + }, + style: TextStyle( + color: Colors.grey[850], + ), + decoration: InputDecoration( + prefixIcon: + Icon(Icons.search, color: Colors.grey[850]), + hintText: "Rechercher ...", + hintStyle: TextStyle(color: Colors.grey[850])), + ); + _homeProvider.handleSearchStart(); + } else { + _homeProvider.handleSearchEnd(); + } + })) + ], + backgroundColor: Color(0xffFFD58D), + ), + backgroundColor: Color(0xffF9F9F1), + body: // _homeProvider.currentTab[_homeProvider.currentIndex], + Builder( + builder: (context) => Column(children: [ + // _historyProvider.snackNode(context), + // SnackBar(content: Text('tataaa')), + + Padding( + padding: EdgeInsets.only(top: 22), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('assets/icon/gecko_final.png'), + height: 180), + ])), + Padding( + padding: EdgeInsets.only(top: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "L’application de paiement Ğ1\nplus mobile qu’un lésard du Vietnam", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.black, fontSize: 15), + ) + ])), + Padding( + padding: EdgeInsets.only(top: 60), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column(children: [ + ClipOval( + child: Material( + color: Color(0xffFFD58D), // button color + child: Padding( + padding: EdgeInsets.all(17), + child: InkWell( + splashColor: Colors.black, // inkwell color + child: Image( + image: + AssetImage('assets/qrcode-scan.png'), + height: 58), + onTap: () async { + await _historyProvider.scan(context); + }, + )), + ), + ), + SizedBox(height: 5), + Text( + "Payer par QR-Code", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.black, fontSize: 13), + ) + ]) + ])), + Padding( + padding: EdgeInsets.only(top: 60), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column(children: [ + ClipOval( + child: Material( + color: Color(0xffFFD58D), // button color + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 18, vertical: 14), + child: InkWell( + splashColor: Colors.black, // inkwell color + child: Image( + image: + AssetImage('assets/blockchain.png'), + height: 65), + onTap: () {}, + )), + ), + ), + SizedBox(height: 5), + Text( + "Explorer\n", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.black, fontSize: 13), + ) + ]), + SizedBox(width: 140), + Column(children: [ + ClipOval( + child: Material( + color: Color(0xffFFD58D), // button color + child: Padding( + padding: EdgeInsets.all(20), + child: InkWell( + splashColor: Colors.black, // inkwell color + child: Image( + image: AssetImage('assets/lock.png'), + height: 50), + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return WalletsHome(); + }), + ); + }, + )), + ), + ), + SizedBox(height: 5), + Text( + "Gérer mes\nportefeuilles", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.black, fontSize: 13), + ) + ]) + ])) + ]), + // bottomNavigationBar: BottomNavigationBar( + // backgroundColor: Color(0xffFFD58D), + // fixedColor: Colors.grey[850], + // unselectedItemColor: Color(0xffBD935C), + // type: BottomNavigationBarType.fixed, + // onTap: (index) { + // _homeProvider.currentIndex = index; + // }, + // currentIndex: _homeProvider.currentIndex, + // items: [ + // BottomNavigationBarItem( + // icon: Image.asset('assets/block-space-disabled.png', height: 26), + // activeIcon: Image.asset('assets/blockchain.png', height: 26), + // label: 'Explorateur', + // ), + // BottomNavigationBarItem( + // icon: Icon(Icons.lock), + // label: 'Mes portefeuilles', + // ), + // ], + // ), + )); } } diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index 9ea2c06..a9611a1 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -27,6 +27,11 @@ class WalletsHome extends StatelessWidget { } return Scaffold( + appBar: AppBar( + title: Text('Mes portefeuilles', + style: TextStyle(color: Colors.grey[850])), + backgroundColor: Color(0xffFFD58D), + ), floatingActionButton: Visibility( visible: (isWalletsExists && firstWalletDerivation != -1), child: Container( diff --git a/pubspec.yaml b/pubspec.yaml index 49542f5..ecc162e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: A new Flutter project. # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.1+13 +version: 0.0.1+14 environment: sdk: ">=2.7.0 <3.0.0"