2022-05-28 19:13:30 +02:00
|
|
|
import 'dart:io';
|
|
|
|
|
2022-06-17 01:13:14 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2021-02-27 20:29:35 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-03-11 07:08:45 +01:00
|
|
|
import 'package:gecko/globals.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/models/chest_data.dart';
|
2022-06-14 21:55:33 +02:00
|
|
|
import 'package:gecko/providers/duniter_indexer.dart';
|
2022-05-27 16:58:03 +02:00
|
|
|
import 'package:gecko/providers/home.dart';
|
2021-12-23 15:13:58 +01:00
|
|
|
import 'package:gecko/providers/my_wallets.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/models/wallet_data.dart';
|
2021-01-13 00:00:11 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2022-06-12 19:20:15 +02:00
|
|
|
import 'package:gecko/providers/substrate_sdk.dart';
|
2021-12-24 15:27:38 +01:00
|
|
|
import 'package:gecko/providers/wallet_options.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/screens/common_elements.dart';
|
2021-11-18 04:41:45 +01:00
|
|
|
import 'package:gecko/screens/myWallets/chest_options.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/screens/myWallets/choose_chest.dart';
|
2022-05-31 18:23:56 +02:00
|
|
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/screens/myWallets/wallet_options.dart';
|
2021-01-28 15:10:09 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-13 00:00:11 +01:00
|
|
|
|
2021-01-26 21:00:26 +01:00
|
|
|
class WalletsHome extends StatelessWidget {
|
2021-12-23 12:36:09 +01:00
|
|
|
const WalletsHome({Key? key}) : super(key: key);
|
2021-11-14 19:21:20 +01:00
|
|
|
|
2021-01-13 00:00:11 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-27 20:29:35 +01:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2021-01-28 15:10:09 +01:00
|
|
|
MyWalletsProvider myWalletProvider =
|
|
|
|
Provider.of<MyWalletsProvider>(context);
|
2022-05-27 16:58:03 +02:00
|
|
|
HomeProvider _homeProvider =
|
|
|
|
Provider.of<HomeProvider>(context, listen: false);
|
2021-03-19 06:33:48 +01:00
|
|
|
|
2021-12-23 12:36:09 +01:00
|
|
|
final int? _currentChestNumber = myWalletProvider.getCurrentChest();
|
|
|
|
final ChestData _currentChest = chestBox.get(_currentChestNumber)!;
|
2021-12-01 08:14:07 +01:00
|
|
|
myWalletProvider.listWallets =
|
|
|
|
myWalletProvider.readAllWallets(_currentChestNumber);
|
2021-01-26 21:00:26 +01:00
|
|
|
|
2021-04-03 00:07:03 +02:00
|
|
|
return WillPopScope(
|
2021-11-09 04:22:04 +01:00
|
|
|
onWillPop: () {
|
2022-05-31 18:23:56 +02:00
|
|
|
// myWalletProvider.pinCode = myWalletProvider.mnemonic = '';
|
2021-11-09 04:22:04 +01:00
|
|
|
Navigator.popUntil(
|
|
|
|
context,
|
|
|
|
ModalRoute.withName('/'),
|
|
|
|
);
|
|
|
|
return Future<bool>.value(true);
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
2022-05-29 00:00:57 +02:00
|
|
|
backgroundColor: backgroundColor,
|
2021-11-09 04:22:04 +01:00
|
|
|
appBar: AppBar(
|
2022-05-28 00:04:37 +02:00
|
|
|
elevation: 1,
|
2021-11-15 04:16:25 +01:00
|
|
|
toolbarHeight: 60 * ratio,
|
2021-11-09 04:22:04 +01:00
|
|
|
leading: IconButton(
|
2021-11-14 19:21:20 +01:00
|
|
|
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
2021-11-09 04:22:04 +01:00
|
|
|
onPressed: () {
|
2022-05-31 18:23:56 +02:00
|
|
|
// myWalletProvider.pinCode = myWalletProvider.mnemonic = '';
|
2021-11-09 04:22:04 +01:00
|
|
|
Navigator.popUntil(
|
|
|
|
context,
|
|
|
|
ModalRoute.withName('/'),
|
|
|
|
);
|
|
|
|
}),
|
2021-12-23 12:36:09 +01:00
|
|
|
title: Text(_currentChest.name!,
|
2021-11-14 19:21:20 +01:00
|
|
|
key: const Key('myWallets'),
|
|
|
|
style: TextStyle(color: Colors.grey[850])),
|
|
|
|
backgroundColor: const Color(0xffFFD58D),
|
2021-11-09 04:22:04 +01:00
|
|
|
),
|
2022-05-28 21:48:04 +02:00
|
|
|
bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
2021-11-09 04:22:04 +01:00
|
|
|
body: SafeArea(
|
2022-06-12 18:03:17 +02:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
myWalletsTiles(context, _currentChestNumber!),
|
|
|
|
CommonElements().offlineInfo(context),
|
|
|
|
],
|
|
|
|
),
|
2021-11-09 04:22:04 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-18 04:41:45 +01:00
|
|
|
Widget chestOptions(
|
|
|
|
BuildContext context, MyWalletsProvider _myWalletProvider) {
|
2021-11-09 04:22:04 +01:00
|
|
|
return Column(children: [
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 50),
|
2021-11-09 04:22:04 +01:00
|
|
|
SizedBox(
|
2021-12-23 21:44:24 +01:00
|
|
|
height: 90,
|
|
|
|
width: 420,
|
2021-11-11 14:45:12 +01:00
|
|
|
child: ElevatedButton.icon(
|
|
|
|
icon: Image.asset(
|
|
|
|
'assets/chests/config.png',
|
2021-12-23 21:44:24 +01:00
|
|
|
height: 60,
|
2021-11-11 14:45:12 +01:00
|
|
|
),
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
elevation: 2,
|
|
|
|
primary: floattingYellow, // background
|
|
|
|
onPrimary: Colors.black, // foreground
|
|
|
|
),
|
2021-11-18 04:41:45 +01:00
|
|
|
onPressed: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return ChestOptions(walletProvider: _myWalletProvider);
|
|
|
|
}),
|
|
|
|
),
|
2022-06-17 01:13:14 +02:00
|
|
|
label: Text(
|
|
|
|
" " + "manageChest".tr(),
|
|
|
|
style: const TextStyle(
|
2021-12-23 21:44:24 +01:00
|
|
|
fontSize: 22,
|
2021-11-11 14:45:12 +01:00
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
color: Color(0xff8a3c0f),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 30),
|
2022-06-01 21:00:17 +02:00
|
|
|
InkWell(
|
2022-06-17 01:13:14 +02:00
|
|
|
key: const Key('changeChest'),
|
2022-06-01 21:00:17 +02:00
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return const ChooseChest();
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: SizedBox(
|
|
|
|
width: 400,
|
|
|
|
height: 50,
|
|
|
|
child: Center(
|
2022-06-17 01:13:14 +02:00
|
|
|
child: Text('changeChest'.tr(),
|
2022-06-01 21:00:17 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 22,
|
|
|
|
color: orangeC,
|
|
|
|
fontWeight: FontWeight.w500))),
|
|
|
|
),
|
|
|
|
),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 30)
|
2021-11-09 04:22:04 +01:00
|
|
|
]);
|
2021-03-10 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
2022-05-19 07:00:25 +02:00
|
|
|
Widget myWalletsTiles(BuildContext context, int _currentChestNumber) {
|
2021-03-10 15:41:56 +01:00
|
|
|
MyWalletsProvider _myWalletProvider =
|
|
|
|
Provider.of<MyWalletsProvider>(context);
|
2021-12-24 15:27:38 +01:00
|
|
|
WalletOptionsProvider _walletOptions =
|
|
|
|
Provider.of<WalletOptionsProvider>(context, listen: false);
|
2022-06-14 21:55:33 +02:00
|
|
|
DuniterIndexer _duniterIndexer =
|
|
|
|
Provider.of<DuniterIndexer>(context, listen: false);
|
2021-03-10 15:41:56 +01:00
|
|
|
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
|
|
|
|
|
|
|
if (!isWalletsExists) {
|
2021-11-14 19:21:20 +01:00
|
|
|
return const Text('');
|
2021-03-10 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
2021-03-31 02:38:44 +02:00
|
|
|
if (_myWalletProvider.listWallets.isEmpty) {
|
2021-03-10 15:41:56 +01:00
|
|
|
return Expanded(
|
2021-11-14 19:21:20 +01:00
|
|
|
child: Column(children: const <Widget>[
|
2021-03-21 00:35:32 +01:00
|
|
|
Center(
|
|
|
|
child: Text(
|
|
|
|
'Veuillez générer votre premier portefeuille',
|
|
|
|
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
|
|
|
)),
|
|
|
|
]));
|
2021-03-10 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
2021-03-31 02:38:44 +02:00
|
|
|
List _listWallets = _myWalletProvider.listWallets;
|
2022-05-27 16:58:03 +02:00
|
|
|
WalletData? defaultWallet = _myWalletProvider.getDefaultWallet();
|
2021-12-23 21:44:24 +01:00
|
|
|
final double screenWidth = MediaQuery.of(context).size.width;
|
|
|
|
int nTule = 2;
|
|
|
|
|
|
|
|
if (screenWidth >= 900) {
|
|
|
|
nTule = 4;
|
|
|
|
} else if (screenWidth >= 650) {
|
|
|
|
nTule = 3;
|
|
|
|
}
|
2021-03-10 15:41:56 +01:00
|
|
|
|
2021-11-09 04:22:04 +01:00
|
|
|
return CustomScrollView(slivers: <Widget>[
|
2021-11-14 19:21:20 +01:00
|
|
|
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
2022-05-28 19:13:30 +02:00
|
|
|
|
2021-11-09 04:22:04 +01:00
|
|
|
SliverGrid.count(
|
2021-11-14 19:21:20 +01:00
|
|
|
key: const Key('listWallets'),
|
2021-12-23 21:44:24 +01:00
|
|
|
crossAxisCount: nTule,
|
2021-11-09 04:22:04 +01:00
|
|
|
childAspectRatio: 1,
|
|
|
|
crossAxisSpacing: 0,
|
|
|
|
mainAxisSpacing: 0,
|
|
|
|
children: <Widget>[
|
2021-12-23 12:36:09 +01:00
|
|
|
for (WalletData _repository in _listWallets as Iterable<WalletData>)
|
2021-11-09 04:22:04 +01:00
|
|
|
Padding(
|
2021-11-14 19:21:20 +01:00
|
|
|
padding: const EdgeInsets.all(16),
|
2021-11-11 14:45:12 +01:00
|
|
|
child: GestureDetector(
|
2021-12-19 21:05:04 +01:00
|
|
|
onTap: () {
|
2021-12-30 00:51:04 +01:00
|
|
|
// _walletOptions.readLocalWallet(context, _repository,
|
|
|
|
// _myWalletProvider.pinCode, pinLength);
|
2022-05-19 07:00:25 +02:00
|
|
|
_walletOptions.getAddress(
|
|
|
|
_currentChestNumber, _repository.derivation!);
|
2021-11-11 14:45:12 +01:00
|
|
|
Navigator.push(
|
2021-12-20 21:33:03 +01:00
|
|
|
context,
|
|
|
|
SmoothTransition(
|
|
|
|
page: WalletOptions(
|
2021-11-11 14:45:12 +01:00
|
|
|
wallet: _repository,
|
2021-12-20 21:33:03 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2021-11-11 14:45:12 +01:00
|
|
|
|
|
|
|
// Navigator.push(context,
|
|
|
|
// MaterialPageRoute(builder: (context) {
|
|
|
|
// return UnlockingWallet(wallet: _repository);
|
|
|
|
// }));
|
|
|
|
},
|
|
|
|
child: ClipOvalShadow(
|
2021-11-14 19:21:20 +01:00
|
|
|
shadow: const Shadow(
|
2021-11-11 14:45:12 +01:00
|
|
|
color: Colors.transparent,
|
|
|
|
offset: Offset(0, 0),
|
|
|
|
blurRadius: 5,
|
|
|
|
),
|
|
|
|
clipper: CustomClipperOval(),
|
|
|
|
child: ClipRRect(
|
2021-11-14 19:21:20 +01:00
|
|
|
borderRadius:
|
|
|
|
const BorderRadius.all(Radius.circular(12)),
|
2021-11-11 14:45:12 +01:00
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: RadialGradient(
|
|
|
|
radius: 0.6,
|
|
|
|
colors: [
|
2021-12-23 12:36:09 +01:00
|
|
|
Colors.green[400]!,
|
2021-11-14 19:21:20 +01:00
|
|
|
const Color(0xFFE7E7A6),
|
2021-11-11 14:45:12 +01:00
|
|
|
],
|
|
|
|
)),
|
|
|
|
child:
|
|
|
|
// SvgPicture.asset('assets/chopp-gecko2.png',
|
|
|
|
// semanticsLabel: 'Gecko', height: 48),
|
2022-05-28 19:13:30 +02:00
|
|
|
_repository.imageCustomPath == null ||
|
|
|
|
_repository.imageCustomPath == ''
|
2021-11-17 06:20:23 +01:00
|
|
|
? Image.asset(
|
2022-05-28 19:13:30 +02:00
|
|
|
'assets/avatars/${_repository.imageDefaultPath}',
|
2021-11-17 06:20:23 +01:00
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
scale: 0.5,
|
|
|
|
)
|
2022-05-28 19:13:30 +02:00
|
|
|
: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.transparent,
|
|
|
|
image: DecorationImage(
|
2022-06-04 23:32:44 +02:00
|
|
|
fit: BoxFit.fitHeight,
|
2022-05-28 19:13:30 +02:00
|
|
|
image: FileImage(
|
|
|
|
File(
|
|
|
|
_repository.imageCustomPath!),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-11-17 06:20:23 +01:00
|
|
|
),
|
2021-11-11 14:45:12 +01:00
|
|
|
)),
|
2022-05-28 19:13:30 +02:00
|
|
|
balanceBuilder(context, _repository.address!,
|
2022-06-02 15:43:22 +02:00
|
|
|
_repository.address == defaultWallet.address),
|
2021-11-11 14:45:12 +01:00
|
|
|
ListTile(
|
2021-11-14 19:21:20 +01:00
|
|
|
shape: const RoundedRectangleBorder(
|
2021-11-11 14:45:12 +01:00
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
bottom: Radius.circular(12))),
|
|
|
|
// contentPadding: const EdgeInsets.only(left: 7.0),
|
|
|
|
tileColor:
|
2022-05-29 00:00:57 +02:00
|
|
|
_repository.address == defaultWallet.address
|
2021-11-11 14:45:12 +01:00
|
|
|
? orangeC
|
2021-11-14 19:21:20 +01:00
|
|
|
: const Color(0xffFFD58D),
|
2021-11-11 14:45:12 +01:00
|
|
|
// leading: Text('IMAGE'),
|
|
|
|
|
|
|
|
// subtitle: Text(_repository.split(':')[3],
|
|
|
|
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
|
|
|
title: Center(
|
2021-11-11 22:38:28 +01:00
|
|
|
child: Padding(
|
2021-11-14 19:21:20 +01:00
|
|
|
padding:
|
|
|
|
const EdgeInsets.symmetric(horizontal: 5),
|
2022-06-14 21:55:33 +02:00
|
|
|
child: _duniterIndexer.getNameByAddress(
|
2022-06-13 21:58:57 +02:00
|
|
|
context,
|
|
|
|
_repository.address!,
|
|
|
|
_repository,
|
|
|
|
17,
|
|
|
|
true,
|
|
|
|
_repository.id()[1] == defaultWallet.id()[1]
|
|
|
|
? const Color(0xffF9F9F1)
|
|
|
|
: Colors.black),
|
|
|
|
|
|
|
|
// Text(
|
|
|
|
// _repository.name!,
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 17.0,
|
|
|
|
// color: _repository.id()[1] ==
|
|
|
|
// defaultWallet.id()[1]
|
|
|
|
// ? const Color(0xffF9F9F1)
|
|
|
|
// : Colors.black,
|
|
|
|
// fontStyle: FontStyle.italic),
|
|
|
|
// ),
|
2021-11-11 22:38:28 +01:00
|
|
|
),
|
|
|
|
),
|
2021-11-11 14:45:12 +01:00
|
|
|
// dense: true,
|
|
|
|
onTap: () {
|
2021-12-30 00:51:04 +01:00
|
|
|
// _walletOptions.readLocalWallet(
|
|
|
|
// context,
|
|
|
|
// _repository,
|
|
|
|
// _myWalletProvider.pinCode,
|
|
|
|
// pinLength);
|
2022-05-19 07:00:25 +02:00
|
|
|
_walletOptions.getAddress(
|
|
|
|
_currentChestNumber, _repository.derivation!);
|
2021-11-11 14:45:12 +01:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
SmoothTransition(
|
|
|
|
page: WalletOptions(
|
|
|
|
wallet: _repository,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
2022-06-12 19:20:15 +02:00
|
|
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
|
|
|
return _sub.nodeConnected
|
|
|
|
? addNewDerivation(context)
|
|
|
|
: const Text('');
|
|
|
|
}),
|
2021-11-11 14:45:12 +01:00
|
|
|
// SizedBox(height: 1),
|
|
|
|
// Padding(
|
|
|
|
// padding: EdgeInsets.symmetric(horizontal: 35),
|
|
|
|
// child: Text(
|
|
|
|
// 'Ajouter un portefeuille',
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// style: TextStyle(fontSize: 18),
|
|
|
|
// ))
|
2021-11-09 04:22:04 +01:00
|
|
|
]),
|
|
|
|
// SliverToBoxAdapter(child: Spacer()),
|
2021-11-18 04:41:45 +01:00
|
|
|
SliverToBoxAdapter(child: chestOptions(context, _myWalletProvider)),
|
2021-11-09 04:22:04 +01:00
|
|
|
]);
|
|
|
|
}
|
2021-04-03 00:07:03 +02:00
|
|
|
|
2022-05-28 19:13:30 +02:00
|
|
|
Widget balanceBuilder(context, String _address, bool isDefault) {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
color: isDefault ? orangeC : yellowC,
|
|
|
|
child: SizedBox(
|
|
|
|
height: 25,
|
|
|
|
child: Column(children: [
|
|
|
|
const Spacer(),
|
|
|
|
// Text(
|
|
|
|
// '0.0 gd',
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// style: TextStyle(color: isDefault ? Colors.white : Colors.black),
|
|
|
|
// ),
|
|
|
|
balance(
|
2022-06-12 18:03:17 +02:00
|
|
|
context,
|
|
|
|
_address,
|
|
|
|
15,
|
|
|
|
isDefault ? Colors.white : Colors.black,
|
|
|
|
isDefault ? yellowC : orangeC)
|
2022-05-28 19:13:30 +02:00
|
|
|
]),
|
|
|
|
),
|
|
|
|
);
|
2021-11-11 22:38:28 +01:00
|
|
|
}
|
|
|
|
|
2021-11-09 04:22:04 +01:00
|
|
|
Widget addNewDerivation(context) {
|
2021-11-15 21:04:06 +01:00
|
|
|
MyWalletsProvider _myWalletProvider =
|
|
|
|
Provider.of<MyWalletsProvider>(context);
|
|
|
|
|
|
|
|
String _newDerivationName =
|
2022-06-17 01:13:14 +02:00
|
|
|
'wallet'.tr() + ' ${_myWalletProvider.listWallets.last.number! + 2}';
|
2021-11-09 04:22:04 +01:00
|
|
|
return Padding(
|
2021-11-14 19:21:20 +01:00
|
|
|
padding: const EdgeInsets.all(16),
|
2021-11-09 04:22:04 +01:00
|
|
|
child: ClipRRect(
|
2021-11-14 19:21:20 +01:00
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
2021-11-09 04:22:04 +01:00
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: InkWell(
|
2021-11-14 19:21:20 +01:00
|
|
|
key: const Key('addDerivation'),
|
2021-11-15 21:04:06 +01:00
|
|
|
onTap: () async {
|
2022-05-28 19:13:30 +02:00
|
|
|
if (!_myWalletProvider.isNewDerivationLoading) {
|
2022-05-31 18:23:56 +02:00
|
|
|
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 != '') {
|
|
|
|
await _myWalletProvider.generateNewDerivation(
|
|
|
|
context, _newDerivationName);
|
|
|
|
}
|
2022-05-28 19:13:30 +02:00
|
|
|
}
|
2021-03-19 06:33:48 +01:00
|
|
|
},
|
2021-11-09 04:22:04 +01:00
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
decoration: BoxDecoration(color: floattingYellow),
|
2022-05-28 19:13:30 +02:00
|
|
|
child: Center(
|
|
|
|
child: _myWalletProvider.isNewDerivationLoading
|
|
|
|
? SizedBox(
|
|
|
|
height: 60,
|
|
|
|
width: 60,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
color: orangeC,
|
|
|
|
strokeWidth: 7,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: const Text(
|
|
|
|
'+',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 150,
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
color: Color(0xFFFCB437)),
|
|
|
|
)),
|
2021-11-09 04:22:04 +01:00
|
|
|
)),
|
2021-11-11 14:45:12 +01:00
|
|
|
),
|
2021-11-09 04:22:04 +01:00
|
|
|
])));
|
2021-01-13 00:00:11 +01:00
|
|
|
}
|
|
|
|
}
|
2021-11-11 14:45:12 +01:00
|
|
|
|
|
|
|
// extension Range on num {
|
|
|
|
// bool isBetween(num from, num to) {
|
|
|
|
// return from < this && this < to;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
class CustomClipperOval extends CustomClipper<Rect> {
|
|
|
|
@override
|
|
|
|
Rect getClip(Size size) {
|
|
|
|
return Rect.fromCircle(
|
2021-11-14 19:21:20 +01:00
|
|
|
center: Offset(size.width / 2, size.width / 2),
|
2021-11-11 14:45:12 +01:00
|
|
|
radius: size.width / 2 + 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldReclip(CustomClipper<Rect> oldClipper) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ClipOvalShadow extends StatelessWidget {
|
|
|
|
final Shadow shadow;
|
|
|
|
final CustomClipper<Rect> clipper;
|
|
|
|
final Widget child;
|
|
|
|
|
2021-11-14 19:21:20 +01:00
|
|
|
const ClipOvalShadow({
|
2021-12-23 12:36:09 +01:00
|
|
|
Key? key,
|
|
|
|
required this.shadow,
|
|
|
|
required this.clipper,
|
|
|
|
required this.child,
|
2021-11-14 19:21:20 +01:00
|
|
|
}) : super(key: key);
|
2021-11-11 14:45:12 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return CustomPaint(
|
|
|
|
painter: _ClipOvalShadowPainter(
|
2021-11-14 19:21:20 +01:00
|
|
|
clipper: clipper,
|
|
|
|
shadow: shadow,
|
2021-11-11 14:45:12 +01:00
|
|
|
),
|
2021-11-14 19:21:20 +01:00
|
|
|
child: ClipRect(child: child, clipper: clipper),
|
2021-11-11 14:45:12 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ClipOvalShadowPainter extends CustomPainter {
|
|
|
|
final Shadow shadow;
|
|
|
|
final CustomClipper<Rect> clipper;
|
|
|
|
|
2021-12-23 12:36:09 +01:00
|
|
|
_ClipOvalShadowPainter({required this.shadow, required this.clipper});
|
2021-11-11 14:45:12 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
|
var paint = shadow.toPaint();
|
2021-11-14 19:21:20 +01:00
|
|
|
var clipRect = clipper.getClip(size).shift(const Offset(0, 0));
|
2021-11-11 14:45:12 +01:00
|
|
|
canvas.drawOval(clipRect, paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|