2020-08-28 20:04:48 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
import 'package:cake_wallet/palette.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CheckboxWidget extends StatefulWidget {
|
|
|
|
CheckboxWidget({
|
2022-10-12 17:09:57 +00:00
|
|
|
required this.value,
|
|
|
|
required this.caption,
|
|
|
|
required this.onChanged});
|
2020-08-28 20:04:48 +00:00
|
|
|
|
|
|
|
final bool value;
|
|
|
|
final String caption;
|
|
|
|
final Function(bool) onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
CheckboxWidgetState createState() => CheckboxWidgetState(value, caption, onChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
class CheckboxWidgetState extends State<CheckboxWidget> {
|
|
|
|
CheckboxWidgetState(this.value, this.caption, this.onChanged);
|
|
|
|
|
|
|
|
bool value;
|
|
|
|
String caption;
|
|
|
|
Function(bool) onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
value = !value;
|
|
|
|
onChanged(value);
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
height: 16,
|
|
|
|
width: 16,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: value
|
|
|
|
? Palette.blueCraiola
|
2022-10-12 17:09:57 +00:00
|
|
|
: Theme.of(context).accentTextTheme!.subtitle1!.decorationColor!,
|
2020-08-28 20:04:48 +00:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
|
|
|
border: Border.all(
|
|
|
|
color: value
|
|
|
|
? Palette.blueCraiola
|
2022-10-12 17:09:57 +00:00
|
|
|
: Theme.of(context).accentTextTheme!.overline!.color!,
|
2020-08-28 20:04:48 +00:00
|
|
|
width: 1
|
|
|
|
)
|
|
|
|
),
|
|
|
|
child: value
|
|
|
|
? Center(
|
|
|
|
child: Icon(
|
|
|
|
Icons.done,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 14,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Offstage(),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 16),
|
|
|
|
child: Text(
|
|
|
|
caption,
|
|
|
|
style: TextStyle(
|
2022-10-12 17:09:57 +00:00
|
|
|
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
|
2020-08-28 20:04:48 +00:00
|
|
|
fontSize: 18,
|
2020-11-11 15:55:18 +00:00
|
|
|
fontFamily: 'Lato',
|
2020-08-28 20:04:48 +00:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
decoration: TextDecoration.none
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|