add readonly mode to toggle
This commit is contained in:
@@ -5,6 +5,7 @@ class MihToggle extends StatefulWidget {
|
|||||||
final bool initialPostion;
|
final bool initialPostion;
|
||||||
final Color fillColor;
|
final Color fillColor;
|
||||||
final Color secondaryFillColor;
|
final Color secondaryFillColor;
|
||||||
|
final bool? readOnly;
|
||||||
final void Function(bool) onChange;
|
final void Function(bool) onChange;
|
||||||
const MihToggle({
|
const MihToggle({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -12,6 +13,7 @@ class MihToggle extends StatefulWidget {
|
|||||||
required this.initialPostion,
|
required this.initialPostion,
|
||||||
required this.fillColor,
|
required this.fillColor,
|
||||||
required this.secondaryFillColor,
|
required this.secondaryFillColor,
|
||||||
|
this.readOnly,
|
||||||
required this.onChange,
|
required this.onChange,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -49,11 +51,20 @@ class _MihToggleState extends State<MihToggle> {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Switch(
|
Switch(
|
||||||
value: widget.initialPostion,
|
value: widget.initialPostion,
|
||||||
activeColor: widget.secondaryFillColor,
|
activeColor:
|
||||||
activeTrackColor: widget.fillColor,
|
widget.readOnly == true ? Colors.grey : widget.secondaryFillColor,
|
||||||
inactiveThumbColor: widget.fillColor,
|
activeTrackColor:
|
||||||
inactiveTrackColor: widget.secondaryFillColor,
|
widget.readOnly == true ? Colors.grey.shade400 : widget.fillColor,
|
||||||
onChanged: widget.onChange,
|
inactiveThumbColor:
|
||||||
|
widget.readOnly == true ? Colors.grey : widget.fillColor,
|
||||||
|
inactiveTrackColor: widget.readOnly == true
|
||||||
|
? Colors.grey.shade400
|
||||||
|
: widget.secondaryFillColor,
|
||||||
|
// activeColor: widget.secondaryFillColor,
|
||||||
|
// activeTrackColor: widget.fillColor,
|
||||||
|
// inactiveThumbColor: widget.fillColor,
|
||||||
|
// inactiveTrackColor: widget.secondaryFillColor,
|
||||||
|
onChanged: widget.readOnly != true ? widget.onChange : null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user