stack_wallet/lib/pages/wallets_view/sub_widgets/empty_wallets.dart
2024-07-08 11:27:20 -06:00

196 lines
6 KiB
Dart

/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import '../../../app_config.dart';
import '../../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
import '../../../themes/stack_colors.dart';
import '../../../themes/theme_providers.dart';
import '../../../utilities/assets.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart';
import '../../add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
class EmptyWallets extends ConsumerWidget {
const EmptyWallets({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
debugPrint("BUILD: $runtimeType");
final isDesktop = Util.isDesktop;
final stack =
ref.watch(themeProvider.select((value) => value.assets.stack));
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 43,
),
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: isDesktop ? 330 : double.infinity,
),
child: Column(
children: [
const Spacer(
flex: 2,
),
SizedBox(
width: isDesktop ? 324 : MediaQuery.of(context).size.width / 3,
child: (stack.endsWith(".png"))
? Image.file(
File(
stack,
),
)
: SvgPicture.file(
File(
stack,
),
width: isDesktop
? 324
: MediaQuery.of(context).size.width / 3,
),
),
SizedBox(
height: isDesktop ? 30 : 16,
),
Text(
AppConfig.emptyWalletsMessage,
textAlign: TextAlign.center,
style: isDesktop
? STextStyles.desktopSubtitleH2(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
)
: STextStyles.subtitle(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
SizedBox(
height: isDesktop ? 30 : 16,
),
if (isDesktop)
const SizedBox(
width: 328,
height: 70,
child: AddWalletButton(
isDesktop: true,
),
),
if (!isDesktop)
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AddWalletButton(
isDesktop: false,
),
],
),
const Spacer(
flex: 5,
),
],
),
),
),
);
}
}
class AddWalletButton extends ConsumerWidget {
const AddWalletButton({super.key, required this.isDesktop});
final bool isDesktop;
@override
Widget build(BuildContext context, WidgetRef ref) {
final bool isOLED = ref.watch(themeProvider).themeId == "oled_black";
return TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonStyle(context),
onPressed: () {
if (AppConfig.isSingleCoinApp) {
if (isDesktop) {
Navigator.of(
context,
rootNavigator: true,
).pushNamed(
CreateOrRestoreWalletView.routeName,
arguments: CoinEntity(AppConfig.coins.first),
);
} else {
Navigator.of(context).pushNamed(
CreateOrRestoreWalletView.routeName,
arguments: CoinEntity(AppConfig.coins.first),
);
}
} else {
if (isDesktop) {
Navigator.of(
context,
rootNavigator: true,
).pushNamed(AddWalletView.routeName);
} else {
Navigator.of(context).pushNamed(AddWalletView.routeName);
}
}
},
child: Center(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
isOLED
? SvgPicture.asset(
Assets.svg.plus,
color: Theme.of(context)
.extension<StackColors>()!
.buttonTextPrimary,
width: isDesktop ? 18 : null,
height: isDesktop ? 18 : null,
)
: SvgPicture.asset(
Assets.svg.plus,
width: isDesktop ? 18 : null,
height: isDesktop ? 18 : null,
),
SizedBox(
width: isDesktop ? 8 : 5,
),
Text(
"Add Wallet",
style: isDesktop
? STextStyles.desktopButtonEnabled(context)
: STextStyles.button(context),
),
],
),
),
),
);
}
}