refacto: export home widgets
This commit is contained in:
parent
d878fd8b37
commit
840932cbc2
|
@ -1,9 +1,7 @@
|
||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:bubble/bubble.dart';
|
|
||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/chest_data.dart';
|
import 'package:gecko/models/chest_data.dart';
|
||||||
import 'package:gecko/models/g1_wallets_list.dart';
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
|
@ -12,21 +10,18 @@ import 'package:gecko/providers/chest_provider.dart';
|
||||||
import 'package:gecko/providers/duniter_indexer.dart';
|
import 'package:gecko/providers/duniter_indexer.dart';
|
||||||
import 'package:gecko/providers/home.dart';
|
import 'package:gecko/providers/home.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/widgets/bubble_speak.dart';
|
||||||
import 'package:gecko/widgets/commons/animated_text.dart';
|
import 'package:gecko/widgets/commons/animated_text.dart';
|
||||||
import 'package:gecko/widgets/commons/common_elements.dart';
|
import 'package:gecko/widgets/commons/common_elements.dart';
|
||||||
import 'package:gecko/screens/myWallets/restore_chest.dart';
|
import 'package:gecko/screens/myWallets/restore_chest.dart';
|
||||||
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
|
||||||
import 'package:gecko/screens/myWallets/wallets_home.dart';
|
|
||||||
import 'package:gecko/screens/onBoarding/1.dart';
|
import 'package:gecko/screens/onBoarding/1.dart';
|
||||||
import 'package:gecko/screens/search.dart';
|
import 'package:gecko/widgets/drawer.dart';
|
||||||
import 'package:gecko/screens/settings.dart';
|
import 'package:gecko/widgets/home_buttons.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:gecko/screens/my_contacts.dart';
|
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const HomeScreen({Key? key}) : super(key: key);
|
const HomeScreen({Key? key}) : super(key: key);
|
||||||
|
@ -80,24 +75,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
duniterIndexer.getValidIndexerEndpoint();
|
duniterIndexer.getValidIndexerEndpoint();
|
||||||
|
|
||||||
await homeProviderInit.getValidEndpoints();
|
await homeProviderInit.getValidEndpoints();
|
||||||
// await configBox.delete('isCacheChecked');
|
|
||||||
if (configBox.get('isCacheChecked') == null) {
|
if (configBox.get('isCacheChecked') == null) {
|
||||||
configBox.put('isCacheChecked', false);
|
configBox.put('isCacheChecked', false);
|
||||||
}
|
}
|
||||||
// log.d(await configBox.get('endpoint'));
|
|
||||||
|
|
||||||
// var connectivityResult =
|
|
||||||
// await (Connectivity().checkConnectivity());
|
|
||||||
|
|
||||||
// if (connectivityResult != ConnectivityResult.mobile &&
|
|
||||||
// connectivityResult != ConnectivityResult.wifi) {
|
|
||||||
// homeProvider.changeMessage(
|
|
||||||
// "notConnectedToInternet".tr(), 0);
|
|
||||||
// sub.nodeConnected = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Améliore ce code car il y a un bug: parfois l'app se croit hors ligne, alors que c'est faux, le téléphone est bien connecté à internet
|
|
||||||
// (GPT vscode extension fixed it for my...)
|
|
||||||
HomeProvider homeProvider =
|
HomeProvider homeProvider =
|
||||||
Provider.of<HomeProvider>(context, listen: false);
|
Provider.of<HomeProvider>(context, listen: false);
|
||||||
Connectivity()
|
Connectivity()
|
||||||
|
@ -121,7 +102,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// await sub.connectNode(ctx);
|
|
||||||
}
|
}
|
||||||
// _duniterIndexer.checkIndexerEndpointBackground();
|
// _duniterIndexer.checkIndexerEndpointBackground();
|
||||||
});
|
});
|
||||||
|
@ -144,83 +124,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
drawer: Drawer(
|
drawer: MainDrawer(isWalletsExists: isWalletsExists),
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: ListView(padding: EdgeInsets.zero, children: <Widget>[
|
|
||||||
DrawerHeader(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: orangeC,
|
|
||||||
),
|
|
||||||
child: Column(children: const <Widget>[
|
|
||||||
SizedBox(height: 0),
|
|
||||||
Image(
|
|
||||||
image: AssetImage('assets/icon/gecko_final.png'),
|
|
||||||
height: 130),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
key: keyParameters,
|
|
||||||
title: Text('parameters'.tr()),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return SettingsScreen();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (isWalletsExists)
|
|
||||||
ListTile(
|
|
||||||
key: keyContacts,
|
|
||||||
title: Text('contactsManagement'.tr()),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return const ContactsScreen();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
])),
|
|
||||||
Align(
|
|
||||||
alignment: FractionalOffset.bottomCenter,
|
|
||||||
child: InkWell(
|
|
||||||
key: keyCopyAddress,
|
|
||||||
splashColor: orangeC,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
child: Text('Ğecko v$appVersion')),
|
|
||||||
onTap: () {
|
|
||||||
Clipboard.setData(
|
|
||||||
ClipboardData(text: 'Ğecko v$appVersion'));
|
|
||||||
snackMessage(context,
|
|
||||||
message:
|
|
||||||
'Le numéro de version de Ğecko a été copié dans votre presse papier',
|
|
||||||
duration: 4);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: const Color(0xffF9F9F1),
|
backgroundColor: const Color(0xffF9F9F1),
|
||||||
body: isWalletsExists ? geckHome(context) : welcomeHome(context));
|
body: isWalletsExists ? geckHome(context) : welcomeHome(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget geckHome(context) {
|
Widget geckHome(context) {
|
||||||
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
|
|
||||||
final homeProvider = Provider.of<HomeProvider>(context, listen: false);
|
|
||||||
Provider.of<ChestProvider>(context);
|
Provider.of<ChestProvider>(context);
|
||||||
|
|
||||||
WalletsProfilesProvider historyProvider =
|
|
||||||
Provider.of<WalletsProfilesProvider>(context);
|
|
||||||
final statusBarHeight = MediaQuery.of(context).padding.top;
|
final statusBarHeight = MediaQuery.of(context).padding.top;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
|
@ -299,172 +211,7 @@ Widget geckHome(context) {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(children: <Widget>[
|
child: const HomeButtons(),
|
||||||
const Spacer(),
|
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
|
||||||
Column(children: <Widget>[
|
|
||||||
Container(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.black,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
blurRadius: 2,
|
|
||||||
offset: Offset(1, 1.5),
|
|
||||||
spreadRadius: 0.5)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: ClipOval(
|
|
||||||
child: Material(
|
|
||||||
color: orangeC, // button color
|
|
||||||
child: InkWell(
|
|
||||||
key: keyOpenSearch,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(18),
|
|
||||||
child: Image(
|
|
||||||
image:
|
|
||||||
const AssetImage('assets/home/loupe.png'),
|
|
||||||
height: 62 * ratio),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return const SearchScreen();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
"searchWallet".tr(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 15 * ratio,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
const SizedBox(width: 120),
|
|
||||||
Column(children: <Widget>[
|
|
||||||
Container(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.black,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
blurRadius: 2,
|
|
||||||
offset: Offset(1, 1.5),
|
|
||||||
spreadRadius: 0.5)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: ClipOval(
|
|
||||||
key: keyOpenWalletsHomme,
|
|
||||||
child: Material(
|
|
||||||
color: homeProvider.isWalletBoxInit
|
|
||||||
? orangeC
|
|
||||||
: Colors.grey[500], // button color
|
|
||||||
child: InkWell(
|
|
||||||
onTap: !homeProvider.isWalletBoxInit
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
WalletData? defaultWallet =
|
|
||||||
myWalletProvider.getDefaultWallet();
|
|
||||||
String? pin;
|
|
||||||
if (myWalletProvider.pinCode == '') {
|
|
||||||
pin = await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (homeContext) {
|
|
||||||
return UnlockingWallet(
|
|
||||||
wallet: defaultWallet);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (pin != null ||
|
|
||||||
myWalletProvider.pinCode != '') {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return const WalletsHome();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// log.d(_myWalletProvider.pinCode);
|
|
||||||
|
|
||||||
// Navigator.pushNamed(
|
|
||||||
// context, '/mywallets')));
|
|
||||||
},
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(18),
|
|
||||||
child: Image(
|
|
||||||
image: const AssetImage(
|
|
||||||
'assets/home/wallet.png'),
|
|
||||||
height: 68 * ratio))),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
"manageWallets".tr(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 15 * ratio,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
)
|
|
||||||
])
|
|
||||||
]),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(top: 35 * ratio),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Column(children: <Widget>[
|
|
||||||
Container(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.black,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
blurRadius: 2,
|
|
||||||
offset: Offset(1, 1.5),
|
|
||||||
spreadRadius: 0.5)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: ClipOval(
|
|
||||||
child: Material(
|
|
||||||
color: orangeC, // button color
|
|
||||||
child: InkWell(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(18),
|
|
||||||
child: Image(
|
|
||||||
image: const AssetImage(
|
|
||||||
'assets/home/qrcode.png'),
|
|
||||||
height: 68 * ratio)),
|
|
||||||
onTap: () async {
|
|
||||||
await historyProvider.scan(context);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
"scanQRCode".tr(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 15 * ratio,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
)
|
|
||||||
])
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
SizedBox(height: isTall ? 80 : 40)
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
|
@ -561,7 +308,7 @@ Widget welcomeHome(context) {
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 180,
|
left: 180,
|
||||||
child: bubbleSpeak("noLizard".tr()),
|
child: BubbleSpeak(text: "noLizard".tr()),
|
||||||
),
|
),
|
||||||
const Positioned(
|
const Positioned(
|
||||||
left: 200,
|
left: 200,
|
||||||
|
@ -635,19 +382,3 @@ Widget welcomeHome(context) {
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bubbleSpeak(String text, {double? long, Key? textKey}) {
|
|
||||||
return Bubble(
|
|
||||||
padding: long == null
|
|
||||||
? const BubbleEdges.all(20)
|
|
||||||
: BubbleEdges.symmetric(horizontal: long, vertical: 30),
|
|
||||||
elevation: 5,
|
|
||||||
color: backgroundColor,
|
|
||||||
child: Text(
|
|
||||||
text,
|
|
||||||
key: textKey,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.black, fontSize: 21, fontWeight: FontWeight.w400),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import 'package:bubble/bubble.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
|
||||||
|
class BubbleSpeak extends StatelessWidget {
|
||||||
|
const BubbleSpeak({
|
||||||
|
required this.text,
|
||||||
|
this.long,
|
||||||
|
this.textKey,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String text;
|
||||||
|
final double? long;
|
||||||
|
final Key? textKey;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Bubble(
|
||||||
|
padding: long == null
|
||||||
|
? const BubbleEdges.all(20)
|
||||||
|
: BubbleEdges.symmetric(horizontal: long, vertical: 30),
|
||||||
|
elevation: 5,
|
||||||
|
color: backgroundColor,
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
key: textKey,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black, fontSize: 21, fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/widgets_keys.dart';
|
||||||
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
|
import 'package:gecko/screens/debug_screen.dart';
|
||||||
|
import 'package:gecko/screens/my_contacts.dart';
|
||||||
|
import 'package:gecko/screens/settings.dart';
|
||||||
|
|
||||||
|
class MainDrawer extends StatelessWidget {
|
||||||
|
const MainDrawer({
|
||||||
|
Key? key,
|
||||||
|
required this.isWalletsExists,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final bool isWalletsExists;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Drawer(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: ListView(padding: EdgeInsets.zero, children: <Widget>[
|
||||||
|
DrawerHeader(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: orangeC,
|
||||||
|
),
|
||||||
|
child: Column(children: const <Widget>[
|
||||||
|
SizedBox(height: 0),
|
||||||
|
Image(
|
||||||
|
image: AssetImage('assets/icon/gecko_final.png'),
|
||||||
|
height: 130),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
key: keyParameters,
|
||||||
|
title: Text('parameters'.tr()),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return SettingsScreen();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (isWalletsExists)
|
||||||
|
ListTile(
|
||||||
|
key: keyContacts,
|
||||||
|
title: Text('contactsManagement'.tr()),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const ContactsScreen();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (kDebugMode)
|
||||||
|
ListTile(
|
||||||
|
key: keyParameters,
|
||||||
|
title: Text('Debug screen'.tr()),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const DebugScreen();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
Align(
|
||||||
|
alignment: FractionalOffset.bottomCenter,
|
||||||
|
child: InkWell(
|
||||||
|
key: keyCopyAddress,
|
||||||
|
splashColor: orangeC,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Text('Ğecko v$appVersion')),
|
||||||
|
onTap: () {
|
||||||
|
Clipboard.setData(ClipboardData(text: 'Ğecko v$appVersion'));
|
||||||
|
snackMessage(context,
|
||||||
|
message:
|
||||||
|
'Le numéro de version de Ğecko a été copié dans votre presse papier',
|
||||||
|
duration: 4);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/models/widgets_keys.dart';
|
||||||
|
import 'package:gecko/providers/home.dart';
|
||||||
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/wallets_home.dart';
|
||||||
|
import 'package:gecko/screens/search.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class HomeButtons extends StatelessWidget {
|
||||||
|
const HomeButtons({
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
|
||||||
|
final homeProvider = Provider.of<HomeProvider>(context, listen: false);
|
||||||
|
final historyProvider = Provider.of<WalletsProfilesProvider>(context);
|
||||||
|
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
const Spacer(),
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||||
|
Column(children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
blurRadius: 2, offset: Offset(1, 1.5), spreadRadius: 0.5)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipOval(
|
||||||
|
child: Material(
|
||||||
|
color: orangeC, // button color
|
||||||
|
child: InkWell(
|
||||||
|
key: keyOpenSearch,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(18),
|
||||||
|
child: Image(
|
||||||
|
image: const AssetImage('assets/home/loupe.png'),
|
||||||
|
height: 62 * ratio),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const SearchScreen();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
"searchWallet".tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 15 * ratio,
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
const SizedBox(width: 120),
|
||||||
|
Column(children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
blurRadius: 2, offset: Offset(1, 1.5), spreadRadius: 0.5)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipOval(
|
||||||
|
key: keyOpenWalletsHomme,
|
||||||
|
child: Material(
|
||||||
|
color: homeProvider.isWalletBoxInit
|
||||||
|
? orangeC
|
||||||
|
: Colors.grey[500], // button color
|
||||||
|
child: InkWell(
|
||||||
|
onTap: !homeProvider.isWalletBoxInit
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
WalletData? defaultWallet =
|
||||||
|
myWalletProvider.getDefaultWallet();
|
||||||
|
String? pin;
|
||||||
|
if (myWalletProvider.pinCode == '') {
|
||||||
|
pin = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (homeContext) {
|
||||||
|
return UnlockingWallet(
|
||||||
|
wallet: defaultWallet);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (pin != null || myWalletProvider.pinCode != '') {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const WalletsHome();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(18),
|
||||||
|
child: Image(
|
||||||
|
image: const AssetImage('assets/home/wallet.png'),
|
||||||
|
height: 68 * ratio))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
"manageWallets".tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 15 * ratio,
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 35 * ratio),
|
||||||
|
child:
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||||
|
Column(children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
blurRadius: 2, offset: Offset(1, 1.5), spreadRadius: 0.5)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipOval(
|
||||||
|
child: Material(
|
||||||
|
color: orangeC, // button color
|
||||||
|
child: InkWell(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(18),
|
||||||
|
child: Image(
|
||||||
|
image: const AssetImage('assets/home/qrcode.png'),
|
||||||
|
height: 68 * ratio)),
|
||||||
|
onTap: () async {
|
||||||
|
await historyProvider.scan(context);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
"scanQRCode".tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 15 * ratio,
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
SizedBox(height: isTall ? 80 : 40)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue