mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
feat: remember delete task option (#542)
This commit is contained in:
11 files changed
+120
-42
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CompactCheckbox extends StatefulWidget {
|
||||
final String label;
|
||||
final bool value;
|
||||
final ValueChanged<bool?>? onChanged;
|
||||
final double? scale;
|
||||
final TextStyle? textStyle;
|
||||
|
||||
const CompactCheckbox({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.onChanged,
|
||||
this.scale,
|
||||
this.textStyle,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CompactCheckbox> createState() => _CompactCheckboxState();
|
||||
}
|
||||
|
||||
class _CompactCheckboxState extends State<CompactCheckbox> {
|
||||
late bool _value;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_value = widget.value;
|
||||
}
|
||||
|
||||
valueChanged(bool? value) {
|
||||
setState(() {
|
||||
_value = value!;
|
||||
});
|
||||
widget.onChanged?.call(_value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final checkbox = Checkbox(
|
||||
value: _value,
|
||||
onChanged: valueChanged,
|
||||
);
|
||||
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
valueChanged(!_value);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
widget.scale == null
|
||||
? checkbox
|
||||
: Transform.scale(
|
||||
scale: widget.scale,
|
||||
child: checkbox,
|
||||
),
|
||||
Text(
|
||||
widget.label,
|
||||
style: widget.textStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user