|
|
|
@ -61,6 +61,7 @@ class EditableTextBlock extends StatelessWidget { |
|
|
|
|
this.embedBuilder, |
|
|
|
|
this.cursorCont, |
|
|
|
|
this.indentLevelCounts, |
|
|
|
|
this.onCheckboxTap, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
final Block block; |
|
|
|
@ -76,6 +77,7 @@ class EditableTextBlock extends StatelessWidget { |
|
|
|
|
final EmbedBuilder embedBuilder; |
|
|
|
|
final CursorCont cursorCont; |
|
|
|
|
final Map<int, int> indentLevelCounts; |
|
|
|
|
final Function(int, bool) onCheckboxTap; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
@ -161,12 +163,22 @@ class EditableTextBlock extends StatelessWidget { |
|
|
|
|
|
|
|
|
|
if (attrs[Attribute.list.key] == Attribute.checked) { |
|
|
|
|
return _Checkbox( |
|
|
|
|
style: defaultStyles!.leading!.style, width: 32, isChecked: true); |
|
|
|
|
style: defaultStyles!.leading!.style, |
|
|
|
|
width: 32, |
|
|
|
|
isChecked: true, |
|
|
|
|
offset: block.offset + line.offset, |
|
|
|
|
onTap: onCheckboxTap, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (attrs[Attribute.list.key] == Attribute.unchecked) { |
|
|
|
|
return _Checkbox( |
|
|
|
|
style: defaultStyles!.leading!.style, width: 32, isChecked: false); |
|
|
|
|
style: defaultStyles!.leading!.style, |
|
|
|
|
width: 32, |
|
|
|
|
isChecked: false, |
|
|
|
|
offset: block.offset + line.offset, |
|
|
|
|
onTap: onCheckboxTap, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (attrs.containsKey(Attribute.codeBlock.key)) { |
|
|
|
@ -685,45 +697,38 @@ class _BulletPoint extends StatelessWidget { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _Checkbox extends StatefulWidget { |
|
|
|
|
const _Checkbox({Key? key, this.style, this.width, this.isChecked}) |
|
|
|
|
: super(key: key); |
|
|
|
|
/// A Checkbox widget. |
|
|
|
|
class _Checkbox extends StatelessWidget { |
|
|
|
|
/// Creates a [_Checkbox]. |
|
|
|
|
const _Checkbox({ |
|
|
|
|
Key? key, |
|
|
|
|
this.style, |
|
|
|
|
this.width, |
|
|
|
|
this.isChecked, |
|
|
|
|
this.offset, |
|
|
|
|
this.onTap, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
final TextStyle? style; |
|
|
|
|
final double? width; |
|
|
|
|
final bool? isChecked; |
|
|
|
|
final int? offset; |
|
|
|
|
final Function(int, bool)? onTap; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
__CheckboxState createState() => __CheckboxState(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class __CheckboxState extends State<_Checkbox> { |
|
|
|
|
bool? isChecked; |
|
|
|
|
|
|
|
|
|
void _onCheckboxClicked(bool? newValue) => setState(() { |
|
|
|
|
isChecked = newValue; |
|
|
|
|
|
|
|
|
|
if (isChecked!) { |
|
|
|
|
// check list |
|
|
|
|
} else { |
|
|
|
|
// uncheck list |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
isChecked = widget.isChecked; |
|
|
|
|
void _onCheckboxClicked(bool? newValue) { |
|
|
|
|
if (onTap != null && newValue != null && offset != null) { |
|
|
|
|
onTap!(offset!, newValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
|
alignment: AlignmentDirectional.topEnd, |
|
|
|
|
width: widget.width, |
|
|
|
|
width: width, |
|
|
|
|
padding: const EdgeInsetsDirectional.only(end: 13), |
|
|
|
|
child: Checkbox( |
|
|
|
|
value: widget.isChecked, |
|
|
|
|
value: isChecked, |
|
|
|
|
onChanged: _onCheckboxClicked, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|