mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 17:39:42 +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({
|
static ConstrainedBox filled({
|
||||||
required final VoidCallback? onPressed,
|
required final VoidCallback? onPressed,
|
||||||
final Key? key,
|
final Key? key,
|
||||||
final String? text,
|
final String? title,
|
||||||
final Widget? child,
|
final Widget? child,
|
||||||
}) {
|
}) {
|
||||||
assert((text ?? child) != null, 'either title or child must not be empty');
|
assert((title ?? child) != null, 'either title or child must not be empty');
|
||||||
assert(text != null || child != null, 'title or child must be provided');
|
assert(title != null || child != null, 'title or child must be provided');
|
||||||
|
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
|
@ -23,7 +23,7 @@ class BrandButton {
|
||||||
),
|
),
|
||||||
child: child ??
|
child: child ??
|
||||||
Text(
|
Text(
|
||||||
text ?? '',
|
title ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,13 +6,11 @@ class BrandOutlinedButton extends StatelessWidget {
|
||||||
this.onPressed,
|
this.onPressed,
|
||||||
this.title,
|
this.title,
|
||||||
this.child,
|
this.child,
|
||||||
this.disabled = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onPressed;
|
||||||
final String? title;
|
final String? title;
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
final bool disabled;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(final BuildContext context) => ConstrainedBox(
|
Widget build(final BuildContext context) => ConstrainedBox(
|
||||||
|
|
|
@ -79,7 +79,7 @@ class JobsContent extends StatelessWidget {
|
||||||
const Gap(80),
|
const Gap(80),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
||||||
text: 'jobs.upgrade_server'.tr(),
|
title: 'jobs.upgrade_server'.tr(),
|
||||||
),
|
),
|
||||||
const Gap(10),
|
const Gap(10),
|
||||||
BrandButton.text(
|
BrandButton.text(
|
||||||
|
@ -370,7 +370,7 @@ class JobsContent extends StatelessWidget {
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
onPressed: () => context.read<JobsCubit>().acknowledgeFinished(),
|
onPressed: () => context.read<JobsCubit>().acknowledgeFinished(),
|
||||||
text: 'basis.done'.tr(),
|
title: 'basis.done'.tr(),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
} else if (state is JobsStateWithJobs) {
|
} else if (state is JobsStateWithJobs) {
|
||||||
|
@ -436,7 +436,7 @@ class JobsContent extends StatelessWidget {
|
||||||
onPressed: hasBlockingJobs
|
onPressed: hasBlockingJobs
|
||||||
? null
|
? null
|
||||||
: () => context.read<JobsCubit>().applyAll(),
|
: () => 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>()
|
getIt<NavigationService>()
|
||||||
.showSnackBar('backup.restore_started'.tr());
|
.showSnackBar('backup.restore_started'.tr());
|
||||||
},
|
},
|
||||||
text: 'backup.restore'.tr(),
|
title: 'backup.restore'.tr(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -76,7 +76,7 @@ class _AddServerProviderTokenPageState
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.close'.tr(),
|
title: 'basis.close'.tr(),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Navigator.of(context).popUntil((final route) => route.isFirst),
|
Navigator.of(context).popUntil((final route) => route.isFirst),
|
||||||
),
|
),
|
||||||
|
|
|
@ -42,7 +42,7 @@ class OnboardingView extends StatelessWidget {
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15) +
|
padding: const EdgeInsets.symmetric(horizontal: 15) +
|
||||||
const EdgeInsets.only(bottom: 30),
|
const EdgeInsets.only(bottom: 30),
|
||||||
child: BrandButton.filled(
|
child: BrandButton.filled(
|
||||||
text: buttonTitle.tr(),
|
title: buttonTitle.tr(),
|
||||||
onPressed: onProceed,
|
onPressed: onProceed,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -117,7 +117,7 @@ class ProviderInputDataPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.connect'.tr(),
|
title: 'basis.connect'.tr(),
|
||||||
onPressed: () => providerCubit.trySubmit(),
|
onPressed: () => providerCubit.trySubmit(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
@ -198,7 +198,7 @@ class ProviderSelectionPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.select'.tr(),
|
title: 'basis.select'.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
serverInstallationCubit
|
serverInstallationCubit
|
||||||
.setDnsProviderType(DnsProviderType.desec);
|
.setDnsProviderType(DnsProviderType.desec);
|
||||||
|
@ -253,7 +253,7 @@ class ProviderSelectionPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.select'.tr(),
|
title: 'basis.select'.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
serverInstallationCubit
|
serverInstallationCubit
|
||||||
.setDnsProviderType(DnsProviderType.cloudflare);
|
.setDnsProviderType(DnsProviderType.cloudflare);
|
||||||
|
@ -309,7 +309,7 @@ class ProviderSelectionPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.select'.tr(),
|
title: 'basis.select'.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
serverInstallationCubit
|
serverInstallationCubit
|
||||||
.setDnsProviderType(DnsProviderType.digitalOcean);
|
.setDnsProviderType(DnsProviderType.digitalOcean);
|
||||||
|
|
|
@ -161,7 +161,7 @@ class _DomainPickerState extends State<DomainPicker> {
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
context.read<DomainSetupCubit>().saveDomain(state.domain),
|
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(
|
Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: BrandButton.filled(
|
child: BrandButton.filled(
|
||||||
text: 'basis.connect_to_existing'.tr(),
|
title: 'basis.connect_to_existing'.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.router.replace(const RecoveryRoute());
|
context.router.replace(const RecoveryRoute());
|
||||||
},
|
},
|
||||||
|
@ -308,7 +308,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
||||||
text: 'basis.connect'.tr(),
|
title: 'basis.connect'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BrandButton.text(
|
BrandButton.text(
|
||||||
|
@ -416,7 +416,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<RootUserFormCubit>().trySubmit(),
|
: () => context.read<RootUserFormCubit>().trySubmit(),
|
||||||
text: 'basis.connect'.tr(),
|
title: 'basis.connect'.tr(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -453,7 +453,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
onPressed: isLoading
|
onPressed: isLoading
|
||||||
? null
|
? null
|
||||||
: appConfigCubit.createServerAndSetDnsRecords,
|
: appConfigCubit.createServerAndSetDnsRecords,
|
||||||
text: isLoading
|
title: isLoading
|
||||||
? 'basis.loading'.tr()
|
? 'basis.loading'.tr()
|
||||||
: 'initializing.create_server'.tr(),
|
: 'initializing.create_server'.tr(),
|
||||||
),
|
),
|
||||||
|
@ -630,7 +630,7 @@ class AddSshKey extends StatelessWidget {
|
||||||
: () => context
|
: () => context
|
||||||
.read<JoblessSshFormCubit>()
|
.read<JoblessSshFormCubit>()
|
||||||
.trySubmit(),
|
.trySubmit(),
|
||||||
text: 'ssh.create'.tr(),
|
title: 'ssh.create'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
|
|
|
@ -215,7 +215,7 @@ class SelectTypePage extends StatelessWidget {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
backToLocationPickingCallback();
|
backToLocationPickingCallback();
|
||||||
},
|
},
|
||||||
text: 'initializing.back_to_locations'.tr(),
|
title: 'initializing.back_to_locations'.tr(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -57,7 +57,7 @@ class RecoveryConfirmBackblaze extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
||||||
text: 'basis.connect'.tr(),
|
title: 'basis.connect'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Builder(
|
Builder(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class RecoveryConfirmDns extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<DnsProviderFormCubit>().trySubmit(),
|
: () => context.read<DnsProviderFormCubit>().trySubmit(),
|
||||||
text: 'basis.connect'.tr(),
|
title: 'basis.connect'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Builder(
|
Builder(
|
||||||
|
|
|
@ -35,7 +35,7 @@ class RecoveryServerProviderConnected extends StatelessWidget {
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
text: 'basis.continue'.tr(),
|
title: 'basis.continue'.tr(),
|
||||||
onPressed: () => context
|
onPressed: () => context
|
||||||
.read<ServerInstallationCubit>()
|
.read<ServerInstallationCubit>()
|
||||||
.skipSettingServerProviderKey(),
|
.skipSettingServerProviderKey(),
|
||||||
|
|
|
@ -110,7 +110,7 @@ class NewUserPage extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<UserFormCubit>().trySubmit(),
|
: () => context.read<UserFormCubit>().trySubmit(),
|
||||||
text: 'basis.create'.tr(),
|
title: 'basis.create'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
Text('users.new_user_info_note'.tr()),
|
Text('users.new_user_info_note'.tr()),
|
||||||
|
|
|
@ -67,7 +67,7 @@ class ResetPassword extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<UserFormCubit>().trySubmit(),
|
: () => context.read<UserFormCubit>().trySubmit(),
|
||||||
text: 'basis.apply'.tr(),
|
title: 'basis.apply'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
|
|
|
@ -332,7 +332,7 @@ class NewSshKey extends StatelessWidget {
|
||||||
onPressed: formCubitState.isSubmitting
|
onPressed: formCubitState.isSubmitting
|
||||||
? null
|
? null
|
||||||
: () => context.read<SshFormCubit>().trySubmit(),
|
: () => context.read<SshFormCubit>().trySubmit(),
|
||||||
text: 'ssh.create'.tr(),
|
title: 'ssh.create'.tr(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue