feat(ui): Use adaptive widgets where possible

pull/483/head
Inex Code 2024-03-13 18:20:50 +03:00
parent 1cb5df19f3
commit e9538a4a84
18 changed files with 32 additions and 30 deletions

View File

@ -67,7 +67,7 @@ class BackupDetailsPage extends StatelessWidget {
const Center( const Center(
child: Padding( child: Padding(
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
), ),
), ),
if (!preventActions) if (!preventActions)

View File

@ -53,7 +53,7 @@ class _ChangeAutobackupsPeriodModalState
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
// Select all services tile // Select all services tile
RadioListTile<Duration?>( RadioListTile<Duration?>.adaptive(
onChanged: (final Duration? value) { onChanged: (final Duration? value) {
setState(() { setState(() {
selectedPeriod = value; selectedPeriod = value;
@ -69,7 +69,7 @@ class _ChangeAutobackupsPeriodModalState
height: 1.0, height: 1.0,
), ),
...autobackupPeriods.map( ...autobackupPeriods.map(
(final Duration period) => RadioListTile<Duration?>( (final Duration period) => RadioListTile<Duration?>.adaptive(
onChanged: (final Duration? value) { onChanged: (final Duration? value) {
setState(() { setState(() {
selectedPeriod = value; selectedPeriod = value;

View File

@ -232,7 +232,7 @@ class QuotaSelectionTile extends StatelessWidget {
children: [ children: [
// Discrete slider to select the new value // Discrete slider to select the new value
if (value >= -1 && value <= max) if (value >= -1 && value <= max)
Slider( Slider.adaptive(
value: value == -1 ? max + 1 : value.toDouble(), value: value == -1 ? max + 1 : value.toDouble(),
min: min.toDouble(), min: min.toDouble(),
max: (max + 1).toDouble(), max: (max + 1).toDouble(),

View File

@ -71,7 +71,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
// Select all services tile // Select all services tile
CheckboxListTile( CheckboxListTile.adaptive(
onChanged: (final bool? value) { onChanged: (final bool? value) {
setState(() { setState(() {
if (value ?? true) { if (value ?? true) {
@ -103,7 +103,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
...widget.services.map( ...widget.services.map(
(final Service service) { (final Service service) {
final bool busy = busyServices.contains(service.id); final bool busy = busyServices.contains(service.id);
return CheckboxListTile( return CheckboxListTile.adaptive(
onChanged: !busy onChanged: !busy
? (final bool? value) { ? (final bool? value) {
setState(() { setState(() {

View File

@ -36,7 +36,7 @@ class _DevicesScreenState extends State<DevicesScreen> {
if (devicesStatus is DevicesInitial) ...[ if (devicesStatus is DevicesInitial) ...[
const Center( const Center(
heightFactor: 8, heightFactor: 8,
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
), ),
], ],
if (devicesStatus is! DevicesInitial) ...[ if (devicesStatus is! DevicesInitial) ...[
@ -94,7 +94,7 @@ class _DevicesInfo extends StatelessWidget {
if (devicesStatus is DevicesDeleting) ...[ if (devicesStatus is DevicesDeleting) ...[
const Center( const Center(
heightFactor: 4, heightFactor: 4,
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
), ),
], ],
if (devicesStatus is! DevicesDeleting) if (devicesStatus is! DevicesDeleting)

View File

@ -27,7 +27,9 @@ class NewDeviceScreen extends StatelessWidget {
newDeviceKey: snapshot.data.toString(), newDeviceKey: snapshot.data.toString(),
); );
} else { } else {
return const Center(child: CircularProgressIndicator()); return const Center(
child: CircularProgressIndicator.adaptive(),
);
} }
}, },
), ),

View File

@ -31,7 +31,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
bodyPadding: const EdgeInsets.symmetric(vertical: 16), bodyPadding: const EdgeInsets.symmetric(vertical: 16),
heroTitle: 'application_settings.title'.tr(), heroTitle: 'application_settings.title'.tr(),
children: [ children: [
SwitchListTile( SwitchListTile.adaptive(
title: Text('application_settings.system_dark_theme_title'.tr()), title: Text('application_settings.system_dark_theme_title'.tr()),
subtitle: subtitle:
Text('application_settings.system_dark_theme_description'.tr()), Text('application_settings.system_dark_theme_description'.tr()),
@ -40,7 +40,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
.read<AppSettingsCubit>() .read<AppSettingsCubit>()
.updateAutoDarkMode(isAutoDarkModeOn: !isSystemDarkModeOn), .updateAutoDarkMode(isAutoDarkModeOn: !isSystemDarkModeOn),
), ),
SwitchListTile( SwitchListTile.adaptive(
title: Text('application_settings.dark_theme_title'.tr()), title: Text('application_settings.dark_theme_title'.tr()),
subtitle: Text('application_settings.dark_theme_description'.tr()), subtitle: Text('application_settings.dark_theme_description'.tr()),
value: Theme.of(context).brightness == Brightness.dark, value: Theme.of(context).brightness == Brightness.dark,

View File

@ -28,7 +28,7 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
heroSubtitle: 'developer_settings.subtitle'.tr(), heroSubtitle: 'developer_settings.subtitle'.tr(),
children: [ children: [
SectionTitle(title: 'developer_settings.server_setup'.tr()), SectionTitle(title: 'developer_settings.server_setup'.tr()),
SwitchListTile( SwitchListTile.adaptive(
title: Text('developer_settings.use_staging_acme'.tr()), title: Text('developer_settings.use_staging_acme'.tr()),
subtitle: subtitle:
Text('developer_settings.use_staging_acme_description'.tr()), Text('developer_settings.use_staging_acme_description'.tr()),
@ -37,7 +37,7 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
() => TlsOptions.stagingAcme = value, () => TlsOptions.stagingAcme = value,
), ),
), ),
SwitchListTile( SwitchListTile.adaptive(
title: Text('developer_settings.ignore_tls'.tr()), title: Text('developer_settings.ignore_tls'.tr()),
subtitle: Text('developer_settings.ignore_tls_description'.tr()), subtitle: Text('developer_settings.ignore_tls_description'.tr()),
value: !TlsOptions.verifyCertificate, value: !TlsOptions.verifyCertificate,
@ -45,7 +45,7 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
() => TlsOptions.verifyCertificate = !value, () => TlsOptions.verifyCertificate = !value,
), ),
), ),
SwitchListTile( SwitchListTile.adaptive(
title: Text('developer_settings.allow_ssh_key_at_setup'.tr()), title: Text('developer_settings.allow_ssh_key_at_setup'.tr()),
subtitle: Text( subtitle: Text(
'developer_settings.allow_ssh_key_at_setup_description'.tr(), 'developer_settings.allow_ssh_key_at_setup_description'.tr(),

View File

@ -96,7 +96,7 @@ class _ConsolePageState extends State<ConsolePage> {
children: [ children: [
Text('console_page.waiting'.tr()), Text('console_page.waiting'.tr()),
const Gap(16), const Gap(16),
const CircularProgressIndicator(), const CircularProgressIndicator.adaptive(),
], ],
); );
} }

View File

@ -32,7 +32,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
case RecoveryKeyRefreshing(): case RecoveryKeyRefreshing():
subtitle = 'recovery_key.key_synchronizing'.tr(); subtitle = 'recovery_key.key_synchronizing'.tr();
widgets = [ widgets = [
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator.adaptive()),
]; ];
break; break;
case RecoveryKeyLoaded(): case RecoveryKeyLoaded():
@ -306,7 +306,7 @@ class _RecoveryKeyConfigurationState extends State<RecoveryKeyConfiguration> {
return Column( return Column(
children: [ children: [
SwitchListTile( SwitchListTile.adaptive(
value: _isAmountToggled, value: _isAmountToggled,
title: Text('recovery_key.key_amount_toggle'.tr()), title: Text('recovery_key.key_amount_toggle'.tr()),
activeColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.primary,
@ -346,7 +346,7 @@ class _RecoveryKeyConfigurationState extends State<RecoveryKeyConfiguration> {
), ),
secondChild: Container(), secondChild: Container(),
), ),
SwitchListTile( SwitchListTile.adaptive(
value: _isExpirationToggled, value: _isExpirationToggled,
title: Text('recovery_key.key_duedate_toggle'.tr()), title: Text('recovery_key.key_duedate_toggle'.tr()),
activeColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.primary,

View File

@ -156,7 +156,7 @@ class _GraphLoadingCardContent extends StatelessWidget {
@override @override
Widget build(final BuildContext context) => const SizedBox( Widget build(final BuildContext context) => const SizedBox(
height: 200, height: 200,
child: Center(child: CircularProgressIndicator()), child: Center(child: CircularProgressIndicator.adaptive()),
); );
} }

View File

@ -34,7 +34,7 @@ class _ServerSettingsState extends State<_ServerSettings> {
return Column( return Column(
children: [ children: [
SwitchListTile( SwitchListTile.adaptive(
value: allowAutoUpgrade ?? false, value: allowAutoUpgrade ?? false,
onChanged: (final switched) { onChanged: (final switched) {
context.read<JobsCubit>().addJob( context.read<JobsCubit>().addJob(
@ -67,7 +67,7 @@ class _ServerSettingsState extends State<_ServerSettings> {
), ),
activeColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.primary,
), ),
SwitchListTile( SwitchListTile.adaptive(
value: rebootAfterUpgrade ?? false, value: rebootAfterUpgrade ?? false,
onChanged: (final switched) { onChanged: (final switched) {
context.read<JobsCubit>().addJob( context.read<JobsCubit>().addJob(
@ -113,7 +113,7 @@ class _ServerSettingsState extends State<_ServerSettings> {
); );
}, },
), ),
SwitchListTile( SwitchListTile.adaptive(
value: enableSsh ?? true, value: enableSsh ?? true,
onChanged: (final switched) { onChanged: (final switched) {
context.read<JobsCubit>().addJob( context.read<JobsCubit>().addJob(
@ -145,7 +145,7 @@ class _ServerSettingsState extends State<_ServerSettings> {
), ),
activeColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.primary,
), ),
SwitchListTile( SwitchListTile.adaptive(
value: allowPasswordAuthentication ?? false, value: allowPasswordAuthentication ?? false,
onChanged: (final switched) { onChanged: (final switched) {
context.read<JobsCubit>().addJob( context.read<JobsCubit>().addJob(

View File

@ -147,7 +147,7 @@ class _ServicesMigrationPageState extends State<ServicesMigrationPage> {
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
children: <Widget>[ children: <Widget>[
if (widget.services.isEmpty) if (widget.services.isEmpty)
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator.adaptive()),
...widget.services.map( ...widget.services.map(
(final service) => Column( (final service) => Column(
children: [ children: [

View File

@ -71,7 +71,7 @@ class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
children: const [ children: const [
SizedBox(height: 16), SizedBox(height: 16),
Center( Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
), ),
], ],
); );

View File

@ -33,7 +33,7 @@ class _ServicePageState extends State<ServicePage> {
hasBackButton: true, hasBackButton: true,
children: [ children: [
Center( Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
), ),
], ],
); );

View File

@ -141,7 +141,7 @@ class SelectLocationPage extends StatelessWidget {
), ),
); );
} else { } 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()), InfoBox(text: 'initializing.choose_server_type_notice'.tr()),
); );
} else { } else {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator.adaptive());
} }
}, },
); );

View File

@ -76,7 +76,7 @@ class _RecoveryConfirmServerState extends State<RecoveryConfirmServer> {
); );
} else { } else {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
); );
} }
}, },

View File

@ -56,7 +56,7 @@ class UsersPage extends StatelessWidget {
if (users.isEmpty) { if (users.isEmpty) {
if (state is UsersRefreshing) { if (state is UsersRefreshing) {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator.adaptive(),
); );
} }
return RefreshIndicator( return RefreshIndicator(