mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-09-19 09:57:50 +00:00
197 lines
4.3 KiB
Dart
197 lines
4.3 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
|
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
|
|
|
enum BrandButtonTypes { rised, text, iconText }
|
|
|
|
class BrandButton extends StatelessWidget {
|
|
const BrandButton({
|
|
Key key,
|
|
this.onPressed,
|
|
this.type,
|
|
this.title,
|
|
this.icon,
|
|
}) : super(key: key);
|
|
|
|
final VoidCallback onPressed;
|
|
final BrandButtonTypes type;
|
|
final String title;
|
|
final Icon icon;
|
|
|
|
static rised({
|
|
Key key,
|
|
@required VoidCallback onPressed,
|
|
@required String title,
|
|
}) =>
|
|
BrandButton(
|
|
key: key,
|
|
onPressed: onPressed,
|
|
title: title,
|
|
type: BrandButtonTypes.rised,
|
|
);
|
|
|
|
static text({
|
|
Key key,
|
|
@required VoidCallback onPressed,
|
|
@required String title,
|
|
}) =>
|
|
BrandButton(
|
|
key: key,
|
|
onPressed: onPressed,
|
|
title: title,
|
|
type: BrandButtonTypes.text,
|
|
);
|
|
|
|
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,
|
|
);
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
switch (type) {
|
|
case BrandButtonTypes.rised:
|
|
return _RisedButton(
|
|
title: title,
|
|
onPressed: onPressed,
|
|
);
|
|
case BrandButtonTypes.text:
|
|
return _TextButton(
|
|
title: title,
|
|
onPressed: onPressed,
|
|
);
|
|
break;
|
|
case BrandButtonTypes.iconText:
|
|
return _IconTextButton(
|
|
title: title,
|
|
onPressed: onPressed,
|
|
icon: icon,
|
|
);
|
|
break;
|
|
}
|
|
|
|
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(
|
|
color: onPressed == null
|
|
? BrandColors.gray2
|
|
: Theme.of(context).primaryColor,
|
|
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,
|
|
fontWeight: FontWeight.bold,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
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: [
|
|
BrandText.body1(title),
|
|
Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: icon,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|