Browse Source

neon: constrain settings pages

pull/456/head
Nikolas Rimikis 1 year ago
parent
commit
18f062a614
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 46
      packages/neon/neon/lib/src/pages/account_settings.dart
  2. 26
      packages/neon/neon/lib/src/pages/nextcloud_app_settings.dart
  3. 19
      packages/neon/neon/lib/src/pages/settings.dart

46
packages/neon/neon/lib/src/pages/account_settings.dart

@ -10,13 +10,14 @@ import 'package:neon/src/settings/widgets/custom_settings_tile.dart';
import 'package:neon/src/settings/widgets/dropdown_button_settings_tile.dart'; import 'package:neon/src/settings/widgets/dropdown_button_settings_tile.dart';
import 'package:neon/src/settings/widgets/settings_category.dart'; import 'package:neon/src/settings/widgets/settings_category.dart';
import 'package:neon/src/settings/widgets/settings_list.dart'; import 'package:neon/src/settings/widgets/settings_list.dart';
import 'package:neon/src/theme/dialog.dart';
import 'package:neon/src/utils/confirmation_dialog.dart'; import 'package:neon/src/utils/confirmation_dialog.dart';
import 'package:neon/src/widgets/exception.dart'; import 'package:neon/src/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
class AccountSettingsPage extends StatelessWidget { class AccountSettingsPage extends StatelessWidget {
AccountSettingsPage({ const AccountSettingsPage({
required this.bloc, required this.bloc,
required this.account, required this.account,
super.key, super.key,
@ -25,15 +26,14 @@ class AccountSettingsPage extends StatelessWidget {
final AccountsBloc bloc; final AccountsBloc bloc;
final Account account; final Account account;
late final _options = bloc.getOptionsFor(account);
late final _userDetailsBloc = bloc.getUserDetailsBlocFor(account);
late final _name = account.client.humanReadableID;
@override @override
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) {
resizeToAvoidBottomInset: false, final options = bloc.getOptionsFor(account);
appBar: AppBar( final userDetailsBloc = bloc.getUserDetailsBlocFor(account);
title: Text(_name), final name = account.client.humanReadableID;
final appBar = AppBar(
title: Text(name),
actions: [ actions: [
IconButton( IconButton(
onPressed: () async { onPressed: () async {
@ -64,18 +64,19 @@ class AccountSettingsPage extends StatelessWidget {
onPressed: () async { onPressed: () async {
if (await showConfirmationDialog( if (await showConfirmationDialog(
context, context,
AppLocalizations.of(context).settingsResetForConfirmation(_name), AppLocalizations.of(context).settingsResetForConfirmation(name),
)) { )) {
await _options.reset(); await options.reset();
} }
}, },
tooltip: AppLocalizations.of(context).settingsResetFor(_name), tooltip: AppLocalizations.of(context).settingsResetFor(name),
icon: Icon(MdiIcons.cogRefresh), icon: Icon(MdiIcons.cogRefresh),
), ),
], ],
), );
body: ResultBuilder<ProvisioningApiUserDetails>.behaviorSubject(
stream: _userDetailsBloc.userDetails, final body = ResultBuilder<ProvisioningApiUserDetails>.behaviorSubject(
stream: userDetailsBloc.userDetails,
builder: (final context, final userDetails) => SettingsList( builder: (final context, final userDetails) => SettingsList(
categories: [ categories: [
SettingsCategory( SettingsCategory(
@ -103,7 +104,7 @@ class AccountSettingsPage extends StatelessWidget {
], ],
NeonException( NeonException(
userDetails.error, userDetails.error,
onRetry: _userDetailsBloc.refresh, onRetry: userDetailsBloc.refresh,
), ),
NeonLinearProgressIndicator( NeonLinearProgressIndicator(
visible: userDetails.isLoading, visible: userDetails.isLoading,
@ -117,12 +118,23 @@ class AccountSettingsPage extends StatelessWidget {
title: Text(AppLocalizations.of(context).optionsCategoryGeneral), title: Text(AppLocalizations.of(context).optionsCategoryGeneral),
tiles: [ tiles: [
DropdownButtonSettingsTile( DropdownButtonSettingsTile(
option: _options.initialApp, option: options.initialApp,
), ),
], ],
), ),
], ],
), ),
);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: appBar,
body: Center(
child: ConstrainedBox(
constraints: NeonDialogTheme.of(context).constraints,
child: body,
),
), ),
); );
} }
}

26
packages/neon/neon/lib/src/pages/nextcloud_app_settings.dart

@ -8,6 +8,7 @@ import 'package:neon/src/settings/widgets/checkbox_settings_tile.dart';
import 'package:neon/src/settings/widgets/dropdown_button_settings_tile.dart'; import 'package:neon/src/settings/widgets/dropdown_button_settings_tile.dart';
import 'package:neon/src/settings/widgets/settings_category.dart'; import 'package:neon/src/settings/widgets/settings_category.dart';
import 'package:neon/src/settings/widgets/settings_list.dart'; import 'package:neon/src/settings/widgets/settings_list.dart';
import 'package:neon/src/theme/dialog.dart';
import 'package:neon/src/utils/confirmation_dialog.dart'; import 'package:neon/src/utils/confirmation_dialog.dart';
class NextcloudAppSettingsPage extends StatelessWidget { class NextcloudAppSettingsPage extends StatelessWidget {
@ -19,9 +20,8 @@ class NextcloudAppSettingsPage extends StatelessWidget {
final AppImplementation appImplementation; final AppImplementation appImplementation;
@override @override
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) {
resizeToAvoidBottomInset: false, final appBar = AppBar(
appBar: AppBar(
title: Text(appImplementation.name(context)), title: Text(appImplementation.name(context)),
actions: [ actions: [
IconButton( IconButton(
@ -37,13 +37,12 @@ class NextcloudAppSettingsPage extends StatelessWidget {
icon: Icon(MdiIcons.cogRefresh), icon: Icon(MdiIcons.cogRefresh),
), ),
], ],
), );
body: SettingsList(
final body = SettingsList(
categories: [ categories: [
for (final category in [...appImplementation.options.categories, null]) ...[ for (final category in [...appImplementation.options.categories, null]) ...[
if (appImplementation.options.options if (appImplementation.options.options.where((final option) => option.category == category).isNotEmpty) ...[
.where((final option) => option.category == category)
.isNotEmpty) ...[
SettingsCategory( SettingsCategory(
title: Text( title: Text(
category != null ? category.name(context) : AppLocalizations.of(context).optionsCategoryOther, category != null ? category.name(context) : AppLocalizations.of(context).optionsCategoryOther,
@ -66,6 +65,17 @@ class NextcloudAppSettingsPage extends StatelessWidget {
], ],
], ],
], ],
);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: appBar,
body: Center(
child: ConstrainedBox(
constraints: NeonDialogTheme.of(context).constraints,
child: body,
),
), ),
); );
} }
}

19
packages/neon/neon/lib/src/pages/settings.dart

@ -19,6 +19,7 @@ import 'package:neon/src/settings/widgets/settings_list.dart';
import 'package:neon/src/settings/widgets/settings_tile.dart'; import 'package:neon/src/settings/widgets/settings_tile.dart';
import 'package:neon/src/settings/widgets/text_settings_tile.dart'; import 'package:neon/src/settings/widgets/text_settings_tile.dart';
import 'package:neon/src/theme/branding.dart'; import 'package:neon/src/theme/branding.dart';
import 'package:neon/src/theme/dialog.dart';
import 'package:neon/src/utils/confirmation_dialog.dart'; import 'package:neon/src/utils/confirmation_dialog.dart';
import 'package:neon/src/utils/global_options.dart'; import 'package:neon/src/utils/global_options.dart';
import 'package:neon/src/utils/save_file.dart'; import 'package:neon/src/utils/save_file.dart';
@ -57,9 +58,7 @@ class _SettingsPageState extends State<SettingsPage> {
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); final accountsBloc = Provider.of<AccountsBloc>(context, listen: false);
final appImplementations = Provider.of<Iterable<AppImplementation>>(context); final appImplementations = Provider.of<Iterable<AppImplementation>>(context);
return Scaffold( final appBar = AppBar(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text(AppLocalizations.of(context).settings), title: Text(AppLocalizations.of(context).settings),
actions: [ actions: [
IconButton( IconButton(
@ -80,8 +79,8 @@ class _SettingsPageState extends State<SettingsPage> {
icon: Icon(MdiIcons.cogRefresh), icon: Icon(MdiIcons.cogRefresh),
), ),
], ],
), );
body: StreamBuilder<List<Account>>( final body = StreamBuilder<List<Account>>(
stream: accountsBloc.accounts, stream: accountsBloc.accounts,
initialData: accountsBloc.accounts.valueOrNull, initialData: accountsBloc.accounts.valueOrNull,
builder: ( builder: (
@ -314,6 +313,16 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
); );
}, },
);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: appBar,
body: Center(
child: ConstrainedBox(
constraints: NeonDialogTheme.of(context).constraints,
child: body,
),
), ),
); );
} }

Loading…
Cancel
Save