Skip to content

Commit

Permalink
implement ontap for check list
Browse files Browse the repository at this point in the history
  • Loading branch information
li3317 committed Jan 15, 2021
1 parent d8941d8 commit 170f3c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
4 changes: 4 additions & 0 deletions lib/widgets/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class QuillController extends ChangeNotifier {
}
}

void notifyChangeListeners() {
notifyListeners();
}

void redo() {
Tuple2 tup = document.redo();
if (tup.item1) {
Expand Down
42 changes: 17 additions & 25 deletions lib/widgets/text_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,13 @@ class EditableTextBlock extends StatelessWidget {
}

if (attrs[Attribute.list.key] == Attribute.checked) {
return _CheckedPoint(
style: defaultStyles.paragraph.style,
width: 32,
isChecked: true
);
return _Checkbox(
style: defaultStyles.paragraph.style, width: 32, isChecked: true);
}

if (attrs[Attribute.list.key] == Attribute.unchecked) {
return _CheckedPoint(
style: defaultStyles.paragraph.style,
width: 32,
isChecked: false
);
return _Checkbox(
style: defaultStyles.paragraph.style, width: 32, isChecked: false);
}

if (attrs.containsKey(Attribute.codeBlock.key)) {
Expand Down Expand Up @@ -693,37 +687,36 @@ class _BulletPoint extends StatelessWidget {
}
}

class _CheckedPoint extends StatefulWidget {
class _Checkbox extends StatefulWidget {
final TextStyle style;
final double width;
final bool isChecked;

const _CheckedPoint({Key key, this.style, this.width, this.isChecked}) : super(key: key);
const _Checkbox({Key key, this.style, this.width, this.isChecked})
: super(key: key);
@override
_CheckedPointState createState() => _CheckedPointState();
__CheckboxState createState() => __CheckboxState();
}

class _CheckedPointState extends State<_CheckedPoint> {

class __CheckboxState extends State<_Checkbox> {
bool isChecked;

void _onCheckboxClicked(bool newValue) => setState(() {
isChecked = newValue;
isChecked = newValue;

if (isChecked) {
// check list
} else {
// uncheck list
}
});
if (isChecked) {
// check list
} else {
// uncheck list
}
});

@override
void initState() {
super.initState();
isChecked = widget.isChecked;
}


@override
Widget build(BuildContext context) {
return Container(
Expand All @@ -736,5 +729,4 @@ class _CheckedPointState extends State<_CheckedPoint> {
padding: EdgeInsetsDirectional.only(end: 13.0),
);
}

}
}

0 comments on commit 170f3c6

Please sign in to comment.