diff --git a/lib/ui/components/buttons/brand_button.dart b/lib/ui/components/buttons/brand_button.dart index c381af43..bb2e722a 100644 --- a/lib/ui/components/buttons/brand_button.dart +++ b/lib/ui/components/buttons/brand_button.dart @@ -7,8 +7,9 @@ class BrandButton { final String? text, final Widget? child, }) { - assert(text == null || child == null, 'required title or child'); - assert(text != null || child != null, 'required title or 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, @@ -28,8 +29,9 @@ class BrandButton { final String? text, final Widget? child, }) { - assert(text == null || child == null, 'required title or child'); - assert(text != null || child != null, 'required title or 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( minWidth: double.infinity, diff --git a/lib/ui/components/buttons/buttons.dart b/lib/ui/components/buttons/buttons.dart new file mode 100644 index 00000000..49e0bb07 --- /dev/null +++ b/lib/ui/components/buttons/buttons.dart @@ -0,0 +1,2 @@ +export 'brand_button.dart'; +export 'sp_brand_button.dart'; diff --git a/lib/ui/components/buttons/sp_brand_button.dart b/lib/ui/components/buttons/sp_brand_button.dart new file mode 100644 index 00000000..036b30f2 --- /dev/null +++ b/lib/ui/components/buttons/sp_brand_button.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class SPBrandButton extends StatelessWidget { + const SPBrandButton({ + required this.child, + required this.onPressed, + super.key, + }); + + SPBrandButton.text({ + required final String title, + required this.onPressed, + super.key, + }) : child = Text(title); + + final Widget child; + final VoidCallback onPressed; + + @override + Widget build(final BuildContext context) => FilledButton( + // TODO(misterfourtytwo): move button styles to theme configuration + style: const ButtonStyle( + minimumSize: MaterialStatePropertyAll(Size.fromHeight(48)), + ), + onPressed: onPressed, + child: child, + ); +}