You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.3 KiB
Dart
109 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
class CheckBoxWithTitleDescription extends StatelessWidget {
|
|
final bool isSelected;
|
|
final String title, description;
|
|
final Function(bool) onSelection;
|
|
final bool isDisabled;
|
|
|
|
const CheckBoxWithTitleDescription({
|
|
required this.isSelected,
|
|
required this.title,
|
|
required this.description,
|
|
required this.onSelection,
|
|
this.isDisabled = false,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: isDisabled
|
|
? null
|
|
: () {
|
|
onSelection(!isSelected);
|
|
},
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Row(
|
|
crossAxisAlignment: description.isNotEmpty ? CrossAxisAlignment.start : CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Checkbox(
|
|
value: isSelected,
|
|
activeColor: isDisabled ? MyColors.lightIconColor : MyColors.darkPrimaryColor,
|
|
onChanged: isDisabled
|
|
? null
|
|
: (bool? v) {
|
|
onSelection(v ?? false);
|
|
},
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
title.toText(fontSize: 14, isBold: true),
|
|
if (description.isNotEmpty) ...[
|
|
description.toText(fontSize: 12, color: MyColors.lightTextColor),
|
|
]
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class CircleCheckBoxWithTitle extends StatelessWidget {
|
|
final bool isChecked;
|
|
final String title;
|
|
final Function() onSelected;
|
|
final Color selectedColor;
|
|
|
|
const CircleCheckBoxWithTitle({super.key, required this.title, required this.isChecked, required this.onSelected, required this.selectedColor});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
height: 20,
|
|
width: 20,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: isChecked ? selectedColor : Colors.transparent,
|
|
border: Border.all(
|
|
color: isChecked ? Colors.transparent : MyColors.darkTextColor,
|
|
),
|
|
),
|
|
child: const Center(child: Icon(Icons.check_rounded, size: 16, color: MyColors.white)),
|
|
),
|
|
5.width,
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
title.toText(fontSize: 14),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
).onPress(() {
|
|
onSelected();
|
|
}),
|
|
);
|
|
}
|
|
}
|