2021-02-24 08:34:39 +01:00
|
|
|
import 'package:dubp/dubp.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:gecko/globals.dart';
|
2021-11-17 06:20:23 +01:00
|
|
|
import 'package:gecko/models/chest_provider.dart';
|
2021-02-16 17:40:25 +01:00
|
|
|
import 'package:gecko/models/history.dart';
|
2021-01-08 01:20:03 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
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';
|
2021-01-08 00:12:22 +01:00
|
|
|
import 'dart:ui';
|
2021-01-28 15:26:26 +01:00
|
|
|
import 'package:gecko/screens/settings.dart';
|
2021-02-27 20:29:35 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-08 00:12:22 +01:00
|
|
|
|
2021-01-26 21:00:26 +01:00
|
|
|
class HomeScreen extends StatelessWidget {
|
2021-11-14 19:21:20 +01:00
|
|
|
const HomeScreen({Key key}) : super(key: key);
|
|
|
|
|
2021-01-08 00:12:22 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-27 20:29:35 +01:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2021-11-19 00:17:00 +01:00
|
|
|
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
2021-02-16 17:40:25 +01:00
|
|
|
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
2021-02-22 19:44:58 +01:00
|
|
|
HistoryProvider _historyStatic = HistoryProvider('');
|
2021-02-27 20:29:35 +01:00
|
|
|
MyWalletsProvider _myWalletProvider =
|
|
|
|
Provider.of<MyWalletsProvider>(context);
|
2021-11-17 06:20:23 +01:00
|
|
|
Provider.of<ChestProvider>(context);
|
2021-03-08 00:32:18 +01:00
|
|
|
|
2021-11-17 06:20:23 +01:00
|
|
|
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
2021-11-14 03:12:07 +01:00
|
|
|
|
2021-11-19 03:18:39 +01:00
|
|
|
final double statusBarHeight = MediaQuery.of(context).padding.top;
|
2021-11-07 04:23:05 +01:00
|
|
|
|
2021-03-08 00:32:18 +01:00
|
|
|
isTall = false;
|
|
|
|
ratio = 1;
|
|
|
|
if (MediaQuery.of(context).size.height >= 930) {
|
|
|
|
isTall = true;
|
|
|
|
ratio = 1.125;
|
|
|
|
}
|
2021-01-09 09:17:01 +01:00
|
|
|
return Scaffold(
|
2021-11-15 18:05:08 +01:00
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
drawer: Drawer(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: ListView(padding: EdgeInsets.zero, children: <Widget>[
|
|
|
|
DrawerHeader(
|
|
|
|
child: Column(children: const <Widget>[
|
|
|
|
SizedBox(height: 0),
|
|
|
|
Image(
|
|
|
|
image: AssetImage('assets/icon/gecko_final.png'),
|
|
|
|
height: 130),
|
|
|
|
]),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: orangeC,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
key: const Key('parameters'),
|
|
|
|
title: const Text('Paramètres'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return SettingsScreen();
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: const Text('A propos'),
|
|
|
|
onTap: () {
|
|
|
|
// Update the state of the app.
|
|
|
|
// ...
|
|
|
|
},
|
|
|
|
),
|
|
|
|
])),
|
|
|
|
Align(
|
|
|
|
alignment: FractionalOffset.bottomCenter,
|
|
|
|
child: Text('Ğecko v$appVersion')),
|
|
|
|
const SizedBox(height: 20)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
backgroundColor: const Color(0xffF9F9F1),
|
|
|
|
body: Builder(
|
|
|
|
builder: (ctx) => StatefulWrapper(
|
|
|
|
onInit: () {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
DubpRust.setup();
|
|
|
|
_historyStatic.snackNode(ctx);
|
|
|
|
});
|
|
|
|
},
|
2021-11-19 00:17:00 +01:00
|
|
|
child: Container(
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
image: AssetImage("assets/home/background.png"),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
2021-11-15 18:05:08 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
child:
|
|
|
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
|
|
|
|
Widget>[
|
|
|
|
Stack(children: <Widget>[
|
|
|
|
Positioned(
|
|
|
|
top: statusBarHeight + 10,
|
|
|
|
left: 15,
|
|
|
|
child: Builder(
|
|
|
|
builder: (context) => IconButton(
|
|
|
|
key: const Key('drawerMenu'),
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.menu,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 35,
|
2021-11-15 18:05:08 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const Align(
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage('assets/home/header.png'), height: 210),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 15 * ratio),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: const <Widget>[
|
|
|
|
Text(
|
|
|
|
"y'a pas de lézard ;-)",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 24,
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
shadows: <Shadow>[
|
|
|
|
Shadow(
|
|
|
|
offset: Offset(0, 0),
|
|
|
|
blurRadius: 20,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
Shadow(
|
|
|
|
offset: Offset(0, 0),
|
|
|
|
blurRadius: 20,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
colors: [
|
|
|
|
Colors.transparent,
|
|
|
|
Colors.black.withOpacity(0.9),
|
|
|
|
],
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
),
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
const Spacer(),
|
|
|
|
Row(
|
2021-11-19 00:17:00 +01:00
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2021-11-19 03:18:39 +01:00
|
|
|
children: <Widget>[
|
|
|
|
Column(children: <Widget>[
|
|
|
|
Container(
|
|
|
|
child: ClipOval(
|
|
|
|
child: Material(
|
|
|
|
color: orangeC, // button color
|
|
|
|
child: InkWell(
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(18),
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage(
|
|
|
|
'assets/home/loupe.png'),
|
|
|
|
height: 70)),
|
|
|
|
onTap: () {
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// MaterialPageRoute(
|
|
|
|
// builder: (context) {
|
|
|
|
// return TemplateScreen();
|
|
|
|
// }),
|
|
|
|
// );
|
|
|
|
}),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.black,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
blurRadius: 2,
|
|
|
|
offset: Offset(1, 1.5),
|
|
|
|
spreadRadius: 0.5)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
const Text(
|
|
|
|
"Rechercher un\nportfeuille",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 17,
|
|
|
|
fontWeight: FontWeight.w500),
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
const SizedBox(width: 120),
|
|
|
|
Column(children: <Widget>[
|
|
|
|
Container(
|
|
|
|
child: ClipOval(
|
|
|
|
key: const Key('manageWallets'),
|
|
|
|
child: Material(
|
|
|
|
color: orangeC, // button color
|
|
|
|
child: InkWell(
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(18),
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage(
|
|
|
|
'assets/home/wallet.png'),
|
|
|
|
height: 75)),
|
|
|
|
onTap: () {
|
|
|
|
WalletData defaultWallet =
|
|
|
|
_myWalletProvider.getDefaultWallet(
|
|
|
|
configBox.get('currentChest'));
|
|
|
|
isWalletsExists
|
|
|
|
? Navigator.push(context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return UnlockingWallet(
|
|
|
|
wallet: defaultWallet,
|
|
|
|
action: "mywallets",
|
|
|
|
);
|
|
|
|
}))
|
|
|
|
|
|
|
|
// Navigator.pushNamed(
|
|
|
|
// context, '/mywallets')
|
|
|
|
: Navigator.push(context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return const NoKeyChainScreen();
|
|
|
|
}));
|
|
|
|
}),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.black,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
blurRadius: 2,
|
|
|
|
offset: Offset(1, 1.5),
|
|
|
|
spreadRadius: 0.5)
|
|
|
|
],
|
|
|
|
),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
const SizedBox(height: 12),
|
|
|
|
const Text(
|
|
|
|
"Gérer mes\nportefeuilles",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 17,
|
|
|
|
fontWeight: FontWeight.w500),
|
|
|
|
)
|
|
|
|
])
|
2021-11-19 00:17:00 +01:00
|
|
|
]),
|
2021-11-19 03:18:39 +01:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 40),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Column(children: <Widget>[
|
|
|
|
Container(
|
|
|
|
child: ClipOval(
|
|
|
|
child: Material(
|
|
|
|
color: orangeC, // button color
|
|
|
|
child: InkWell(
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(18),
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage(
|
|
|
|
'assets/home/qrcode.png'),
|
|
|
|
height: 75)),
|
|
|
|
onTap: () async {
|
|
|
|
await _historyProvider.scan(context);
|
|
|
|
}),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.black,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
blurRadius: 2,
|
|
|
|
offset: Offset(1, 1.5),
|
|
|
|
spreadRadius: 0.5)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
const Text(
|
|
|
|
"Scanner un\nQR code",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 17,
|
|
|
|
fontWeight: FontWeight.w500),
|
|
|
|
)
|
|
|
|
])
|
|
|
|
]),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
SizedBox(height: isTall ? 80 : 40)
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]),
|
2021-11-19 00:17:00 +01:00
|
|
|
),
|
2021-11-15 18:05:08 +01:00
|
|
|
),
|
|
|
|
),
|
2021-11-19 03:18:39 +01:00
|
|
|
// bottomNavigationBar: BottomNavigationBar(
|
|
|
|
// backgroundColor: backgroundColor,
|
|
|
|
// fixedColor: Colors.grey[850],
|
|
|
|
// unselectedItemColor: const 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',
|
|
|
|
// ),
|
|
|
|
// const BottomNavigationBarItem(
|
|
|
|
// icon: Icon(Icons.lock),
|
|
|
|
// label: 'Mes portefeuilles',
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
2021-11-15 18:05:08 +01:00
|
|
|
);
|
2021-02-22 19:44:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class StatefulWrapper extends StatefulWidget {
|
|
|
|
final Function onInit;
|
|
|
|
final Widget child;
|
2021-11-14 19:21:20 +01:00
|
|
|
const StatefulWrapper({Key key, @required this.onInit, @required this.child})
|
|
|
|
: super(key: key);
|
2021-02-22 19:44:58 +01:00
|
|
|
@override
|
|
|
|
_StatefulWrapperState createState() => _StatefulWrapperState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _StatefulWrapperState extends State<StatefulWrapper> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
if (widget.onInit != null) {
|
|
|
|
widget.onInit();
|
|
|
|
}
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return widget.child;
|
2021-01-08 00:12:22 +01:00
|
|
|
}
|
|
|
|
}
|