Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 91bdf2b

Browse files
committed
feat: Updated show accounts dialog & added import button
1 parent 3af7afd commit 91bdf2b

File tree

2 files changed

+81
-66
lines changed

2 files changed

+81
-66
lines changed

lib/features/settings/presentation/widgets/account_managment/account_managment_panel.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:flutter_i18n/flutter_i18n.dart';
88
import 'package:hooks_riverpod/hooks_riverpod.dart';
99
import 'package:mxc_ui/mxc_ui.dart';
1010

11-
import '../../../subfeatures/accounts/show_add_accounts_dialog.dart';
1211
import 'copyable_item.dart';
1312

1413
class AccountManagementPanel extends HookConsumerWidget {
@@ -32,20 +31,19 @@ class AccountManagementPanel extends HookConsumerWidget {
3231
children: [
3332
InkWell(
3433
onTap: () => showAccountsDialog(
35-
context: context,
36-
currentAccount: state.account!,
37-
accounts: state.accounts,
38-
isLoading: state.isLoading,
39-
onAdd: () => showAddAccountsDialog(
40-
context: context,
41-
isLoading: state.isLoading,
42-
onAdd: presenter.addNewAccount,
43-
onImport: () => Navigator.of(context).push(
44-
route.featureDialog(
45-
const ImportAccountPage(),
34+
context: context,
35+
currentAccount: state.account!,
36+
accounts: state.accounts,
37+
isLoading: state.isLoading,
38+
onImport: () => Navigator.of(context).push(
39+
route.featureDialog(
40+
const ImportAccountPage(),
41+
),
4642
),
47-
),),
48-
onSelect: (item) => presenter.changeAccount(item)),
43+
onAdd: () => presenter.addNewAccount(),
44+
onSelect: (item) => presenter.changeAccount(item),
45+
onRemove: (item) => presenter.removeAccount(item),
46+
),
4947
child: Row(
5048
children: [
5149
Portrait(
@@ -95,6 +93,7 @@ class AccountManagementPanel extends HookConsumerWidget {
9593
onTap: () => Navigator.of(context).push(route(QrCodePage(
9694
name: account.mns,
9795
address: account.address,
96+
privateKey: state.account?.privateKey ?? '',
9897
))),
9998
child: Container(
10099
padding: const EdgeInsets.all(Sizes.spaceXSmall),

lib/features/settings/subfeatures/accounts/show_accounts_dialog.dart

Lines changed: 68 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,88 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/rendering.dart';
23
import 'package:flutter_i18n/flutter_i18n.dart';
34
import 'package:mxc_logic/mxc_logic.dart';
45
import 'package:mxc_ui/mxc_ui.dart';
56

67
import 'account_item.dart';
78

8-
void showAccountsDialog({
9-
required BuildContext context,
10-
required Account currentAccount,
11-
required List<Account> accounts,
12-
bool isLoading = false,
13-
VoidCallback? onAdd,
14-
VoidCallback? onImport,
15-
required Function(Account) onSelect,
16-
}) {
9+
void showAccountsDialog(
10+
{required BuildContext context,
11+
required Account currentAccount,
12+
required List<Account> accounts,
13+
bool isLoading = false,
14+
VoidCallback? onAdd,
15+
VoidCallback? onImport,
16+
required Function(Account) onSelect,
17+
required Function(Account) onRemove}) {
1718
showModalBottomSheet<void>(
1819
context: context,
1920
useRootNavigator: true,
2021
isScrollControlled: true,
2122
useSafeArea: true,
2223
backgroundColor: Colors.transparent,
23-
builder: (BuildContext context) => Container(
24-
padding: const EdgeInsets.only(left: 16, right: 16, top: 0, bottom: 44),
25-
decoration: BoxDecoration(
26-
color: ColorsTheme.of(context).screenBackground,
27-
borderRadius: const BorderRadius.only(
28-
topLeft: Radius.circular(20),
29-
topRight: Radius.circular(20),
30-
),
24+
builder: (BuildContext context) => ConstrainedBox(
25+
constraints: BoxConstraints(
26+
maxHeight: MediaQuery.of(context).size.height * 0.95,
3127
),
32-
child: Column(
33-
mainAxisSize: MainAxisSize.min,
34-
children: [
35-
MxcAppBarEvenly.title(
36-
titleText: FlutterI18n.translate(context, 'accounts'),
37-
action: Container(
38-
alignment: Alignment.centerRight,
39-
child: InkWell(
40-
child: const Icon(Icons.close),
41-
onTap: () => Navigator.of(context).pop(false),
28+
child: Container(
29+
padding: const EdgeInsets.only(
30+
left: 16, right: 16, top: 0, bottom: Sizes.space3XLarge),
31+
decoration: BoxDecoration(
32+
color: ColorsTheme.of(context).screenBackground,
33+
borderRadius: const BorderRadius.only(
34+
topLeft: Radius.circular(20),
35+
topRight: Radius.circular(20),
36+
),
37+
),
38+
child: Column(
39+
mainAxisSize: MainAxisSize.min,
40+
children: [
41+
MxcAppBarEvenly.title(
42+
titleText: FlutterI18n.translate(context, 'accounts'),
43+
action: Container(
44+
alignment: Alignment.centerRight,
45+
child: InkWell(
46+
child: const Icon(Icons.close),
47+
onTap: () => Navigator.of(context).pop(false),
48+
),
4249
),
4350
),
44-
),
45-
ConstrainedBox(
46-
constraints: const BoxConstraints(maxHeight: 400),
47-
child: ListView.builder(
48-
padding: EdgeInsets.zero,
49-
itemCount: accounts.length,
50-
shrinkWrap: true,
51-
itemBuilder: (ctx, index) {
52-
return AccountItem(
53-
account: accounts[index],
54-
isSelected: currentAccount.address == accounts[index].address,
55-
onSelect: () => onSelect(accounts[index]),
56-
isCustom: accounts[index].isCustom,
57-
);
58-
},
51+
Flexible(
52+
child: ListView.builder(
53+
padding: EdgeInsets.zero,
54+
itemCount: accounts.length,
55+
shrinkWrap: true,
56+
itemBuilder: (ctx, index) {
57+
return AccountItem(
58+
account: accounts[index],
59+
isSelected:
60+
currentAccount.address == accounts[index].address,
61+
onSelect: () => onSelect(accounts[index]),
62+
isCustom: accounts[index].isCustom,
63+
onRemove: onRemove,
64+
);
65+
},
66+
),
5967
),
60-
),
61-
const SizedBox(height: Sizes.spaceXSmall),
62-
MxcButton.primary(
63-
key: const ValueKey('addAccountButton'),
64-
title: FlutterI18n.translate(
65-
context, isLoading ? 'adding_account' : 'add_new_account'),
66-
onTap: onAdd,
67-
size: AxsButtonSize.xl,
68-
),
69-
],
68+
const SizedBox(height: Sizes.spaceXSmall),
69+
MxcButton.primary(
70+
key: const ValueKey('addAccountButton'),
71+
title: FlutterI18n.translate(
72+
context, isLoading ? 'adding_account' : 'add_new_account'),
73+
onTap: onAdd,
74+
size: AxsButtonSize.xl,
75+
),
76+
const SizedBox(height: Sizes.spaceXSmall),
77+
MxcButton.plainWhite(
78+
key: const ValueKey('importAccountButton'),
79+
title: FlutterI18n.translate(context, 'import_account'),
80+
onTap: onImport,
81+
size: AxsButtonSize.xl,
82+
titleColor: ColorsTheme.of(context).primary,
83+
),
84+
],
85+
),
7086
),
7187
),
7288
);

0 commit comments

Comments
 (0)