From c6c26eec832f221f473e9734d2b6a6820a7a9870 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Wed, 30 Oct 2024 16:05:39 +0300 Subject: [PATCH] refactor(ui): Fix button parameters --- lib/ui/components/buttons/brand_button.dart | 8 ++++---- lib/ui/components/buttons/outlined_button.dart | 2 -- lib/ui/components/jobs_content/jobs_content.dart | 6 +++--- lib/ui/pages/backups/backup_details.dart | 2 +- lib/ui/pages/backups/snapshot_modal.dart | 2 +- .../pages/more/tokens/add_server_provider_token.dart | 2 +- lib/ui/pages/onboarding/views/onboarding_view.dart | 2 +- .../pages/setup/initializing/dns_provider_picker.dart | 8 ++++---- lib/ui/pages/setup/initializing/domain_picker.dart | 2 +- lib/ui/pages/setup/initializing/initializing.dart | 10 +++++----- .../pages/setup/initializing/server_type_picker.dart | 2 +- .../setup/recovering/recovery_confirm_backblaze.dart | 2 +- .../pages/setup/recovering/recovery_confirm_dns.dart | 2 +- .../recovering/recovery_server_provider_connected.dart | 2 +- lib/ui/pages/users/new_user.dart | 2 +- lib/ui/pages/users/reset_password.dart | 2 +- lib/ui/pages/users/user_details.dart | 2 +- 17 files changed, 28 insertions(+), 30 deletions(-) diff --git a/lib/ui/components/buttons/brand_button.dart b/lib/ui/components/buttons/brand_button.dart index 230d95ee..3ff97410 100644 --- a/lib/ui/components/buttons/brand_button.dart +++ b/lib/ui/components/buttons/brand_button.dart @@ -4,11 +4,11 @@ class BrandButton { static ConstrainedBox filled({ required final VoidCallback? onPressed, final Key? key, - final String? text, + final String? title, final Widget? child, }) { - assert((text ?? child) != null, 'either title or child must not be empty'); - assert(text != null || child != null, 'title or child must be provided'); + assert((title ?? child) != null, 'either title or child must not be empty'); + assert(title != null || child != null, 'title or child must be provided'); return ConstrainedBox( constraints: const BoxConstraints( @@ -23,7 +23,7 @@ class BrandButton { ), child: child ?? Text( - text ?? '', + title ?? '', textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, ), diff --git a/lib/ui/components/buttons/outlined_button.dart b/lib/ui/components/buttons/outlined_button.dart index 306d1085..f8164d12 100644 --- a/lib/ui/components/buttons/outlined_button.dart +++ b/lib/ui/components/buttons/outlined_button.dart @@ -6,13 +6,11 @@ class BrandOutlinedButton extends StatelessWidget { this.onPressed, this.title, this.child, - this.disabled = false, }); final VoidCallback? onPressed; final String? title; final Widget? child; - final bool disabled; @override Widget build(final BuildContext context) => ConstrainedBox( diff --git a/lib/ui/components/jobs_content/jobs_content.dart b/lib/ui/components/jobs_content/jobs_content.dart index 5c4d5ce0..4846145d 100644 --- a/lib/ui/components/jobs_content/jobs_content.dart +++ b/lib/ui/components/jobs_content/jobs_content.dart @@ -79,7 +79,7 @@ class JobsContent extends StatelessWidget { const Gap(80), BrandButton.filled( onPressed: () => context.read().upgradeServer(), - text: 'jobs.upgrade_server'.tr(), + title: 'jobs.upgrade_server'.tr(), ), const Gap(10), BrandButton.text( @@ -370,7 +370,7 @@ class JobsContent extends StatelessWidget { const Gap(16), BrandButton.filled( onPressed: () => context.read().acknowledgeFinished(), - text: 'basis.done'.tr(), + title: 'basis.done'.tr(), ), ]; } else if (state is JobsStateWithJobs) { @@ -436,7 +436,7 @@ class JobsContent extends StatelessWidget { onPressed: hasBlockingJobs ? null : () => context.read().applyAll(), - text: 'jobs.start'.tr(), + title: 'jobs.start'.tr(), ), ]; } diff --git a/lib/ui/pages/backups/backup_details.dart b/lib/ui/pages/backups/backup_details.dart index 80fcdb88..52650cfa 100644 --- a/lib/ui/pages/backups/backup_details.dart +++ b/lib/ui/pages/backups/backup_details.dart @@ -90,7 +90,7 @@ class BackupDetailsPage extends StatelessWidget { ), ); }, - text: 'backup.initialize'.tr(), + title: 'backup.initialize'.tr(), ), ], ); diff --git a/lib/ui/pages/backups/snapshot_modal.dart b/lib/ui/pages/backups/snapshot_modal.dart index 54dbaae4..9ef77e46 100644 --- a/lib/ui/pages/backups/snapshot_modal.dart +++ b/lib/ui/pages/backups/snapshot_modal.dart @@ -163,7 +163,7 @@ class _SnapshotModalState extends State { getIt() .showSnackBar('backup.restore_started'.tr()); }, - text: 'backup.restore'.tr(), + title: 'backup.restore'.tr(), ), ], ) diff --git a/lib/ui/pages/more/tokens/add_server_provider_token.dart b/lib/ui/pages/more/tokens/add_server_provider_token.dart index 669d7cf8..0f197bfb 100644 --- a/lib/ui/pages/more/tokens/add_server_provider_token.dart +++ b/lib/ui/pages/more/tokens/add_server_provider_token.dart @@ -76,7 +76,7 @@ class _AddServerProviderTokenPageState }, children: [ BrandButton.filled( - text: 'basis.close'.tr(), + title: 'basis.close'.tr(), onPressed: () => Navigator.of(context).popUntil((final route) => route.isFirst), ), diff --git a/lib/ui/pages/onboarding/views/onboarding_view.dart b/lib/ui/pages/onboarding/views/onboarding_view.dart index 46ff1078..4e661f30 100644 --- a/lib/ui/pages/onboarding/views/onboarding_view.dart +++ b/lib/ui/pages/onboarding/views/onboarding_view.dart @@ -42,7 +42,7 @@ class OnboardingView extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 15) + const EdgeInsets.only(bottom: 30), child: BrandButton.filled( - text: buttonTitle.tr(), + title: buttonTitle.tr(), onPressed: onProceed, ), ), diff --git a/lib/ui/pages/setup/initializing/dns_provider_picker.dart b/lib/ui/pages/setup/initializing/dns_provider_picker.dart index b6df0795..9385eab3 100644 --- a/lib/ui/pages/setup/initializing/dns_provider_picker.dart +++ b/lib/ui/pages/setup/initializing/dns_provider_picker.dart @@ -117,7 +117,7 @@ class ProviderInputDataPage extends StatelessWidget { ), const SizedBox(height: 32), BrandButton.filled( - text: 'basis.connect'.tr(), + title: 'basis.connect'.tr(), onPressed: () => providerCubit.trySubmit(), ), const SizedBox(height: 10), @@ -198,7 +198,7 @@ class ProviderSelectionPage extends StatelessWidget { ), const SizedBox(height: 16), BrandButton.filled( - text: 'basis.select'.tr(), + title: 'basis.select'.tr(), onPressed: () { serverInstallationCubit .setDnsProviderType(DnsProviderType.desec); @@ -253,7 +253,7 @@ class ProviderSelectionPage extends StatelessWidget { ), const SizedBox(height: 16), BrandButton.filled( - text: 'basis.select'.tr(), + title: 'basis.select'.tr(), onPressed: () { serverInstallationCubit .setDnsProviderType(DnsProviderType.cloudflare); @@ -309,7 +309,7 @@ class ProviderSelectionPage extends StatelessWidget { ), const SizedBox(height: 16), BrandButton.filled( - text: 'basis.select'.tr(), + title: 'basis.select'.tr(), onPressed: () { serverInstallationCubit .setDnsProviderType(DnsProviderType.digitalOcean); diff --git a/lib/ui/pages/setup/initializing/domain_picker.dart b/lib/ui/pages/setup/initializing/domain_picker.dart index 719e3bfe..fd304236 100644 --- a/lib/ui/pages/setup/initializing/domain_picker.dart +++ b/lib/ui/pages/setup/initializing/domain_picker.dart @@ -161,7 +161,7 @@ class _DomainPickerState extends State { BrandButton.filled( onPressed: () => context.read().saveDomain(state.domain), - text: 'initializing.save_domain'.tr(), + title: 'initializing.save_domain'.tr(), ), ], ], diff --git a/lib/ui/pages/setup/initializing/initializing.dart b/lib/ui/pages/setup/initializing/initializing.dart index 563a9a1b..dc26606f 100644 --- a/lib/ui/pages/setup/initializing/initializing.dart +++ b/lib/ui/pages/setup/initializing/initializing.dart @@ -136,7 +136,7 @@ class InitializingPage extends StatelessWidget { Container( alignment: Alignment.center, child: BrandButton.filled( - text: 'basis.connect_to_existing'.tr(), + title: 'basis.connect_to_existing'.tr(), onPressed: () { context.router.replace(const RecoveryRoute()); }, @@ -308,7 +308,7 @@ class InitializingPage extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.connect'.tr(), + title: 'basis.connect'.tr(), ), const SizedBox(height: 10), BrandButton.text( @@ -416,7 +416,7 @@ class InitializingPage extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.connect'.tr(), + title: 'basis.connect'.tr(), ), ], ), @@ -453,7 +453,7 @@ class InitializingPage extends StatelessWidget { onPressed: isLoading ? null : appConfigCubit.createServerAndSetDnsRecords, - text: isLoading + title: isLoading ? 'basis.loading'.tr() : 'initializing.create_server'.tr(), ), @@ -630,7 +630,7 @@ class AddSshKey extends StatelessWidget { : () => context .read() .trySubmit(), - text: 'ssh.create'.tr(), + title: 'ssh.create'.tr(), ), const SizedBox(height: 30), ], diff --git a/lib/ui/pages/setup/initializing/server_type_picker.dart b/lib/ui/pages/setup/initializing/server_type_picker.dart index f92a9a8e..a56c9aec 100644 --- a/lib/ui/pages/setup/initializing/server_type_picker.dart +++ b/lib/ui/pages/setup/initializing/server_type_picker.dart @@ -215,7 +215,7 @@ class SelectTypePage extends StatelessWidget { onPressed: () { backToLocationPickingCallback(); }, - text: 'initializing.back_to_locations'.tr(), + title: 'initializing.back_to_locations'.tr(), ), ], ); diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart index 51cc1d48..90bff9bd 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart @@ -57,7 +57,7 @@ class RecoveryConfirmBackblaze extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.connect'.tr(), + title: 'basis.connect'.tr(), ), const SizedBox(height: 16), Builder( diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart b/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart index 393dc820..a3dca1c7 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart @@ -55,7 +55,7 @@ class RecoveryConfirmDns extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.connect'.tr(), + title: 'basis.connect'.tr(), ), const SizedBox(height: 16), Builder( diff --git a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart index a9024e46..a460670c 100644 --- a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart +++ b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart @@ -35,7 +35,7 @@ class RecoveryServerProviderConnected extends StatelessWidget { }, children: [ BrandButton.filled( - text: 'basis.continue'.tr(), + title: 'basis.continue'.tr(), onPressed: () => context .read() .skipSettingServerProviderKey(), diff --git a/lib/ui/pages/users/new_user.dart b/lib/ui/pages/users/new_user.dart index 6b6c65fa..c8939c8f 100644 --- a/lib/ui/pages/users/new_user.dart +++ b/lib/ui/pages/users/new_user.dart @@ -110,7 +110,7 @@ class NewUserPage extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.create'.tr(), + title: 'basis.create'.tr(), ), const SizedBox(height: 40), Text('users.new_user_info_note'.tr()), diff --git a/lib/ui/pages/users/reset_password.dart b/lib/ui/pages/users/reset_password.dart index 145c0baa..4b39342c 100644 --- a/lib/ui/pages/users/reset_password.dart +++ b/lib/ui/pages/users/reset_password.dart @@ -67,7 +67,7 @@ class ResetPassword extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'basis.apply'.tr(), + title: 'basis.apply'.tr(), ), const SizedBox(height: 30), ], diff --git a/lib/ui/pages/users/user_details.dart b/lib/ui/pages/users/user_details.dart index 148c5dd5..4775bb22 100644 --- a/lib/ui/pages/users/user_details.dart +++ b/lib/ui/pages/users/user_details.dart @@ -332,7 +332,7 @@ class NewSshKey extends StatelessWidget { onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), - text: 'ssh.create'.tr(), + title: 'ssh.create'.tr(), ), const SizedBox(height: 30), ],