68 lines
1.9 KiB
Dart
68 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:satu/shared/app_colors.dart';
|
|
import 'package:satu/shared/ui_helpers.dart';
|
|
|
|
import 'note_text.dart';
|
|
|
|
class InputCheckBox extends StatelessWidget {
|
|
const InputCheckBox(this.text,
|
|
{required this.value, this.labelText, this.onChanged});
|
|
|
|
final String text;
|
|
final bool value;
|
|
final String? labelText;
|
|
final Function(bool? value)? onChanged;
|
|
|
|
Color getColor(Set<MaterialState> states) {
|
|
const Set<MaterialState> interactiveStates = <MaterialState>{
|
|
MaterialState.pressed,
|
|
MaterialState.hovered,
|
|
MaterialState.focused,
|
|
};
|
|
if (states.any(interactiveStates.contains)) {
|
|
return Colors.blue;
|
|
}
|
|
return primaryColor;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (labelText != null)
|
|
Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 14.0, vertical: 5.0),
|
|
child: NoteText(labelText ?? ''),
|
|
),
|
|
Container(
|
|
decoration: const BoxDecoration(color: whiteColor),
|
|
child: Padding(
|
|
padding: EdgeInsets.only(left: 5, right: 15),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Checkbox(
|
|
value: value,
|
|
onChanged: onChanged,
|
|
//checkColor: primaryColor,
|
|
fillColor: MaterialStateProperty.resolveWith(getColor),
|
|
),
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
verticalSpaceSmall
|
|
],
|
|
);
|
|
}
|
|
}
|