2020-11-29 20:07:46 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_colors.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
|
|
|
|
|
|
|
class BrandButton extends StatelessWidget {
|
|
|
|
const BrandButton({
|
|
|
|
Key key,
|
|
|
|
this.onPressed,
|
|
|
|
this.type,
|
|
|
|
this.title,
|
2020-12-03 16:52:53 +00:00
|
|
|
this.icon,
|
2020-11-29 20:07:46 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
final BrandButtonTypes type;
|
|
|
|
final String title;
|
2020-12-03 16:52:53 +00:00
|
|
|
final Icon icon;
|
2020-11-29 20:07:46 +00:00
|
|
|
|
|
|
|
static rised({
|
|
|
|
Key key,
|
2020-11-30 10:03:55 +00:00
|
|
|
@required VoidCallback onPressed,
|
|
|
|
@required String title,
|
2020-11-29 20:07:46 +00:00
|
|
|
}) =>
|
|
|
|
BrandButton(
|
|
|
|
key: key,
|
|
|
|
onPressed: onPressed,
|
|
|
|
title: title,
|
|
|
|
type: BrandButtonTypes.rised,
|
|
|
|
);
|
|
|
|
|
2020-11-30 10:03:55 +00:00
|
|
|
static text({
|
|
|
|
Key key,
|
|
|
|
@required VoidCallback onPressed,
|
|
|
|
@required String title,
|
|
|
|
}) =>
|
|
|
|
BrandButton(
|
|
|
|
key: key,
|
|
|
|
onPressed: onPressed,
|
|
|
|
title: title,
|
|
|
|
type: BrandButtonTypes.text,
|
|
|
|
);
|
|
|
|
|
2020-12-03 16:52:53 +00:00
|
|
|
static iconText({
|
|
|
|
Key key,
|
|
|
|
@required VoidCallback onPressed,
|
|
|
|
@required String title,
|
|
|
|
@required Icon icon,
|
|
|
|
}) =>
|
|
|
|
BrandButton(
|
|
|
|
key: key,
|
|
|
|
onPressed: onPressed,
|
|
|
|
title: title,
|
|
|
|
type: BrandButtonTypes.iconText,
|
|
|
|
icon: icon,
|
|
|
|
);
|
2020-11-29 20:07:46 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
switch (type) {
|
|
|
|
case BrandButtonTypes.rised:
|
|
|
|
return _RisedButton(
|
|
|
|
title: title,
|
|
|
|
onPressed: onPressed,
|
|
|
|
);
|
2020-11-30 10:03:55 +00:00
|
|
|
case BrandButtonTypes.text:
|
|
|
|
return _TextButton(
|
|
|
|
title: title,
|
|
|
|
onPressed: onPressed,
|
|
|
|
);
|
|
|
|
break;
|
2020-12-03 16:52:53 +00:00
|
|
|
case BrandButtonTypes.iconText:
|
|
|
|
return _IconTextButton(
|
|
|
|
title: title,
|
|
|
|
onPressed: onPressed,
|
|
|
|
icon: icon,
|
|
|
|
);
|
|
|
|
break;
|
2020-11-29 20:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _RisedButton extends StatelessWidget {
|
|
|
|
const _RisedButton({
|
|
|
|
Key key,
|
|
|
|
this.onPressed,
|
|
|
|
this.title,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(24),
|
|
|
|
child: ColoredBox(
|
2020-12-06 07:28:31 +00:00
|
|
|
color: onPressed == null
|
|
|
|
? BrandColors.gray2
|
|
|
|
: Theme.of(context).primaryColor,
|
2020-11-29 20:07:46 +00:00
|
|
|
child: Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onPressed,
|
|
|
|
child: Container(
|
|
|
|
height: 48,
|
|
|
|
width: double.infinity,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: BrandColors.white,
|
|
|
|
fontSize: 16,
|
2020-11-30 10:03:55 +00:00
|
|
|
fontWeight: FontWeight.bold,
|
2020-12-30 14:13:25 +00:00
|
|
|
height: 1,
|
2020-11-29 20:07:46 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-11-30 10:03:55 +00:00
|
|
|
|
|
|
|
class _TextButton extends StatelessWidget {
|
|
|
|
const _TextButton({
|
|
|
|
Key key,
|
|
|
|
this.onPressed,
|
|
|
|
this.title,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: onPressed,
|
|
|
|
child: Container(
|
|
|
|
height: 48,
|
|
|
|
width: double.infinity,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: BrandColors.blue,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
height: 1.5,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
class _IconTextButton extends StatelessWidget {
|
|
|
|
const _IconTextButton({Key key, this.onPressed, this.title, this.icon})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
final String title;
|
|
|
|
final Icon icon;
|
|
|
|
|
|
|
|
@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 19:26:51 +00:00
|
|
|
BrandText.body1(title),
|
2020-12-03 16:52:53 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: icon,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|