From e9538a4a84c0ad0e96e79980a8bee99b47f5ef3a Mon Sep 17 00:00:00 2001 From: Inex Code Date: Wed, 13 Mar 2024 18:20:50 +0300 Subject: [PATCH] feat(ui): Use adaptive widgets where possible --- lib/ui/pages/backups/backup_details.dart | 2 +- lib/ui/pages/backups/change_period_modal.dart | 4 ++-- lib/ui/pages/backups/change_rotation_quotas_modal.dart | 2 +- lib/ui/pages/backups/create_backups_modal.dart | 4 ++-- lib/ui/pages/devices/devices.dart | 4 ++-- lib/ui/pages/devices/new_device.dart | 4 +++- lib/ui/pages/more/app_settings/app_settings.dart | 4 ++-- lib/ui/pages/more/app_settings/developer_settings.dart | 6 +++--- lib/ui/pages/more/console.dart | 2 +- lib/ui/pages/recovery_key/recovery_key.dart | 6 +++--- lib/ui/pages/server_details/charts/chart.dart | 2 +- lib/ui/pages/server_details/server_settings.dart | 8 ++++---- .../binds_migration/services_migration.dart | 2 +- lib/ui/pages/server_storage/extending_volume.dart | 2 +- lib/ui/pages/services/service_page.dart | 2 +- lib/ui/pages/setup/initializing/server_type_picker.dart | 4 ++-- .../pages/setup/recovering/recovery_confirm_server.dart | 2 +- lib/ui/pages/users/users.dart | 2 +- 18 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/ui/pages/backups/backup_details.dart b/lib/ui/pages/backups/backup_details.dart index dad45db4..a5650bbb 100644 --- a/lib/ui/pages/backups/backup_details.dart +++ b/lib/ui/pages/backups/backup_details.dart @@ -67,7 +67,7 @@ class BackupDetailsPage extends StatelessWidget { const Center( child: Padding( padding: EdgeInsets.all(16.0), - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ), ), if (!preventActions) diff --git a/lib/ui/pages/backups/change_period_modal.dart b/lib/ui/pages/backups/change_period_modal.dart index d3217b64..80247acb 100644 --- a/lib/ui/pages/backups/change_period_modal.dart +++ b/lib/ui/pages/backups/change_period_modal.dart @@ -53,7 +53,7 @@ class _ChangeAutobackupsPeriodModalState ), const SizedBox(height: 16), // Select all services tile - RadioListTile( + RadioListTile.adaptive( onChanged: (final Duration? value) { setState(() { selectedPeriod = value; @@ -69,7 +69,7 @@ class _ChangeAutobackupsPeriodModalState height: 1.0, ), ...autobackupPeriods.map( - (final Duration period) => RadioListTile( + (final Duration period) => RadioListTile.adaptive( onChanged: (final Duration? value) { setState(() { selectedPeriod = value; diff --git a/lib/ui/pages/backups/change_rotation_quotas_modal.dart b/lib/ui/pages/backups/change_rotation_quotas_modal.dart index 1a7e91bc..19b39151 100644 --- a/lib/ui/pages/backups/change_rotation_quotas_modal.dart +++ b/lib/ui/pages/backups/change_rotation_quotas_modal.dart @@ -232,7 +232,7 @@ class QuotaSelectionTile extends StatelessWidget { children: [ // Discrete slider to select the new value if (value >= -1 && value <= max) - Slider( + Slider.adaptive( value: value == -1 ? max + 1 : value.toDouble(), min: min.toDouble(), max: (max + 1).toDouble(), diff --git a/lib/ui/pages/backups/create_backups_modal.dart b/lib/ui/pages/backups/create_backups_modal.dart index acf6ac6f..f78e1075 100644 --- a/lib/ui/pages/backups/create_backups_modal.dart +++ b/lib/ui/pages/backups/create_backups_modal.dart @@ -71,7 +71,7 @@ class _CreateBackupsModalState extends State { ), const SizedBox(height: 16), // Select all services tile - CheckboxListTile( + CheckboxListTile.adaptive( onChanged: (final bool? value) { setState(() { if (value ?? true) { @@ -103,7 +103,7 @@ class _CreateBackupsModalState extends State { ...widget.services.map( (final Service service) { final bool busy = busyServices.contains(service.id); - return CheckboxListTile( + return CheckboxListTile.adaptive( onChanged: !busy ? (final bool? value) { setState(() { diff --git a/lib/ui/pages/devices/devices.dart b/lib/ui/pages/devices/devices.dart index 4d92cd56..6c2992c8 100644 --- a/lib/ui/pages/devices/devices.dart +++ b/lib/ui/pages/devices/devices.dart @@ -36,7 +36,7 @@ class _DevicesScreenState extends State { if (devicesStatus is DevicesInitial) ...[ const Center( heightFactor: 8, - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ), ], if (devicesStatus is! DevicesInitial) ...[ @@ -94,7 +94,7 @@ class _DevicesInfo extends StatelessWidget { if (devicesStatus is DevicesDeleting) ...[ const Center( heightFactor: 4, - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ), ], if (devicesStatus is! DevicesDeleting) diff --git a/lib/ui/pages/devices/new_device.dart b/lib/ui/pages/devices/new_device.dart index 6f343b22..bbf03728 100644 --- a/lib/ui/pages/devices/new_device.dart +++ b/lib/ui/pages/devices/new_device.dart @@ -27,7 +27,9 @@ class NewDeviceScreen extends StatelessWidget { newDeviceKey: snapshot.data.toString(), ); } else { - return const Center(child: CircularProgressIndicator()); + return const Center( + child: CircularProgressIndicator.adaptive(), + ); } }, ), diff --git a/lib/ui/pages/more/app_settings/app_settings.dart b/lib/ui/pages/more/app_settings/app_settings.dart index 43b4ef32..b41f1a74 100644 --- a/lib/ui/pages/more/app_settings/app_settings.dart +++ b/lib/ui/pages/more/app_settings/app_settings.dart @@ -31,7 +31,7 @@ class _AppSettingsPageState extends State { bodyPadding: const EdgeInsets.symmetric(vertical: 16), heroTitle: 'application_settings.title'.tr(), children: [ - SwitchListTile( + SwitchListTile.adaptive( title: Text('application_settings.system_dark_theme_title'.tr()), subtitle: Text('application_settings.system_dark_theme_description'.tr()), @@ -40,7 +40,7 @@ class _AppSettingsPageState extends State { .read() .updateAutoDarkMode(isAutoDarkModeOn: !isSystemDarkModeOn), ), - SwitchListTile( + SwitchListTile.adaptive( title: Text('application_settings.dark_theme_title'.tr()), subtitle: Text('application_settings.dark_theme_description'.tr()), value: Theme.of(context).brightness == Brightness.dark, diff --git a/lib/ui/pages/more/app_settings/developer_settings.dart b/lib/ui/pages/more/app_settings/developer_settings.dart index 46149e15..751eabb6 100644 --- a/lib/ui/pages/more/app_settings/developer_settings.dart +++ b/lib/ui/pages/more/app_settings/developer_settings.dart @@ -28,7 +28,7 @@ class _DeveloperSettingsPageState extends State { heroSubtitle: 'developer_settings.subtitle'.tr(), children: [ SectionTitle(title: 'developer_settings.server_setup'.tr()), - SwitchListTile( + SwitchListTile.adaptive( title: Text('developer_settings.use_staging_acme'.tr()), subtitle: Text('developer_settings.use_staging_acme_description'.tr()), @@ -37,7 +37,7 @@ class _DeveloperSettingsPageState extends State { () => TlsOptions.stagingAcme = value, ), ), - SwitchListTile( + SwitchListTile.adaptive( title: Text('developer_settings.ignore_tls'.tr()), subtitle: Text('developer_settings.ignore_tls_description'.tr()), value: !TlsOptions.verifyCertificate, @@ -45,7 +45,7 @@ class _DeveloperSettingsPageState extends State { () => TlsOptions.verifyCertificate = !value, ), ), - SwitchListTile( + SwitchListTile.adaptive( title: Text('developer_settings.allow_ssh_key_at_setup'.tr()), subtitle: Text( 'developer_settings.allow_ssh_key_at_setup_description'.tr(), diff --git a/lib/ui/pages/more/console.dart b/lib/ui/pages/more/console.dart index 94c06b4d..0c60cf81 100644 --- a/lib/ui/pages/more/console.dart +++ b/lib/ui/pages/more/console.dart @@ -96,7 +96,7 @@ class _ConsolePageState extends State { children: [ Text('console_page.waiting'.tr()), const Gap(16), - const CircularProgressIndicator(), + const CircularProgressIndicator.adaptive(), ], ); } diff --git a/lib/ui/pages/recovery_key/recovery_key.dart b/lib/ui/pages/recovery_key/recovery_key.dart index b211bad7..d5bd7a15 100644 --- a/lib/ui/pages/recovery_key/recovery_key.dart +++ b/lib/ui/pages/recovery_key/recovery_key.dart @@ -32,7 +32,7 @@ class _RecoveryKeyPageState extends State { case RecoveryKeyRefreshing(): subtitle = 'recovery_key.key_synchronizing'.tr(); widgets = [ - const Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator.adaptive()), ]; break; case RecoveryKeyLoaded(): @@ -306,7 +306,7 @@ class _RecoveryKeyConfigurationState extends State { return Column( children: [ - SwitchListTile( + SwitchListTile.adaptive( value: _isAmountToggled, title: Text('recovery_key.key_amount_toggle'.tr()), activeColor: Theme.of(context).colorScheme.primary, @@ -346,7 +346,7 @@ class _RecoveryKeyConfigurationState extends State { ), secondChild: Container(), ), - SwitchListTile( + SwitchListTile.adaptive( value: _isExpirationToggled, title: Text('recovery_key.key_duedate_toggle'.tr()), activeColor: Theme.of(context).colorScheme.primary, diff --git a/lib/ui/pages/server_details/charts/chart.dart b/lib/ui/pages/server_details/charts/chart.dart index 76576261..da39c104 100644 --- a/lib/ui/pages/server_details/charts/chart.dart +++ b/lib/ui/pages/server_details/charts/chart.dart @@ -156,7 +156,7 @@ class _GraphLoadingCardContent extends StatelessWidget { @override Widget build(final BuildContext context) => const SizedBox( height: 200, - child: Center(child: CircularProgressIndicator()), + child: Center(child: CircularProgressIndicator.adaptive()), ); } diff --git a/lib/ui/pages/server_details/server_settings.dart b/lib/ui/pages/server_details/server_settings.dart index f3a78292..58715fa6 100644 --- a/lib/ui/pages/server_details/server_settings.dart +++ b/lib/ui/pages/server_details/server_settings.dart @@ -34,7 +34,7 @@ class _ServerSettingsState extends State<_ServerSettings> { return Column( children: [ - SwitchListTile( + SwitchListTile.adaptive( value: allowAutoUpgrade ?? false, onChanged: (final switched) { context.read().addJob( @@ -67,7 +67,7 @@ class _ServerSettingsState extends State<_ServerSettings> { ), activeColor: Theme.of(context).colorScheme.primary, ), - SwitchListTile( + SwitchListTile.adaptive( value: rebootAfterUpgrade ?? false, onChanged: (final switched) { context.read().addJob( @@ -113,7 +113,7 @@ class _ServerSettingsState extends State<_ServerSettings> { ); }, ), - SwitchListTile( + SwitchListTile.adaptive( value: enableSsh ?? true, onChanged: (final switched) { context.read().addJob( @@ -145,7 +145,7 @@ class _ServerSettingsState extends State<_ServerSettings> { ), activeColor: Theme.of(context).colorScheme.primary, ), - SwitchListTile( + SwitchListTile.adaptive( value: allowPasswordAuthentication ?? false, onChanged: (final switched) { context.read().addJob( diff --git a/lib/ui/pages/server_storage/binds_migration/services_migration.dart b/lib/ui/pages/server_storage/binds_migration/services_migration.dart index 695b8de4..cc4d18aa 100644 --- a/lib/ui/pages/server_storage/binds_migration/services_migration.dart +++ b/lib/ui/pages/server_storage/binds_migration/services_migration.dart @@ -147,7 +147,7 @@ class _ServicesMigrationPageState extends State { padding: const EdgeInsets.all(16.0), children: [ if (widget.services.isEmpty) - const Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator.adaptive()), ...widget.services.map( (final service) => Column( children: [ diff --git a/lib/ui/pages/server_storage/extending_volume.dart b/lib/ui/pages/server_storage/extending_volume.dart index e6961a95..2b222276 100644 --- a/lib/ui/pages/server_storage/extending_volume.dart +++ b/lib/ui/pages/server_storage/extending_volume.dart @@ -71,7 +71,7 @@ class _ExtendingVolumePageState extends State { children: const [ SizedBox(height: 16), Center( - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ), ], ); diff --git a/lib/ui/pages/services/service_page.dart b/lib/ui/pages/services/service_page.dart index c0064eef..6e441c94 100644 --- a/lib/ui/pages/services/service_page.dart +++ b/lib/ui/pages/services/service_page.dart @@ -33,7 +33,7 @@ class _ServicePageState extends State { hasBackButton: true, children: [ Center( - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ), ], ); diff --git a/lib/ui/pages/setup/initializing/server_type_picker.dart b/lib/ui/pages/setup/initializing/server_type_picker.dart index 067746f6..6fb09f4b 100644 --- a/lib/ui/pages/setup/initializing/server_type_picker.dart +++ b/lib/ui/pages/setup/initializing/server_type_picker.dart @@ -141,7 +141,7 @@ class SelectLocationPage extends StatelessWidget { ), ); } else { - return const Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator.adaptive()); } }, ); @@ -479,7 +479,7 @@ class SelectTypePage extends StatelessWidget { InfoBox(text: 'initializing.choose_server_type_notice'.tr()), ); } else { - return const Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator.adaptive()); } }, ); diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart index e9c53f94..9e7709bc 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart @@ -76,7 +76,7 @@ class _RecoveryConfirmServerState extends State { ); } else { return const Center( - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ); } }, diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index b08b168e..b7469a6e 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -56,7 +56,7 @@ class UsersPage extends StatelessWidget { if (users.isEmpty) { if (state is UsersRefreshing) { return const Center( - child: CircularProgressIndicator(), + child: CircularProgressIndicator.adaptive(), ); } return RefreshIndicator(