mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 04:34:34 +00:00
add custom token dialog modified for desktop
This commit is contained in:
parent
f744fd10de
commit
1ff19194e7
2 changed files with 101 additions and 58 deletions
|
@ -12,7 +12,6 @@ import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/ad
|
||||||
import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart';
|
import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart';
|
import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
@ -113,18 +112,32 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _addToken() async {
|
Future<void> _addToken() async {
|
||||||
final token = await Navigator.of(context).pushNamed(
|
EthContract? contract;
|
||||||
AddCustomTokenView.routeName,
|
|
||||||
arguments: widget.walletId,
|
if (isDesktop) {
|
||||||
|
contract = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const DesktopDialog(
|
||||||
|
maxWidth: 580,
|
||||||
|
maxHeight: 500,
|
||||||
|
child: AddCustomTokenView(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (token is EthContract) {
|
} else {
|
||||||
await MainDB.instance.putEthContract(token);
|
contract = await Navigator.of(context).pushNamed(
|
||||||
|
AddCustomTokenView.routeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contract != null) {
|
||||||
|
await MainDB.instance.putEthContract(contract);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (tokenEntities
|
if (tokenEntities
|
||||||
.where((e) => e.token.address == token.address)
|
.where((e) => e.token.address == contract!.address)
|
||||||
.isEmpty) {
|
.isEmpty) {
|
||||||
tokenEntities.add(AddTokenListElementData(token)..selected = true);
|
tokenEntities
|
||||||
|
.add(AddTokenListElementData(contract!)..selected = true);
|
||||||
tokenEntities.sort((a, b) => a.token.name.compareTo(b.token.name));
|
tokenEntities.sort((a, b) => a.token.name.compareTo(b.token.name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -184,13 +197,51 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
||||||
builder: (child) => DesktopScaffold(
|
builder: (child) => DesktopScaffold(
|
||||||
appBar: DesktopAppBar(
|
appBar: DesktopAppBar(
|
||||||
isCompactHeight: false,
|
isCompactHeight: false,
|
||||||
|
useSpacers: false,
|
||||||
leading: const AppBarBackButton(),
|
leading: const AppBarBackButton(),
|
||||||
|
overlayCenter: Text(
|
||||||
|
walletName,
|
||||||
|
style: STextStyles.desktopSubtitleH2(context),
|
||||||
|
),
|
||||||
trailing: widget.contractsToMarkSelected == null
|
trailing: widget.contractsToMarkSelected == null
|
||||||
? const ExitToMyStackButton()
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
right: 24,
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 56,
|
||||||
|
child: TextButton(
|
||||||
|
style: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.getSmallSecondaryEnabledButtonStyle(context),
|
||||||
|
onPressed: _addToken,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 30,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"Add custom token",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopButtonSmallSecondaryEnabled(
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
body: SizedBox(
|
body: SizedBox(
|
||||||
width: 480,
|
width: 480,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const AddTokenText(
|
||||||
|
isDesktop: true,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
child: RoundedWhiteContainer(
|
child: RoundedWhiteContainer(
|
||||||
radiusMultiplier: 2,
|
radiusMultiplier: 2,
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
|
@ -199,18 +250,9 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
||||||
right: 20,
|
right: 20,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
),
|
),
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
AddTokenText(
|
|
||||||
isDesktop: true,
|
|
||||||
walletName: walletName,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 26,
|
height: 26,
|
||||||
),
|
),
|
||||||
|
@ -231,7 +273,6 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
child: ConditionalParent(
|
child: ConditionalParent(
|
||||||
condition: widget.isDesktopPopup,
|
condition: widget.isDesktopPopup,
|
||||||
builder: (child) => DesktopDialog(
|
builder: (child) => DesktopDialog(
|
||||||
|
@ -369,7 +410,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
||||||
child: AddTokenList(
|
child: AddTokenList(
|
||||||
walletId: widget.walletId,
|
walletId: widget.walletId,
|
||||||
items: filter(_searchTerm, tokenEntities),
|
items: filter(_searchTerm, tokenEntities),
|
||||||
addFunction: widget.isDesktopPopup ? null : _addToken,
|
addFunction: isDesktop ? null : _addToken,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
|
@ -5,10 +5,10 @@ class AddTokenText extends StatelessWidget {
|
||||||
const AddTokenText({
|
const AddTokenText({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.isDesktop,
|
required this.isDesktop,
|
||||||
required this.walletName,
|
this.walletName,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String walletName;
|
final String? walletName;
|
||||||
final bool isDesktop;
|
final bool isDesktop;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -16,13 +16,15 @@ class AddTokenText extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
if (walletName != null)
|
||||||
Text(
|
Text(
|
||||||
walletName,
|
walletName!,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles.sectionLabelMedium12(context) // todo: fixme
|
? STextStyles.sectionLabelMedium12(context) // todo: fixme
|
||||||
: STextStyles.sectionLabelMedium12(context),
|
: STextStyles.sectionLabelMedium12(context),
|
||||||
),
|
),
|
||||||
|
if (walletName != null)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue