92 lines
1.7 KiB
Dart
92 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../utils/size_utils.dart';
|
|
|
|
class CustomFloatingButton extends StatelessWidget {
|
|
CustomFloatingButton(
|
|
{super.key, this.shape,
|
|
this.variant,
|
|
this.alignment,
|
|
this.margin,
|
|
this.onTap,
|
|
this.width,
|
|
this.height,
|
|
this.child});
|
|
|
|
FloatingButtonShape? shape;
|
|
|
|
FloatingButtonVariant? variant;
|
|
|
|
Alignment? alignment;
|
|
|
|
EdgeInsetsGeometry? margin;
|
|
|
|
VoidCallback? onTap;
|
|
|
|
double? width;
|
|
|
|
double? height;
|
|
|
|
Widget? child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return alignment != null
|
|
? Align(
|
|
alignment: alignment ?? Alignment.center,
|
|
child: _buildFabWidget(),
|
|
)
|
|
: _buildFabWidget();
|
|
}
|
|
|
|
_buildFabWidget() {
|
|
return Padding(
|
|
padding: margin ?? EdgeInsets.zero,
|
|
child: FloatingActionButton(
|
|
backgroundColor: _setColor(),
|
|
onPressed: onTap,
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
width: getSize(width ?? 0),
|
|
height: getSize(height ?? 0),
|
|
decoration: _buildDecoration(),
|
|
child: child,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_buildDecoration() {
|
|
return BoxDecoration(
|
|
color: _setColor(),
|
|
borderRadius: _setBorderRadius(),
|
|
);
|
|
}
|
|
|
|
_setColor() {
|
|
switch (variant) {
|
|
default:
|
|
return const Color.fromRGBO(253, 202, 101, 1.0);
|
|
}
|
|
}
|
|
|
|
_setBorderRadius() {
|
|
switch (shape) {
|
|
default:
|
|
return BorderRadius.circular(
|
|
getHorizontalSize(
|
|
6.00,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
enum FloatingButtonShape {
|
|
RoundedBorder6,
|
|
}
|
|
|
|
enum FloatingButtonVariant {
|
|
FillBlueA700,
|
|
}
|