2 changed files with 94 additions and 94 deletions
			
			
		@ -1,114 +1,115 @@ | 
				
			|||||||
part of '../../neon.dart'; | 
					part of '../../neon.dart'; | 
				
			||||||
 | 
					
 | 
				
			||||||
class AccountSettingsPage extends StatelessWidget { | 
					class AccountSettingsPage extends StatelessWidget { | 
				
			||||||
  AccountSettingsPage({ | 
					  const AccountSettingsPage({ | 
				
			||||||
    required this.bloc, | 
					 | 
				
			||||||
    required this.account, | 
					    required this.account, | 
				
			||||||
    super.key, | 
					    super.key, | 
				
			||||||
  }); | 
					  }); | 
				
			||||||
 | 
					
 | 
				
			||||||
  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 accountsBloc = Provider.of<AccountsBloc>(context, listen: false); | 
				
			||||||
        appBar: AppBar( | 
					    final options = accountsBloc.getOptionsFor(account); | 
				
			||||||
          title: Text(_name), | 
					    final userDetailsBloc = accountsBloc.getUserDetailsBlocFor(account); | 
				
			||||||
          actions: [ | 
					    final name = account.client.humanReadableID; | 
				
			||||||
            IconButton( | 
					
 | 
				
			||||||
              onPressed: () async { | 
					    return Scaffold( | 
				
			||||||
 | 
					      resizeToAvoidBottomInset: false, | 
				
			||||||
 | 
					      appBar: AppBar( | 
				
			||||||
 | 
					        title: Text(name), | 
				
			||||||
 | 
					        actions: [ | 
				
			||||||
 | 
					          IconButton( | 
				
			||||||
 | 
					            onPressed: () async { | 
				
			||||||
 | 
					              // ignore: use_build_context_synchronously | 
				
			||||||
 | 
					              if (await showConfirmationDialog( | 
				
			||||||
 | 
					                context, | 
				
			||||||
                // ignore: use_build_context_synchronously | 
					                // ignore: use_build_context_synchronously | 
				
			||||||
                if (await showConfirmationDialog( | 
					                AppLocalizations.of(context).accountOptionsRemoveConfirm(account.client.humanReadableID), | 
				
			||||||
                  context, | 
					              )) { | 
				
			||||||
                  // ignore: use_build_context_synchronously | 
					                final isActive = accountsBloc.activeAccount.value == account; | 
				
			||||||
                  AppLocalizations.of(context).accountOptionsRemoveConfirm(account.client.humanReadableID), | 
					 | 
				
			||||||
                )) { | 
					 | 
				
			||||||
                  final isActive = bloc.activeAccount.value == account; | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  bloc.removeAccount(account); | 
					                accountsBloc.removeAccount(account); | 
				
			||||||
 | 
					
 | 
				
			||||||
                  if (isActive) { | 
					                if (isActive) { | 
				
			||||||
                    // ignore: use_build_context_synchronously | 
					 | 
				
			||||||
                    const HomeRoute().go(context); | 
					 | 
				
			||||||
                  } else { | 
					 | 
				
			||||||
                    // ignore: use_build_context_synchronously | 
					 | 
				
			||||||
                    Navigator.of(context).pop(); | 
					 | 
				
			||||||
                  } | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
              }, | 
					 | 
				
			||||||
              tooltip: AppLocalizations.of(context).accountOptionsRemove, | 
					 | 
				
			||||||
              icon: const Icon(MdiIcons.delete), | 
					 | 
				
			||||||
            ), | 
					 | 
				
			||||||
            IconButton( | 
					 | 
				
			||||||
              onPressed: () async { | 
					 | 
				
			||||||
                // ignore: use_build_context_synchronously | 
					 | 
				
			||||||
                if (await showConfirmationDialog( | 
					 | 
				
			||||||
                  context, | 
					 | 
				
			||||||
                  // ignore: use_build_context_synchronously | 
					                  // ignore: use_build_context_synchronously | 
				
			||||||
                  AppLocalizations.of(context).settingsResetForConfirmation(_name), | 
					                  const HomeRoute().go(context); | 
				
			||||||
                )) { | 
					                } else { | 
				
			||||||
                  await _options.reset(); | 
					                  // ignore: use_build_context_synchronously | 
				
			||||||
 | 
					                  Navigator.of(context).pop(); | 
				
			||||||
                } | 
					                } | 
				
			||||||
              }, | 
					              } | 
				
			||||||
              tooltip: AppLocalizations.of(context).settingsResetFor(_name), | 
					            }, | 
				
			||||||
              icon: const Icon(MdiIcons.cogRefresh), | 
					            tooltip: AppLocalizations.of(context).accountOptionsRemove, | 
				
			||||||
            ), | 
					            icon: const Icon(MdiIcons.delete), | 
				
			||||||
          ], | 
					          ), | 
				
			||||||
        ), | 
					          IconButton( | 
				
			||||||
        body: ResultBuilder<NextcloudProvisioningApiUserDetails>( | 
					            onPressed: () async { | 
				
			||||||
          stream: _userDetailsBloc.userDetails, | 
					              // ignore: use_build_context_synchronously | 
				
			||||||
          builder: (final context, final userDetails) => SettingsList( | 
					              if (await showConfirmationDialog( | 
				
			||||||
            categories: [ | 
					                context, | 
				
			||||||
              SettingsCategory( | 
					                // ignore: use_build_context_synchronously | 
				
			||||||
                title: Text(AppLocalizations.of(context).accountOptionsCategoryStorageInfo), | 
					                AppLocalizations.of(context).settingsResetForConfirmation(name), | 
				
			||||||
                tiles: [ | 
					              )) { | 
				
			||||||
                  CustomSettingsTile( | 
					                await options.reset(); | 
				
			||||||
                    title: Column( | 
					              } | 
				
			||||||
                      crossAxisAlignment: CrossAxisAlignment.start, | 
					            }, | 
				
			||||||
                      children: [ | 
					            tooltip: AppLocalizations.of(context).settingsResetFor(name), | 
				
			||||||
                        if (userDetails.data != null) ...[ | 
					            icon: const Icon(MdiIcons.cogRefresh), | 
				
			||||||
                          LinearProgressIndicator( | 
					          ), | 
				
			||||||
                            value: userDetails.data!.quota.relative / 100, | 
					        ], | 
				
			||||||
                            backgroundColor: Theme.of(context).colorScheme.primary.withOpacity(0.3), | 
					      ), | 
				
			||||||
                          ), | 
					      body: ResultBuilder<NextcloudProvisioningApiUserDetails>( | 
				
			||||||
                          const SizedBox( | 
					        stream: userDetailsBloc.userDetails, | 
				
			||||||
                            height: 10, | 
					        builder: (final context, final userDetails) => SettingsList( | 
				
			||||||
                          ), | 
					          categories: [ | 
				
			||||||
                          Text( | 
					            SettingsCategory( | 
				
			||||||
                            AppLocalizations.of(context).accountOptionsQuotaUsedOf( | 
					              title: Text(AppLocalizations.of(context).accountOptionsCategoryStorageInfo), | 
				
			||||||
                              filesize(userDetails.data!.quota.used, 1), | 
					              tiles: [ | 
				
			||||||
                              filesize(userDetails.data!.quota.total, 1), | 
					                CustomSettingsTile( | 
				
			||||||
                              userDetails.data!.quota.relative.toString(), | 
					                  title: Column( | 
				
			||||||
                            ), | 
					                    crossAxisAlignment: CrossAxisAlignment.start, | 
				
			||||||
                          ), | 
					                    children: [ | 
				
			||||||
                        ], | 
					                      if (userDetails.data != null) ...[ | 
				
			||||||
                        NeonException( | 
					                        LinearProgressIndicator( | 
				
			||||||
                          userDetails.error, | 
					                          value: userDetails.data!.quota.relative / 100, | 
				
			||||||
                          onRetry: _userDetailsBloc.refresh, | 
					                          backgroundColor: Theme.of(context).colorScheme.primary.withOpacity(0.3), | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					                        const SizedBox( | 
				
			||||||
 | 
					                          height: 10, | 
				
			||||||
                        ), | 
					                        ), | 
				
			||||||
                        NeonLinearProgressIndicator( | 
					                        Text( | 
				
			||||||
                          visible: userDetails.loading, | 
					                          AppLocalizations.of(context).accountOptionsQuotaUsedOf( | 
				
			||||||
 | 
					                            filesize(userDetails.data!.quota.used, 1), | 
				
			||||||
 | 
					                            filesize(userDetails.data!.quota.total, 1), | 
				
			||||||
 | 
					                            userDetails.data!.quota.relative.toString(), | 
				
			||||||
 | 
					                          ), | 
				
			||||||
                        ), | 
					                        ), | 
				
			||||||
                      ], | 
					                      ], | 
				
			||||||
                    ), | 
					                      NeonException( | 
				
			||||||
 | 
					                        userDetails.error, | 
				
			||||||
 | 
					                        onRetry: userDetailsBloc.refresh, | 
				
			||||||
 | 
					                      ), | 
				
			||||||
 | 
					                      NeonLinearProgressIndicator( | 
				
			||||||
 | 
					                        visible: userDetails.loading, | 
				
			||||||
 | 
					                      ), | 
				
			||||||
 | 
					                    ], | 
				
			||||||
                  ), | 
					                  ), | 
				
			||||||
                ], | 
					                ), | 
				
			||||||
              ), | 
					              ], | 
				
			||||||
              SettingsCategory( | 
					            ), | 
				
			||||||
                title: Text(AppLocalizations.of(context).optionsCategoryGeneral), | 
					            SettingsCategory( | 
				
			||||||
                tiles: [ | 
					              title: Text(AppLocalizations.of(context).optionsCategoryGeneral), | 
				
			||||||
                  DropdownButtonSettingsTile( | 
					              tiles: [ | 
				
			||||||
                    option: _options.initialApp, | 
					                DropdownButtonSettingsTile( | 
				
			||||||
                  ), | 
					                  option: options.initialApp, | 
				
			||||||
                ], | 
					                ), | 
				
			||||||
              ), | 
					              ], | 
				
			||||||
            ], | 
					            ), | 
				
			||||||
          ), | 
					          ], | 
				
			||||||
        ), | 
					        ), | 
				
			||||||
      ); | 
					      ), | 
				
			||||||
 | 
					    ); | 
				
			||||||
 | 
					  } | 
				
			||||||
} | 
					} | 
				
			||||||
 | 
				
			|||||||
					Loading…
					
					
				
		Reference in new issue