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

90 lines
2.1 KiB
Dart
Raw Normal View History

2020-11-29 22:07:46 +02:00
import 'package:flutter/material.dart';
import 'package:selfprivacy/ui/components/brand_button/filled_button.dart';
2020-12-08 21:26:51 +02:00
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
2020-11-29 22:07:46 +02:00
2020-12-03 18:52:53 +02:00
enum BrandButtonTypes { rised, text, iconText }
2020-11-29 22:07:46 +02:00
2021-02-15 20:58:29 +02:00
class BrandButton {
2020-11-29 22:07:46 +02:00
static rised({
2021-03-15 17:39:44 +02:00
Key? key,
required VoidCallback? onPressed,
2021-05-26 00:53:54 +03:00
String? text,
2021-03-15 17:39:44 +02:00
Widget? child,
2021-02-15 20:58:29 +02:00
}) {
2021-05-26 00:53:54 +03:00
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
2022-05-17 01:41:00 +03:00
return ConstrainedBox(
2022-05-24 21:55:39 +03:00
constraints: const BoxConstraints(
2022-05-17 01:41:00 +03:00
minHeight: 48,
minWidth: double.infinity,
),
child: FilledButton(
key: key,
title: text,
onPressed: onPressed,
child: child,
),
2021-02-15 20:58:29 +02:00
);
}
2020-11-29 22:07:46 +02:00
2020-11-30 12:03:55 +02:00
static text({
2021-03-15 17:39:44 +02:00
Key? key,
required VoidCallback onPressed,
required String title,
2020-11-30 12:03:55 +02:00
}) =>
2022-05-17 01:41:00 +03:00
ConstrainedBox(
2022-05-24 21:55:39 +03:00
constraints: const BoxConstraints(
minHeight: 40,
2022-05-17 01:41:00 +03:00
minWidth: double.infinity,
),
child: TextButton(onPressed: onPressed, child: Text(title)),
2020-11-30 12:03:55 +02:00
);
2021-03-26 15:38:39 +02:00
static emptyWithIconText({
2021-03-15 17:39:44 +02:00
Key? key,
required VoidCallback onPressed,
required String title,
required Icon icon,
2020-12-03 18:52:53 +02:00
}) =>
2021-02-15 20:58:29 +02:00
_IconTextButton(
2020-12-03 18:52:53 +02:00
key: key,
title: title,
2021-02-15 20:58:29 +02:00
onPressed: onPressed,
2020-12-03 18:52:53 +02:00
icon: icon,
);
2020-11-29 22:07:46 +02:00
}
2020-12-03 18:52:53 +02:00
class _IconTextButton extends StatelessWidget {
2021-03-15 17:39:44 +02:00
const _IconTextButton({Key? key, this.onPressed, this.title, this.icon})
2020-12-03 18:52:53 +02:00
: super(key: key);
2021-03-15 17:39:44 +02:00
final VoidCallback? onPressed;
final String? title;
final Icon? icon;
2020-12-03 18:52:53 +02:00
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onPressed,
child: Container(
height: 48,
width: double.infinity,
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2020-12-08 21:26:51 +02:00
BrandText.body1(title),
2020-12-03 18:52:53 +02:00
Padding(
padding: const EdgeInsets.all(12.0),
child: icon,
)
],
),
),
),
);
}
}