diff --git a/lib/main.dart b/lib/main.dart index 3707b90..daf94e8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'home.dart'; +import 'package:gecko/ui/home.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/ui/historyWallets.dart b/lib/ui/historyElements.dart similarity index 95% rename from lib/ui/historyWallets.dart rename to lib/ui/historyElements.dart index 219d6d2..3c26d83 100644 --- a/lib/ui/historyWallets.dart +++ b/lib/ui/historyElements.dart @@ -18,12 +18,12 @@ import 'package:truncate/truncate.dart'; // } // } -class HistoryListView extends StatelessWidget { +class HistoryElements extends StatelessWidget { // const String({this.isPubkey}); // final PubkeyCallBack isPubkey; // GlobalKey _myKey = GlobalKey(); - const HistoryListView( + const HistoryElements( {Key key, @required ScrollController scrollController, @required this.transBC, diff --git a/lib/home.dart b/lib/ui/historyScreen.dart similarity index 75% rename from lib/home.dart rename to lib/ui/historyScreen.dart index 13d70e1..fc1b912 100644 --- a/lib/home.dart +++ b/lib/ui/historyScreen.dart @@ -1,62 +1,36 @@ import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:qrscan/qrscan.dart' as scanner; -import 'package:gecko/ui/generateWallets.dart'; -import 'package:gecko/ui/historyWallets.dart'; +import 'package:gecko/ui/historyElements.dart'; import 'dart:async'; import 'dart:typed_data'; import 'dart:ui'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'parsingGVA.dart'; -import 'query.dart'; +import 'package:gecko/parsingGVA.dart'; +import 'package:gecko/query.dart'; import 'package:sentry/sentry.dart' as sentry; -// method to call from widget to fetchmore queries -typedef FetchMore = dynamic Function(FetchMoreOptions options); - -typedef Refetch = Future Function(); - -typedef QueryBuilder = Widget Function( - QueryResult result, { - Refetch refetch, - FetchMore fetchMore, -}); - //ignore: must_be_immutable -class HomeScreen extends StatefulWidget { - // const HistoryListScreen({ - // final Key key, - // @required this.options, - // @required this.builder, - // }) : super(key: key); - - // final QueryOptions options; - // final QueryBuilder builder; - - HomeScreen({this.screens}); - - static const Tag = "HistoryListScreen"; - final List screens; +class HistoryScreen extends StatefulWidget { + const HistoryScreen({Key keyHistory}) : super(key: keyHistory); @override - _HomeScreenState createState() => _HomeScreenState(); + State createState() => HistoryScreenState(); } -class _HomeScreenState extends State { - int _currentIndex = 0; +class HistoryScreenState extends State { + int currentIndex = 0; Widget currentScreen; void onTabTapped(int index) { setState(() { - _currentIndex = index; + currentIndex = index; }); } Uint8List bytes = Uint8List(0); - final TextEditingController _outputPubkey = new TextEditingController(); - final nRepositories = 20; // String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug @@ -96,53 +70,6 @@ class _HomeScreenState extends State { print('Build pubkey : ' + pubkey); print('Build this.pubkey : ' + this.pubkey); print('isBuilding: ' + isBuilding.toString()); - return MaterialApp( - home: Scaffold( - backgroundColor: Colors.grey[300], - body: SafeArea( - child: IndexedStack( - index: _currentIndex, - children: [ - historyScreen(), - GenerateWalletScreen(), - // FriendsScreen() - ], - ), - ), - floatingActionButton: Container( - height: 80.0, - width: 80.0, - child: FittedBox( - child: FloatingActionButton( - onPressed: () => _scan(), - child: Container( - height: 40.0, - width: 40.0, - child: Image.asset('images/scanner.png')), - backgroundColor: Color.fromARGB(500, 204, 255, 255), - ), - ), - ), - bottomNavigationBar: BottomNavigationBar( - fixedColor: Colors.black, - type: BottomNavigationBarType.fixed, - onTap: onTabTapped, - currentIndex: _currentIndex, - items: [ - BottomNavigationBarItem( - icon: new Icon(Icons.format_list_bulleted), - label: 'HOME', - ), - BottomNavigationBarItem( - icon: new Icon(Icons.settings), - label: 'GENERATE WALLET', - ) - ], - ), - )); - } - - Widget historyScreen() { return Column(children: [ TextField( onChanged: (text) { @@ -256,7 +183,7 @@ class _HomeScreenState extends State { List _transBC = parseHistory(blockchainTX); return Expanded( - child: HistoryListView( + child: HistoryElements( scrollController: _scrollController, transBC: _transBC, historyData: result), @@ -267,7 +194,7 @@ class _HomeScreenState extends State { )); } - Future _scan() async { + Future scan() async { await Permission.camera.request(); String barcode; try { diff --git a/lib/ui/home.dart b/lib/ui/home.dart new file mode 100644 index 0000000..61ef4e0 --- /dev/null +++ b/lib/ui/home.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:gecko/ui/generateWallets.dart'; +import 'dart:typed_data'; +import 'dart:ui'; +import 'package:gecko/ui/historyScreen.dart'; + +//ignore: must_be_immutable +class HomeScreen extends StatefulWidget { + // const HistoryListScreen({ + // final Key key, + // @required this.options, + // @required this.builder, + // }) : super(key: key); + + // final QueryOptions options; + // final QueryBuilder builder; + + HomeScreen({this.screens}); + final List screens; + + @override + _HomeScreenState createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + GlobalKey _keyHistory = GlobalKey(); + + int _currentIndex = 0; + Widget currentScreen; + + void onTabTapped(int index) { + setState(() { + _currentIndex = index; + }); + } + + Uint8List bytes = Uint8List(0); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + backgroundColor: Colors.grey[300], + body: SafeArea( + child: IndexedStack( + index: _currentIndex, + children: [ + HistoryScreen( + keyHistory: _keyHistory, + ), + GenerateWalletScreen(), + // FriendsScreen() + ], + ), + ), + floatingActionButton: Container( + height: 80.0, + width: 80.0, + child: FittedBox( + child: FloatingActionButton( + onPressed: () => _keyHistory.currentState.scan(), // _scan(), + child: Container( + height: 40.0, + width: 40.0, + child: Image.asset('images/scanner.png')), + backgroundColor: Color.fromARGB(500, 204, 255, 255), + ), + ), + ), + bottomNavigationBar: BottomNavigationBar( + fixedColor: Colors.black, + type: BottomNavigationBarType.fixed, + onTap: onTabTapped, + currentIndex: _currentIndex, + items: [ + BottomNavigationBarItem( + icon: new Icon(Icons.format_list_bulleted), + label: 'HOME', + ), + BottomNavigationBarItem( + icon: new Icon(Icons.settings), + label: 'GENERATE WALLET', + ) + ], + ), + )); + } +}