From 6292a2b0ca0b71def7d81750b4d26baf88069439 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Thu, 12 Jun 2025 13:15:11 +0200 Subject: [PATCH] dynamic switch color --- .../mih_package_components/mih_toggle.dart | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart b/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart index 5872bf6c..afda13b0 100644 --- a/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart +++ b/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:mzansi_innovation_hub/main.dart'; class MihToggle extends StatefulWidget { final String hintText; @@ -51,15 +52,28 @@ class _MihToggleState extends State { const SizedBox(width: 10), Switch( value: widget.initialPostion, + trackOutlineColor: WidgetStateProperty.resolveWith( + (states) { + if (states.contains(WidgetState.selected)) { + return MzanziInnovationHub.of(context)! + .theme + .successColor(); // Outline color when active + } + return MzanziInnovationHub.of(context)! + .theme + .errorColor(); // Outline color when active + }, + ), activeColor: widget.readOnly == true ? Colors.grey : widget.secondaryFillColor, - activeTrackColor: - widget.readOnly == true ? Colors.grey.shade400 : widget.fillColor, + activeTrackColor: widget.readOnly == true + ? Colors.grey.shade400 + : MzanziInnovationHub.of(context)!.theme.successColor(), inactiveThumbColor: - widget.readOnly == true ? Colors.grey : widget.fillColor, + widget.readOnly == true ? Colors.grey : widget.secondaryFillColor, inactiveTrackColor: widget.readOnly == true ? Colors.grey.shade400 - : widget.secondaryFillColor, + : MzanziInnovationHub.of(context)!.theme.errorColor(), // activeColor: widget.secondaryFillColor, // activeTrackColor: widget.fillColor, // inactiveThumbColor: widget.fillColor,