2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-05-10 13:39:00 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-05-04 18:10:37 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:stackwallet/providers/providers.dart';
|
2024-05-15 21:20:45 +00:00
|
|
|
import 'package:stackwallet/supported_coins.dart';
|
2023-05-10 13:39:00 +00:00
|
|
|
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2023-05-04 18:10:37 +00:00
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2024-05-15 21:20:45 +00:00
|
|
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
2023-05-04 18:10:37 +00:00
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|
|
|
|
2023-05-26 19:25:59 +00:00
|
|
|
/*
|
|
|
|
* This widget is used to choose a coin from a list of coins.
|
|
|
|
* @param title: The title of the page.
|
|
|
|
* @param coinAdditional: Additional text to be displayed after the coin name.
|
|
|
|
* @param nextRouteName: The name of the route to be pushed when a coin is selected.
|
|
|
|
* @return A widget that displays a list of coins.
|
|
|
|
*/
|
|
|
|
|
2023-05-04 18:10:37 +00:00
|
|
|
class ChooseCoinView extends ConsumerStatefulWidget {
|
|
|
|
const ChooseCoinView({
|
2024-05-15 21:20:45 +00:00
|
|
|
super.key,
|
2023-05-04 18:10:37 +00:00
|
|
|
required this.title,
|
|
|
|
required this.coinAdditional,
|
|
|
|
required this.nextRouteName,
|
2024-05-15 21:20:45 +00:00
|
|
|
});
|
2023-05-04 18:10:37 +00:00
|
|
|
|
|
|
|
static const String routeName = "/chooseCoin";
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
final String coinAdditional;
|
|
|
|
final String nextRouteName;
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<ChooseCoinView> createState() => _ChooseCoinViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
|
2024-05-21 18:48:48 +00:00
|
|
|
List<CryptoCurrency> _coins = [...Coins.enabled];
|
2023-05-04 18:10:37 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_coins = _coins.toList();
|
2024-05-15 21:20:45 +00:00
|
|
|
_coins.removeWhere(
|
|
|
|
(e) => e.identifier == Firo(CryptoCurrencyNetwork.test).identifier,
|
|
|
|
);
|
2023-05-04 18:10:37 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-15 21:20:45 +00:00
|
|
|
final bool showTestNet = ref.watch(
|
2023-05-04 18:10:37 +00:00
|
|
|
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
|
|
|
|
);
|
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
final List<CryptoCurrency> coins = showTestNet
|
|
|
|
? _coins
|
|
|
|
: _coins
|
|
|
|
.where(
|
|
|
|
(e) => e.network == CryptoCurrencyNetwork.main,
|
|
|
|
)
|
|
|
|
.toList();
|
2023-05-04 18:10:37 +00:00
|
|
|
|
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
title: Text(
|
2023-05-08 14:36:05 +00:00
|
|
|
widget.title,
|
2023-05-04 18:10:37 +00:00
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 12,
|
|
|
|
left: 12,
|
|
|
|
right: 12,
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
...coins.map(
|
2023-05-08 14:36:05 +00:00
|
|
|
(coin) {
|
2023-05-04 18:10:37 +00:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: RoundedWhiteContainer(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
child: RawMaterialButton(
|
|
|
|
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
materialTapTargetSize:
|
2023-05-08 14:36:05 +00:00
|
|
|
MaterialTapTargetSize.shrinkWrap,
|
2023-05-04 18:10:37 +00:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
widget.nextRouteName,
|
|
|
|
arguments: coin,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2023-05-10 13:39:00 +00:00
|
|
|
SvgPicture.file(
|
|
|
|
File(
|
|
|
|
ref.watch(coinIconProvider(coin)),
|
|
|
|
),
|
2023-05-04 18:10:37 +00:00
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-05-08 14:36:05 +00:00
|
|
|
"${coin.prettyName} ${widget.coinAdditional}",
|
2023-05-04 18:10:37 +00:00
|
|
|
style: STextStyles.titleBold12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2023-05-08 14:36:05 +00:00
|
|
|
}
|