|
1 | 1 | import 'package:flutter/material.dart';
|
| 2 | +import 'package:flutter/rendering.dart'; |
2 | 3 | import 'package:flutter_i18n/flutter_i18n.dart';
|
3 | 4 | import 'package:mxc_logic/mxc_logic.dart';
|
4 | 5 | import 'package:mxc_ui/mxc_ui.dart';
|
5 | 6 |
|
6 | 7 | import 'account_item.dart';
|
7 | 8 |
|
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}) { |
17 | 18 | showModalBottomSheet<void>(
|
18 | 19 | context: context,
|
19 | 20 | useRootNavigator: true,
|
20 | 21 | isScrollControlled: true,
|
21 | 22 | useSafeArea: true,
|
22 | 23 | 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, |
31 | 27 | ),
|
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 | + ), |
42 | 49 | ),
|
43 | 50 | ),
|
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 | + ), |
59 | 67 | ),
|
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 | + ), |
70 | 86 | ),
|
71 | 87 | ),
|
72 | 88 | );
|
|
0 commit comments