selfprivacy.org.app/lib/ui/components/buttons/brand_button.dart

67 lines
1.8 KiB
Dart
Raw Normal View History

2020-11-29 20:07:46 +00:00
import 'package:flutter/material.dart';
2021-02-15 18:58:29 +00:00
class BrandButton {
2022-06-05 19:36:32 +00:00
static ConstrainedBox rised({
required final VoidCallback? onPressed,
final Key? key,
final String? text,
final Widget? child,
2021-02-15 18:58:29 +00:00
}) {
2021-05-25 21:53:54 +00:00
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
2022-05-16 22:41:00 +00:00
return ConstrainedBox(
2022-05-24 18:55:39 +00:00
constraints: const BoxConstraints(
2022-05-16 22:41:00 +00:00
minHeight: 48,
minWidth: double.infinity,
),
child: FilledButton(
key: key,
onPressed: onPressed,
2023-02-05 13:24:37 +00:00
child: child ?? Text(text ?? ''),
),
);
}
static ConstrainedBox filled({
required final VoidCallback? onPressed,
final Key? key,
final String? text,
final Widget? child,
}) {
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
return ConstrainedBox(
constraints: const BoxConstraints(
minWidth: double.infinity,
),
child: FilledButton(
key: key,
onPressed: onPressed,
2023-05-30 17:52:42 +00:00
style: ElevatedButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.padded,
2023-12-28 17:07:30 +00:00
padding: const EdgeInsets.symmetric(horizontal: 16.0),
2023-05-30 17:52:42 +00:00
),
2023-12-28 17:07:30 +00:00
child: child ??
Text(
text ?? '',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
),
2022-05-16 22:41:00 +00:00
),
2021-02-15 18:58:29 +00:00
);
}
2020-11-29 20:07:46 +00:00
2022-06-05 19:36:32 +00:00
static ConstrainedBox text({
required final VoidCallback onPressed,
required final String title,
final Key? key,
2020-11-30 10:03:55 +00:00
}) =>
2022-05-16 22:41:00 +00:00
ConstrainedBox(
2022-05-24 18:55:39 +00:00
constraints: const BoxConstraints(
minHeight: 40,
2022-05-16 22:41:00 +00:00
minWidth: double.infinity,
),
child: TextButton(onPressed: onPressed, child: Text(title)),
2020-11-30 10:03:55 +00:00
);
2020-12-03 16:52:53 +00:00
}