Limit max account dialog width (mainly for tablets)

This commit is contained in:
Ming Ming 2023-08-05 03:13:06 +08:00
parent c304011ea3
commit dfe03caf73

View file

@ -91,98 +91,101 @@ class _WrappedAccountPickerDialog extends StatelessWidget {
], ],
child: Dialog( child: Dialog(
insetPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 24), insetPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 24),
child: Padding( child: ConstrainedBox(
padding: const EdgeInsets.all(8), constraints: const BoxConstraints(maxWidth: 512),
child: ClipRRect( child: Padding(
borderRadius: BorderRadius.circular(24), padding: const EdgeInsets.all(8),
child: SingleChildScrollView( child: ClipRRect(
child: Column( borderRadius: BorderRadius.circular(24),
mainAxisSize: MainAxisSize.min, child: SingleChildScrollView(
children: [ child: Column(
const SizedBox(height: 8), mainAxisSize: MainAxisSize.min,
Stack( children: [
alignment: Alignment.center, const SizedBox(height: 8),
children: [ Stack(
Text( alignment: Alignment.center,
L10n.global().appTitle, children: [
style: Theme.of(context).textTheme.headlineSmall, Text(
), L10n.global().appTitle,
if (!Pref().isFollowSystemThemeOr(false)) style: Theme.of(context).textTheme.headlineSmall,
Align(
alignment: AlignmentDirectional.centerEnd,
child: _DarkModeSwitch(
onChanged: _onDarkModeChanged,
),
), ),
], if (!Pref().isFollowSystemThemeOr(false))
), Align(
const SizedBox(height: 8), alignment: AlignmentDirectional.centerEnd,
ClipRRect( child: _DarkModeSwitch(
borderRadius: BorderRadius.circular(24), onChanged: _onDarkModeChanged,
child: Container( ),
color: Theme.of(context).colorScheme.background, ),
child: Material( ],
type: MaterialType.transparency, ),
child: _BlocBuilder( const SizedBox(height: 8),
buildWhen: (previous, current) => ClipRRect(
previous.isOpenDropdown != borderRadius: BorderRadius.circular(24),
current.isOpenDropdown || child: Container(
previous.accounts != current.accounts, color: Theme.of(context).colorScheme.background,
builder: (context, state) { child: Material(
final bloc = context.read<_Bloc>(); type: MaterialType.transparency,
return Column( child: _BlocBuilder(
mainAxisSize: MainAxisSize.min, buildWhen: (previous, current) =>
children: [ previous.isOpenDropdown !=
const _AccountDropdown(), current.isOpenDropdown ||
if (state.isOpenDropdown) ...[ previous.accounts != current.accounts,
...state.accounts builder: (context, state) {
.where( final bloc = context.read<_Bloc>();
(a) => a.id != bloc.activeAccount.id) return Column(
.map((a) => _AccountView(account: a)), mainAxisSize: MainAxisSize.min,
const _NewAccountView(), children: [
] else const _AccountDropdown(),
const _AccountSettingsView(), if (state.isOpenDropdown) ...[
], ...state.accounts
); .where((a) =>
}, a.id != bloc.activeAccount.id)
.map((a) => _AccountView(account: a)),
const _NewAccountView(),
] else
const _AccountSettingsView(),
],
);
},
),
), ),
), ),
), ),
), _IconTile(
_IconTile( icon: const Icon(Icons.settings_outlined),
icon: const Icon(Icons.settings_outlined), title: Text(L10n.global().settingsMenuLabel),
title: Text(L10n.global().settingsMenuLabel), isCircularSplash: true,
isCircularSplash: true, onTap: () {
onTap: () { Navigator.of(context)
Navigator.of(context) ..pop()
..pop() ..pushNamed(
..pushNamed( Settings.routeName,
Settings.routeName, arguments: SettingsArguments(
arguments: SettingsArguments( context.read<_Bloc>().activeAccount),
context.read<_Bloc>().activeAccount), );
); },
}, ),
), _IconTile(
_IconTile( icon: const Icon(Icons.groups_outlined),
icon: const Icon(Icons.groups_outlined), title: Text(L10n.global().contributorsTooltip),
title: Text(L10n.global().contributorsTooltip), isCircularSplash: true,
isCircularSplash: true, onTap: () {
onTap: () { Navigator.of(context).pop();
Navigator.of(context).pop(); launch(help_util.contributorsUrl);
launch(help_util.contributorsUrl); },
}, ),
), _IconTile(
_IconTile( icon: const Icon(Icons.help_outline),
icon: const Icon(Icons.help_outline), title: Text(L10n.global().helpTooltip),
title: Text(L10n.global().helpTooltip), isCircularSplash: true,
isCircularSplash: true, onTap: () {
onTap: () { Navigator.of(context).pop();
Navigator.of(context).pop(); launch(help_util.mainUrl);
launch(help_util.mainUrl); },
}, ),
), const _AboutChin(),
const _AboutChin(), ],
], ),
), ),
), ),
), ),