Skip to content
Snippets Groups Projects
settings.dart 5.07 KiB
Newer Older
import 'package:durt/durt.dart';
poka's avatar
poka committed
import 'package:flutter/services.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
poka's avatar
poka committed
import 'package:gecko/screens/myWallets/generate_wallets.dart';
// import 'package:gecko/screens/myWallets/import_cesium_wallet.dart';
poka's avatar
poka committed
import 'package:gecko/globals.dart';
import 'package:gecko/screens/myWallets/restore_chest.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class SettingsScreen extends StatelessWidget {
poka's avatar
poka committed
  String? generatedMnemonic;
poka's avatar
poka committed
  NewWallet? actualWallet;
  String? newWalletName;

  bool hasError = false;
  String validPin = 'NO PIN';
  String currentText = "";
  var pinColor = Colors.grey[300];
poka's avatar
poka committed
  Directory? appPath;
poka's avatar
poka committed
  final MyWalletsProvider _myWallets = MyWalletsProvider();

poka's avatar
poka committed
  SettingsScreen({Key? key}) : super(key: key);
poka's avatar
poka committed
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

    const double buttonHigh = 50;
    const double buttonWidth = 240;
    const double fontSize = 16;
    TextEditingController _endpointController =
        TextEditingController(text: configBox.get('endpoint'));
      appBar: AppBar(
          toolbarHeight: 60 * ratio,
          title: const SizedBox(
            height: 22,
            child: Text('Paramètres'),
          )),
      body: Column(
          // crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            const SizedBox(height: 60),
            Row(children: [
              Text(' Noeud $currencyName :'),
              const SizedBox(width: 20),
              SizedBox(
                width: 200,
                height: 50,
                child: TextField(
                  controller: _endpointController,
                  autocorrect: false,
                ),
              const Spacer(),
              Consumer<SubstrateSdk>(builder: (context, _sub, _) {
                return _sub.isLoadingEndpoint
                    ? CircularProgressIndicator(color: orangeC)
                    : IconButton(
                        icon: Icon(
                          Icons.send,
                          color: orangeC,
                          size: 40,
                        ),
                        onPressed: () async {
                          configBox.put('endpoint', _endpointController.text);
                          await _sub.connectNode(context);
                        });
              }),
              const Spacer(),
            ]),
            SizedBox(height: isTall ? 50 : 20),
            SizedBox(
              height: buttonHigh,
              width: buttonWidth,
              child: ElevatedButton(
                key: const Key('generateKeychain'),
                style: ElevatedButton.styleFrom(
                  elevation: 5,
                  primary: yellowC, // background
                  onPrimary: Colors.black, // foreground
                ),
                onPressed: () => Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) {
                    return GenerateFastChestScreen();
                  }),
                ),
                child: const Text(
poka's avatar
poka committed
                  "Générer un coffre",
                  style: TextStyle(fontSize: fontSize),
                ),
            const SizedBox(height: 20),
            SizedBox(
              height: buttonHigh,
              width: buttonWidth,
              child: ElevatedButton(
                key: const Key('generateKeychain'),
                style: ElevatedButton.styleFrom(
                  elevation: 5,
                  primary: yellowC, // background
                  onPrimary: Colors.black, // foreground
                ),
                onPressed: () => Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) {
                    return const RestoreChest();
                  }),
                ),
                child: const Text(
                  "Restaurer un coffre",
                  style: TextStyle(fontSize: fontSize),
                ),
            const SizedBox(height: 25),
            SizedBox(
              height: buttonHigh,
              width: buttonWidth,
              child: Center(
                child: InkWell(
                  key: const Key('deleteChest'),
                  onTap: () async {
                    log.i('Oublier tous mes coffres');
                    await _myWallets.deleteAllWallet(context);
                  },
                  child: const Text(
                    'Oublier tous mes coffres',
                    style: TextStyle(
                      fontSize: fontSize + 3,
                      color: Color(0xffD80000),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                ),