Fix back button bypassing Done listener in account settings

This commit is contained in:
Ming Ming 2021-10-26 00:17:10 +08:00
parent 6052d82047
commit 1fdf438956

View file

@ -423,43 +423,46 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
} }
Widget _buildContent(BuildContext context) { Widget _buildContent(BuildContext context) {
return CustomScrollView( return WillPopScope(
slivers: [ onWillPop: () async => !_hasModified,
SliverAppBar( child: CustomScrollView(
pinned: true, slivers: [
title: Text(L10n.global().settingsAccountPageTitle), SliverAppBar(
leading: _hasModified pinned: true,
? IconButton( title: Text(L10n.global().settingsAccountPageTitle),
icon: const Icon(Icons.check), leading: _hasModified
tooltip: L10n.global().doneButtonTooltip, ? IconButton(
onPressed: () => _onDonePressed(context), icon: const Icon(Icons.check),
) tooltip: L10n.global().doneButtonTooltip,
: null, onPressed: () => _onDonePressed(context),
), )
SliverList( : null,
delegate: SliverChildListDelegate(
[
ListTile(
title: Text(L10n.global().settingsIncludedFoldersTitle),
subtitle: Text(_account.roots.map((e) => "/$e").join("; ")),
onTap: _onIncludedFoldersPressed,
),
ListTile(
title: Text(L10n.global().settingsShareFolderTitle),
subtitle: Text("/$_shareFolder"),
onTap: () => _onShareFolderPressed(context),
),
_buildCaption(
context, L10n.global().settingsServerAppSectionTitle),
SwitchListTile(
title: const Text("Face Recognition"),
value: _isEnableFaceRecognitionApp,
onChanged: _onEnableFaceRecognitionAppChanged,
),
],
), ),
), SliverList(
], delegate: SliverChildListDelegate(
[
ListTile(
title: Text(L10n.global().settingsIncludedFoldersTitle),
subtitle: Text(_account.roots.map((e) => "/$e").join("; ")),
onTap: _onIncludedFoldersPressed,
),
ListTile(
title: Text(L10n.global().settingsShareFolderTitle),
subtitle: Text("/$_shareFolder"),
onTap: () => _onShareFolderPressed(context),
),
_buildCaption(
context, L10n.global().settingsServerAppSectionTitle),
SwitchListTile(
title: const Text("Face Recognition"),
value: _isEnableFaceRecognitionApp,
onChanged: _onEnableFaceRecognitionAppChanged,
),
],
),
),
],
),
); );
} }