diff --git a/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart b/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart new file mode 100644 index 00000000..9eda3852 --- /dev/null +++ b/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; + +class MihToggle extends StatefulWidget { + final String hintText; + final bool initialPostion; + final Color fillColor; + final Color secondaryFillColor; + final void Function(bool) onChange; + const MihToggle({ + super.key, + required this.hintText, + required this.initialPostion, + required this.fillColor, + required this.secondaryFillColor, + required this.onChange, + }); + + @override + State createState() => _MihToggleState(); +} + +class _MihToggleState extends State { + late bool togglePosition; + + @override + void initState() { + super.initState(); + setState(() { + togglePosition = widget.initialPostion; + }); + } + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Text( + widget.hintText, + style: TextStyle( + fontWeight: FontWeight.bold, + color: widget.fillColor, + fontSize: 15, + ), + ), + ), + const SizedBox(width: 10), + Switch( + value: widget.initialPostion, + activeColor: widget.secondaryFillColor, + activeTrackColor: widget.fillColor, + inactiveThumbColor: widget.fillColor, + inactiveTrackColor: widget.secondaryFillColor, + onChanged: widget.onChange, + ), + ], + ); + } +}