gecko/lib/screens/settings.dart

108 lines
4.1 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:dubp/dubp.dart';
2021-02-27 20:29:35 +01:00
import 'package:flutter/services.dart';
import 'package:gecko/models/home.dart';
2021-11-14 19:21:20 +01:00
import 'package:gecko/models/my_wallets.dart';
import 'package:gecko/screens/myWallets/generate_wallets.dart';
import 'dart:io';
2021-11-14 19:21:20 +01:00
import 'package:gecko/screens/myWallets/import_wallet.dart';
2021-04-02 12:05:37 +02:00
import 'package:gecko/globals.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class SettingsScreen extends StatelessWidget {
String generatedMnemonic;
bool walletIsGenerated = false;
NewWallet actualWallet;
String newWalletName;
bool hasError = false;
String validPin = 'NO PIN';
String currentText = "";
var pinColor = Colors.grey[300];
Directory appPath;
2021-11-14 19:21:20 +01:00
final MyWalletsProvider _myWallets = MyWalletsProvider();
SettingsScreen({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
2021-02-27 20:29:35 +01:00
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
// getAppDirectory();
return Scaffold(
appBar: AppBar(
2021-11-14 19:21:20 +01:00
title: const SizedBox(
height: 22,
child: Text('Paramètres'),
)),
body: Column(children: <Widget>[
2021-11-14 19:21:20 +01:00
const SizedBox(height: 40),
SizedBox(
2021-04-29 02:12:14 +02:00
height: 70,
width: 500,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
2021-11-08 23:12:25 +01:00
primary: yellowC, // background
onPrimary: Colors.black, // foreground
),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) {
2021-11-14 19:21:20 +01:00
return const ImportWalletScreen();
}),
).then((value) => {
if (value == true) {Navigator.pop(context)}
}),
2021-11-14 19:21:20 +01:00
child: const Text("Importer un portefeuille Cesium",
2021-04-29 02:12:14 +02:00
style: TextStyle(fontSize: 16)))),
2021-11-14 19:21:20 +01:00
const SizedBox(height: 30),
SizedBox(
2021-04-29 02:12:14 +02:00
height: 70,
width: 500,
child: ElevatedButton(
2021-11-14 19:21:20 +01:00
key: const Key('generateKeychain'),
style: ElevatedButton.styleFrom(
elevation: 5,
2021-11-08 23:12:25 +01:00
primary: yellowC, // background
onPrimary: Colors.black, // foreground
),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return GenerateWalletsScreen();
}),
).then((value) => {
if (value == true) {Navigator.pop(context)}
}),
2021-11-14 19:21:20 +01:00
child: const Text("Générer un nouveau trousseau",
2021-04-29 02:12:14 +02:00
style: TextStyle(fontSize: 16)))),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
height: 100,
width: 500,
child: ElevatedButton(
2021-11-14 19:21:20 +01:00
key: const Key('deleteAllWallets'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Colors.redAccent, // background
onPrimary: Colors.black, // foreground
),
onPressed: () async => {
2021-04-02 12:05:37 +02:00
log.i('Suppression de tous les wallets'),
await _myWallets
.deleteAllWallet(context)
.then((v) => _homeProvider.rebuildWidget())
},
2021-11-14 19:21:20 +01:00
child: const Text("EFFACER TOUS MES PORTEFEUILLES",
style: TextStyle(fontSize: 20)))))),
2021-11-14 19:21:20 +01:00
const SizedBox(height: 50),
]));
}
}