Skip to content

Commit 3aa29b2

Browse files
committed
accounts ui: Make list of accounts scrollable
Fixes: #100
1 parent cade616 commit 3aa29b2

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

lib/widgets/app.dart

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,44 @@ class ChooseAccountPage extends StatelessWidget {
5858
final globalStore = GlobalStoreWidget.of(context);
5959
return Scaffold(
6060
appBar: AppBar(title: const Text('Choose account')),
61-
body: SafeArea(
62-
minimum: const EdgeInsets.all(8),
63-
child: Center(
64-
child: ConstrainedBox(
65-
constraints: const BoxConstraints(maxWidth: 400),
66-
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
67-
for (final (:accountId, :account) in globalStore.accountEntries)
68-
_buildAccountItem(context,
69-
accountId: accountId,
70-
title: Text(account.realmUrl.toString()),
71-
subtitle: Text(account.email)),
72-
const SizedBox(height: 12),
73-
ElevatedButton(
74-
onPressed: () => Navigator.push(context,
75-
AddAccountPage.buildRoute()),
76-
child: const Text('Add an account')),
77-
]))),
78-
));
61+
body: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
62+
Builder(builder: (context) =>
63+
MediaQuery.removePadding(
64+
context: context,
65+
removeBottom: true,
66+
child: Expanded(
67+
child: SingleChildScrollView(
68+
child: SafeArea(
69+
minimum: const EdgeInsets.all(8),
70+
child: Center(
71+
child: ConstrainedBox(
72+
constraints: const BoxConstraints(maxWidth: 400),
73+
child: Column(children: [
74+
for (final (:accountId, :account) in globalStore.accountEntries)
75+
_buildAccountItem(context,
76+
accountId: accountId,
77+
title: Text(account.realmUrl.toString()),
78+
subtitle: Text(account.email)),
79+
]))),
80+
),
81+
),
82+
),
83+
),
84+
),
85+
const Divider(height: 0), // remove padding; height clamped to 1 physical pixel
86+
// TODO adapt this lower section to wide screens?
87+
SafeArea(
88+
minimum: const EdgeInsets.all(8),
89+
child: Column(children: [
90+
MenuItemButton(
91+
// round corners; not flush with device edge (SafeArea padding)
92+
style: const ButtonStyle(shape: MaterialStatePropertyAll(StadiumBorder())),
93+
leadingIcon: const Icon(Icons.add),
94+
onPressed: () => Navigator.push(context,
95+
AddAccountPage.buildRoute()),
96+
child: const Text('Add an account')),
97+
])),
98+
]));
7999
}
80100
}
81101

0 commit comments

Comments
 (0)