From 812985a041857aa9337347e35bf266fef53816e8 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Fri, 6 Dec 2024 22:24:39 -0500 Subject: [PATCH] app: Fix ChooseAccountPage's colors in dark mode The colors are intended to match what we use for `ElevatedButton` (see `zulipThemeData`). Signed-off-by: Zixuan James Li --- lib/widgets/app.dart | 61 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart index 9b5c3227fa..7d7d1246e2 100644 --- a/lib/widgets/app.dart +++ b/lib/widgets/app.dart @@ -229,6 +229,7 @@ class ChooseAccountPage extends StatelessWidget { required Widget title, Widget? subtitle, }) { + final colorScheme = ColorScheme.of(context); final designVariables = DesignVariables.of(context); final zulipLocalizations = ZulipLocalizations.of(context); final materialLocalizations = MaterialLocalizations.of(context); @@ -237,6 +238,8 @@ class ChooseAccountPage extends StatelessWidget { child: ListTile( title: title, subtitle: subtitle, + tileColor: colorScheme.secondaryContainer, + textColor: colorScheme.onSecondaryContainer, trailing: MenuAnchor( menuChildren: [ MenuItemButton( @@ -274,36 +277,40 @@ class ChooseAccountPage extends StatelessWidget { @override Widget build(BuildContext context) { + final colorScheme = ColorScheme.of(context); final zulipLocalizations = ZulipLocalizations.of(context); assert(!PerAccountStoreWidget.debugExistsOf(context)); final globalStore = GlobalStoreWidget.of(context); - return Scaffold( - appBar: AppBar( - titleSpacing: 16, - title: Text(zulipLocalizations.chooseAccountPageTitle), - actions: const [ChooseAccountPageOverflowButton()]), - body: SafeArea( - minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8), - child: Center( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - Flexible(child: SingleChildScrollView( - padding: const EdgeInsets.only(top: 8), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - for (final (:accountId, :account) in globalStore.accountEntries) - _buildAccountItem(context, - accountId: accountId, - title: Text(account.realmUrl.toString()), - subtitle: Text(account.email)), - ]))), - const SizedBox(height: 12), - ElevatedButton( - onPressed: () => Navigator.push(context, - AddAccountPage.buildRoute()), - child: Text(zulipLocalizations.chooseAccountButtonAddAnAccount)), - ]))), - )); + return MenuButtonTheme( + data: MenuButtonThemeData(style: MenuItemButton.styleFrom( + backgroundColor: colorScheme.secondaryContainer, + foregroundColor: colorScheme.onSecondaryContainer)), + child: Scaffold( + appBar: AppBar( + titleSpacing: 16, + title: Text(zulipLocalizations.chooseAccountPageTitle), + actions: const [ChooseAccountPageOverflowButton()]), + body: SafeArea( + minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8), + child: Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + Flexible(child: SingleChildScrollView( + padding: const EdgeInsets.only(top: 8), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + for (final (:accountId, :account) in globalStore.accountEntries) + _buildAccountItem(context, + accountId: accountId, + title: Text(account.realmUrl.toString()), + subtitle: Text(account.email)), + ]))), + const SizedBox(height: 12), + ElevatedButton( + onPressed: () => Navigator.push(context, + AddAccountPage.buildRoute()), + child: Text(zulipLocalizations.chooseAccountButtonAddAnAccount)), + ])))))); } }