test base project
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Utils/color_constants.dart';
|
||||
import '../Utils/size_utils.dart';
|
||||
|
||||
class CustomCheckbox extends StatelessWidget {
|
||||
CustomCheckbox(
|
||||
{this.fontStyle,
|
||||
this.alignment,
|
||||
this.isRightCheck = false,
|
||||
this.iconSize,
|
||||
this.value,
|
||||
this.onChange,
|
||||
this.text,
|
||||
this.width,
|
||||
this.margin});
|
||||
|
||||
CheckboxFontStyle? fontStyle;
|
||||
|
||||
Alignment? alignment;
|
||||
|
||||
bool? isRightCheck;
|
||||
|
||||
double? iconSize;
|
||||
|
||||
bool? value;
|
||||
|
||||
Function(bool)? onChange;
|
||||
|
||||
String? text;
|
||||
|
||||
double? width;
|
||||
|
||||
EdgeInsetsGeometry? margin;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return alignment != null
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: _buildCheckboxWidget(),
|
||||
)
|
||||
: _buildCheckboxWidget();
|
||||
}
|
||||
|
||||
_buildCheckboxWidget() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
value = !(value!);
|
||||
onChange!(value!);
|
||||
},
|
||||
child: Container(
|
||||
width: width,
|
||||
margin: margin ?? EdgeInsets.zero,
|
||||
child: isRightCheck! ? getRightSideCheckbox() : getLeftSideCheckbox(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getRightSideCheckbox() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: 8,
|
||||
),
|
||||
child: getTextWidget(),
|
||||
),
|
||||
getCheckboxWidget(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getLeftSideCheckbox() {
|
||||
return Row(
|
||||
children: [
|
||||
getCheckboxWidget(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 8,
|
||||
),
|
||||
child: getTextWidget(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getTextWidget() {
|
||||
return Text(
|
||||
text ?? "",
|
||||
textAlign: TextAlign.center,
|
||||
style: _setFontStyle(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getCheckboxWidget() {
|
||||
return SizedBox(
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
child: Checkbox(
|
||||
value: value ?? false,
|
||||
onChanged: (value) {
|
||||
onChange!(value!);
|
||||
},
|
||||
checkColor: ColorConstant.whiteA700,
|
||||
visualDensity: VisualDensity(
|
||||
vertical: -4,
|
||||
horizontal: -4,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_setFontStyle() {
|
||||
switch (fontStyle) {
|
||||
case CheckboxFontStyle.GilroyMedium16:
|
||||
return TextStyle(
|
||||
color: ColorConstant.blueGray900,
|
||||
fontSize: getFontSize(
|
||||
16,
|
||||
),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
case CheckboxFontStyle.GilroyMedium14:
|
||||
return TextStyle(
|
||||
color: ColorConstant.blueGray300,
|
||||
fontSize: getFontSize(
|
||||
14,
|
||||
),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
default:
|
||||
return TextStyle(
|
||||
color: ColorConstant.blueGray400,
|
||||
fontSize: getFontSize(
|
||||
14,
|
||||
),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w400,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum CheckboxFontStyle { GilroyRegular14, GilroyMedium16, GilroyMedium14 }
|
||||
Reference in New Issue
Block a user