2020-11-29 20:07:46 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-05-25 12:21:56 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_button/filled_button.dart';
|
2020-12-08 19:26:51 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
2020-11-29 20:07:46 +00:00
|
|
|
|
2020-12-03 16:52:53 +00:00
|
|
|
enum BrandButtonTypes { rised, text, iconText }
|
2020-11-29 20:07:46 +00:00
|
|
|
|
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,
|
|
|
|
title: text,
|
|
|
|
onPressed: onPressed,
|
|
|
|
child: child,
|
|
|
|
),
|
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(
|
2022-05-30 13:55:52 +00:00
|
|
|
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
|
|
|
);
|
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
static IconTextButton emptyWithIconText({
|
2022-06-05 19:36:32 +00:00
|
|
|
required final VoidCallback onPressed,
|
|
|
|
required final String title,
|
|
|
|
required final Icon icon,
|
|
|
|
final Key? key,
|
2020-12-03 16:52:53 +00:00
|
|
|
}) =>
|
2022-06-05 22:40:34 +00:00
|
|
|
IconTextButton(
|
2020-12-03 16:52:53 +00:00
|
|
|
key: key,
|
|
|
|
title: title,
|
2021-02-15 18:58:29 +00:00
|
|
|
onPressed: onPressed,
|
2020-12-03 16:52:53 +00:00
|
|
|
icon: icon,
|
|
|
|
);
|
2020-11-29 20:07:46 +00:00
|
|
|
}
|
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
class IconTextButton extends StatelessWidget {
|
|
|
|
const IconTextButton({
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-06-05 22:40:34 +00:00
|
|
|
this.onPressed,
|
|
|
|
this.title,
|
|
|
|
this.icon,
|
|
|
|
});
|
2020-12-03 16:52:53 +00:00
|
|
|
|
2021-03-15 15:39:44 +00:00
|
|
|
final VoidCallback? onPressed;
|
|
|
|
final String? title;
|
|
|
|
final Icon? icon;
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) => Material(
|
2022-06-05 22:40:34 +00:00
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onPressed,
|
|
|
|
child: Container(
|
|
|
|
height: 48,
|
|
|
|
width: double.infinity,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
BrandText.body1(title),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: icon,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
2020-12-03 16:52:53 +00:00
|
|
|
}
|