86 lines
2.4 KiB
Dart
86 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:ui_kit/ui_kit.dart';
|
|
|
|
class ButtonWidget extends StatefulWidget {
|
|
const ButtonWidget({
|
|
super.key,
|
|
required this.onPressed,
|
|
required this.label,
|
|
this.textStyle,
|
|
this.size = 'big',
|
|
required this.variant,
|
|
});
|
|
final VoidCallback onPressed;
|
|
final String label;
|
|
final TextStyle? textStyle;
|
|
final String size;
|
|
final String variant;
|
|
|
|
@override
|
|
State<ButtonWidget> createState() => _ButtonWidgetState();
|
|
}
|
|
|
|
class _ButtonWidgetState extends State<ButtonWidget> {
|
|
late Color bgColor;
|
|
late TextStyle textStyle;
|
|
late Color borderColor;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (widget.variant == 'flat') {
|
|
bgColor = primaryColor;
|
|
borderColor = Colors.transparent;
|
|
if (widget.size == 'big') {
|
|
textStyle = title2Semibold.copyWith(color: whiteColor);
|
|
} else if (widget.size == 'small') {
|
|
textStyle = captionSemibold.copyWith(color: whiteColor);
|
|
}
|
|
}
|
|
if (widget.variant == 'inactive') {
|
|
bgColor = primaryHoverColor;
|
|
borderColor = Colors.transparent;
|
|
if (widget.size == 'big') {
|
|
textStyle = title2Semibold.copyWith(color: whiteColor);
|
|
} else if (widget.size == 'small') {
|
|
textStyle = captionSemibold.copyWith(color: whiteColor);
|
|
}
|
|
}
|
|
if (widget.variant == 'solid') {
|
|
bgColor = Colors.transparent;
|
|
borderColor = primaryColor;
|
|
|
|
if (widget.size == 'big') {
|
|
textStyle = title2Semibold.copyWith(color: primaryColor);
|
|
} else if (widget.size == 'small') {
|
|
textStyle = captionSemibold.copyWith(color: primaryColor);
|
|
}
|
|
}
|
|
if (widget.variant == 'ghost') {
|
|
bgColor = inputBgColor;
|
|
borderColor = Colors.transparent;
|
|
if (widget.size == 'big') {
|
|
textStyle = title2Semibold.copyWith(color: blackColor);
|
|
} else if (widget.size == 'small') {
|
|
textStyle = captionSemibold.copyWith(color: blackColor);
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: widget.size == 'small' ? 40 : 56,
|
|
width: widget.size == 'small' ? 96 : width(context) * 100,
|
|
decoration: BoxDecoration(
|
|
color: bgColor,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: borderColor),
|
|
),
|
|
child: TextButton(
|
|
onPressed: widget.onPressed,
|
|
child: Text(widget.label, style: textStyle),
|
|
),
|
|
);
|
|
}
|
|
}
|