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/settings_category.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/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:nextcloud/nextcloud.dart';
class AccountSettingsPage extends StatelessWidget {
AccountSettingsPage({
const AccountSettingsPage({
required this.bloc,
required this.account,
super.key,
@ -25,15 +26,14 @@ class AccountSettingsPage extends StatelessWidget {
final AccountsBloc bloc;
final Account account;
late final _options = bloc.getOptionsFor(account);
late final _userDetailsBloc = bloc.getUserDetailsBlocFor(account);
late final _name = account.client.humanReadableID;
@override
Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text(_name),
Widget build(final BuildContext context) {
final options = bloc.getOptionsFor(account);
final userDetailsBloc = bloc.getUserDetailsBlocFor(account);
final name = account.client.humanReadableID;
final appBar = AppBar(
title: Text(name),
actions: [
IconButton(
onPressed: () async {
@ -64,18 +64,19 @@ class AccountSettingsPage extends StatelessWidget {
onPressed: () async {
if (await showConfirmationDialog(
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),
),
],
),
body: ResultBuilder<ProvisioningApiUserDetails>.behaviorSubject(
stream: _userDetailsBloc.userDetails,
);
final body = ResultBuilder<ProvisioningApiUserDetails>.behaviorSubject(
stream: userDetailsBloc.userDetails,
builder: (final context, final userDetails) => SettingsList(
categories: [
SettingsCategory(
@ -103,7 +104,7 @@ class AccountSettingsPage extends StatelessWidget {
],
NeonException(
userDetails.error,
onRetry: _userDetailsBloc.refresh,
onRetry: userDetailsBloc.refresh,
),
NeonLinearProgressIndicator(
visible: userDetails.isLoading,
@ -117,12 +118,23 @@ class AccountSettingsPage extends StatelessWidget {
title: Text(AppLocalizations.of(context).optionsCategoryGeneral),
tiles: [
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/settings_category.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';
class NextcloudAppSettingsPage extends StatelessWidget {
@ -19,9 +20,8 @@ class NextcloudAppSettingsPage extends StatelessWidget {
final AppImplementation appImplementation;
@override
Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
Widget build(final BuildContext context) {
final appBar = AppBar(
title: Text(appImplementation.name(context)),
actions: [
IconButton(
@ -37,13 +37,12 @@ class NextcloudAppSettingsPage extends StatelessWidget {
icon: Icon(MdiIcons.cogRefresh),
),
],
),
body: SettingsList(
);
final body = SettingsList(
categories: [
for (final category in [...appImplementation.options.categories, null]) ...[
if (appImplementation.options.options
.where((final option) => option.category == category)
.isNotEmpty) ...[
if (appImplementation.options.options.where((final option) => option.category == category).isNotEmpty) ...[
SettingsCategory(
title: Text(
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/text_settings_tile.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/global_options.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 appImplementations = Provider.of<Iterable<AppImplementation>>(context);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
final appBar = AppBar(
title: Text(AppLocalizations.of(context).settings),
actions: [
IconButton(
@ -80,8 +79,8 @@ class _SettingsPageState extends State<SettingsPage> {
icon: Icon(MdiIcons.cogRefresh),
),
],
),
body: StreamBuilder<List<Account>>(
);
final body = StreamBuilder<List<Account>>(
stream: accountsBloc.accounts,
initialData: accountsBloc.accounts.valueOrNull,
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