mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
refactor(ui): Fix button parameters
This commit is contained in:
parent
731f15fff6
commit
c6c26eec83
|
@ -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,
|
||||
),
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -79,7 +79,7 @@ class JobsContent extends StatelessWidget {
|
|||
const Gap(80),
|
||||
BrandButton.filled(
|
||||
onPressed: () => context.read<JobsCubit>().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<JobsCubit>().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<JobsCubit>().applyAll(),
|
||||
text: 'jobs.start'.tr(),
|
||||
title: 'jobs.start'.tr(),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class BackupDetailsPage extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
},
|
||||
text: 'backup.initialize'.tr(),
|
||||
title: 'backup.initialize'.tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -163,7 +163,7 @@ class _SnapshotModalState extends State<SnapshotModal> {
|
|||
getIt<NavigationService>()
|
||||
.showSnackBar('backup.restore_started'.tr());
|
||||
},
|
||||
text: 'backup.restore'.tr(),
|
||||
title: 'backup.restore'.tr(),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -161,7 +161,7 @@ class _DomainPickerState extends State<DomainPicker> {
|
|||
BrandButton.filled(
|
||||
onPressed: () =>
|
||||
context.read<DomainSetupCubit>().saveDomain(state.domain),
|
||||
text: 'initializing.save_domain'.tr(),
|
||||
title: 'initializing.save_domain'.tr(),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
|
|
@ -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<BackblazeFormCubit>().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<RootUserFormCubit>().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<JoblessSshFormCubit>()
|
||||
.trySubmit(),
|
||||
text: 'ssh.create'.tr(),
|
||||
title: 'ssh.create'.tr(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
|
|
|
@ -215,7 +215,7 @@ class SelectTypePage extends StatelessWidget {
|
|||
onPressed: () {
|
||||
backToLocationPickingCallback();
|
||||
},
|
||||
text: 'initializing.back_to_locations'.tr(),
|
||||
title: 'initializing.back_to_locations'.tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -57,7 +57,7 @@ class RecoveryConfirmBackblaze extends StatelessWidget {
|
|||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
||||
text: 'basis.connect'.tr(),
|
||||
title: 'basis.connect'.tr(),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Builder(
|
||||
|
|
|
@ -55,7 +55,7 @@ class RecoveryConfirmDns extends StatelessWidget {
|
|||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<DnsProviderFormCubit>().trySubmit(),
|
||||
text: 'basis.connect'.tr(),
|
||||
title: 'basis.connect'.tr(),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Builder(
|
||||
|
|
|
@ -35,7 +35,7 @@ class RecoveryServerProviderConnected extends StatelessWidget {
|
|||
},
|
||||
children: [
|
||||
BrandButton.filled(
|
||||
text: 'basis.continue'.tr(),
|
||||
title: 'basis.continue'.tr(),
|
||||
onPressed: () => context
|
||||
.read<ServerInstallationCubit>()
|
||||
.skipSettingServerProviderKey(),
|
||||
|
|
|
@ -110,7 +110,7 @@ class NewUserPage extends StatelessWidget {
|
|||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<UserFormCubit>().trySubmit(),
|
||||
text: 'basis.create'.tr(),
|
||||
title: 'basis.create'.tr(),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
Text('users.new_user_info_note'.tr()),
|
||||
|
|
|
@ -67,7 +67,7 @@ class ResetPassword extends StatelessWidget {
|
|||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<UserFormCubit>().trySubmit(),
|
||||
text: 'basis.apply'.tr(),
|
||||
title: 'basis.apply'.tr(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
|
|
|
@ -332,7 +332,7 @@ class NewSshKey extends StatelessWidget {
|
|||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<SshFormCubit>().trySubmit(),
|
||||
text: 'ssh.create'.tr(),
|
||||
title: 'ssh.create'.tr(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue