refactor(ui): Delete BrandButton.rised

This commit is contained in:
Inex Code 2024-10-30 15:01:46 +03:00
parent a5020e729e
commit 3cd61e9cee
11 changed files with 16 additions and 38 deletions

View file

@ -1,28 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class BrandButton { class BrandButton {
static ConstrainedBox rised({
required final VoidCallback? onPressed,
final Key? key,
final String? text,
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');
return ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 48,
minWidth: double.infinity,
),
child: FilledButton(
key: key,
onPressed: onPressed,
child: child ?? Text(text ?? ''),
),
);
}
static ConstrainedBox filled({ static ConstrainedBox filled({
required final VoidCallback? onPressed, required final VoidCallback? onPressed,
final Key? key, final Key? key,

View file

@ -77,7 +77,7 @@ class JobsContent extends StatelessWidget {
widgets = [ widgets = [
...widgets, ...widgets,
const Gap(80), const Gap(80),
BrandButton.rised( BrandButton.filled(
onPressed: () => context.read<JobsCubit>().upgradeServer(), onPressed: () => context.read<JobsCubit>().upgradeServer(),
text: 'jobs.upgrade_server'.tr(), text: 'jobs.upgrade_server'.tr(),
), ),
@ -368,7 +368,7 @@ class JobsContent extends StatelessWidget {
}, },
), ),
const Gap(16), const Gap(16),
BrandButton.rised( BrandButton.filled(
onPressed: () => context.read<JobsCubit>().acknowledgeFinished(), onPressed: () => context.read<JobsCubit>().acknowledgeFinished(),
text: 'basis.done'.tr(), text: 'basis.done'.tr(),
), ),
@ -432,7 +432,7 @@ class JobsContent extends StatelessWidget {
), ),
), ),
const Gap(16), const Gap(16),
BrandButton.rised( BrandButton.filled(
onPressed: hasBlockingJobs onPressed: hasBlockingJobs
? null ? null
: () => context.read<JobsCubit>().applyAll(), : () => context.read<JobsCubit>().applyAll(),

View file

@ -80,7 +80,7 @@ class BackupDetailsPage extends StatelessWidget {
), ),
), ),
if (!preventActions) if (!preventActions)
BrandButton.rised( BrandButton.filled(
onPressed: preventActions onPressed: preventActions
? null ? null
: () { : () {

View file

@ -116,7 +116,7 @@ class ProviderInputDataPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
BrandButton.rised( BrandButton.filled(
text: 'basis.connect'.tr(), text: 'basis.connect'.tr(),
onPressed: () => providerCubit.trySubmit(), onPressed: () => providerCubit.trySubmit(),
), ),
@ -197,7 +197,7 @@ class ProviderSelectionPage extends StatelessWidget {
style: Theme.of(context).textTheme.bodySmall, style: Theme.of(context).textTheme.bodySmall,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
text: 'basis.select'.tr(), text: 'basis.select'.tr(),
onPressed: () { onPressed: () {
serverInstallationCubit serverInstallationCubit
@ -252,7 +252,7 @@ class ProviderSelectionPage extends StatelessWidget {
style: Theme.of(context).textTheme.bodySmall, style: Theme.of(context).textTheme.bodySmall,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
text: 'basis.select'.tr(), text: 'basis.select'.tr(),
onPressed: () { onPressed: () {
serverInstallationCubit serverInstallationCubit
@ -308,7 +308,7 @@ class ProviderSelectionPage extends StatelessWidget {
style: Theme.of(context).textTheme.bodySmall, style: Theme.of(context).textTheme.bodySmall,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
text: 'basis.select'.tr(), text: 'basis.select'.tr(),
onPressed: () { onPressed: () {
serverInstallationCubit serverInstallationCubit

View file

@ -304,7 +304,7 @@ class InitializingPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<BackblazeFormCubit>().trySubmit(), : () => context.read<BackblazeFormCubit>().trySubmit(),
@ -624,7 +624,7 @@ class AddSshKey extends StatelessWidget {
), ),
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context : () => context

View file

@ -211,7 +211,7 @@ class SelectTypePage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
onPressed: () { onPressed: () {
backToLocationPickingCallback(); backToLocationPickingCallback();
}, },

View file

@ -53,7 +53,7 @@ class RecoveryConfirmBackblaze extends StatelessWidget {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<BackblazeFormCubit>().trySubmit(), : () => context.read<BackblazeFormCubit>().trySubmit(),

View file

@ -51,7 +51,7 @@ class RecoveryConfirmDns extends StatelessWidget {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<DnsProviderFormCubit>().trySubmit(), : () => context.read<DnsProviderFormCubit>().trySubmit(),

View file

@ -106,7 +106,7 @@ class NewUserPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<UserFormCubit>().trySubmit(), : () => context.read<UserFormCubit>().trySubmit(),

View file

@ -63,7 +63,7 @@ class ResetPassword extends StatelessWidget {
), ),
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<UserFormCubit>().trySubmit(), : () => context.read<UserFormCubit>().trySubmit(),

View file

@ -328,7 +328,7 @@ class NewSshKey extends StatelessWidget {
), ),
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
BrandButton.rised( BrandButton.filled(
onPressed: formCubitState.isSubmitting onPressed: formCubitState.isSubmitting
? null ? null
: () => context.read<SshFormCubit>().trySubmit(), : () => context.read<SshFormCubit>().trySubmit(),