47 lines
1.4 KiB
Dart
47 lines
1.4 KiB
Dart
// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:prasule/api/wallet_manager.dart';
|
|
import 'package:prasule/pw/platformroute.dart';
|
|
import 'package:prasule/views/home.dart';
|
|
import 'package:prasule/views/setup.dart';
|
|
|
|
/// Intermediate screen used to initialize variables relying on context
|
|
class InitializationScreen extends StatefulWidget {
|
|
/// Intermediate screen used to initialize variables relying on context
|
|
const InitializationScreen({super.key});
|
|
|
|
@override
|
|
State<InitializationScreen> createState() => _InitializationScreenState();
|
|
}
|
|
|
|
class _InitializationScreenState extends State<InitializationScreen> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getApplicationDocumentsDirectory().then((v) {
|
|
WalletManager.walletPath = "${v.path}/wallets";
|
|
if (!mounted) return;
|
|
final wallets = WalletManager.listWallets();
|
|
if (wallets.isEmpty && mounted) {
|
|
Navigator.of(context)
|
|
.pushReplacement(platformRoute((c) => const SetupView()));
|
|
return;
|
|
}
|
|
Navigator.of(context)
|
|
.pushReplacement(platformRoute((c) => const HomeView()));
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Scaffold(
|
|
body: Align(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
);
|
|
}
|
|
}
|