From 11fc60627028dde09ffba8e593e948da23d1b830 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Tue, 10 Jun 2025 09:34:36 +0200 Subject: [PATCH] update font --- .../mih_radio_options.dart | 130 ++++++++++++++++++ .../mih_text_form_field.dart | 9 +- .../mih_package_components/mih_toggle.dart | 2 +- 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 Frontend/lib/mih_components/mih_package_components/mih_radio_options.dart diff --git a/Frontend/lib/mih_components/mih_package_components/mih_radio_options.dart b/Frontend/lib/mih_components/mih_package_components/mih_radio_options.dart new file mode 100644 index 00000000..4eb44ee2 --- /dev/null +++ b/Frontend/lib/mih_components/mih_package_components/mih_radio_options.dart @@ -0,0 +1,130 @@ +import 'package:flutter/material.dart'; + +class MihRadioOptions extends StatefulWidget { + final TextEditingController controller; + final String hintText; + final Color fillColor; + final Color secondaryFillColor; + final bool requiredText; + final List radioOptions; + const MihRadioOptions({ + super.key, + required this.controller, + required this.hintText, + required this.fillColor, + required this.secondaryFillColor, + required this.requiredText, + required this.radioOptions, + }); + + @override + State createState() => _MihRadioOptionsState(); +} + +class _MihRadioOptionsState extends State { + late String _currentSelection; + + @override + void initState() { + super.initState(); + setState(() { + _currentSelection = widget.radioOptions[0]; + }); + } + + Widget displayRadioOptions() { + return Material( + elevation: 4.0, + borderRadius: BorderRadius.circular(8.0), + child: Container( + decoration: BoxDecoration( + color: widget.fillColor, + borderRadius: BorderRadius.circular(8.0), + ), + child: Column( + children: widget.radioOptions.map((option) { + return GestureDetector( + onTap: () { + setState(() { + int index = widget.radioOptions + .indexWhere((element) => element == option); + _currentSelection = widget.radioOptions[index]; + widget.controller.text = option; + }); + }, + child: Row( + children: [ + const SizedBox(width: 10), + Expanded( + child: Text( + option, + style: TextStyle( + color: widget.secondaryFillColor, + fontWeight: FontWeight.w500, + fontSize: 15, + ), + ), + ), + Radio( + value: option, + groupValue: _currentSelection, + onChanged: (value) { + setState(() { + _currentSelection = value!; + widget.controller.text = value; + }); + }, + activeColor: widget.secondaryFillColor, + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.selected)) { + return widget.secondaryFillColor; // Color when selected + } + return widget.secondaryFillColor; + }), + ), + ], + ), + ); + }).toList(), + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + widget.hintText, + textAlign: TextAlign.left, + style: TextStyle( + color: widget.fillColor, + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + Visibility( + visible: !widget.requiredText, + child: Text( + "(Optional)", + textAlign: TextAlign.right, + style: TextStyle( + color: widget.fillColor, + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + const SizedBox(height: 4), + displayRadioOptions(), + ], + ); + } +} diff --git a/Frontend/lib/mih_components/mih_package_components/mih_text_form_field.dart b/Frontend/lib/mih_components/mih_package_components/mih_text_form_field.dart index 438f45d6..7675561b 100644 --- a/Frontend/lib/mih_components/mih_package_components/mih_text_form_field.dart +++ b/Frontend/lib/mih_components/mih_package_components/mih_text_form_field.dart @@ -19,6 +19,7 @@ class MihTextFormField extends StatefulWidget { final FormFieldValidator? validator; final List? autofillHints; final double? elevation; + final TextAlign? textIputAlignment; const MihTextFormField({ Key? key, @@ -38,6 +39,7 @@ class MihTextFormField extends StatefulWidget { this.validator, this.autofillHints, this.elevation, + this.textIputAlignment, }) : super(key: key); @override @@ -108,7 +110,7 @@ class _MihTextFormFieldState extends State { textAlign: TextAlign.left, style: TextStyle( color: widget.fillColor, - fontSize: 15, + fontSize: 18, fontWeight: FontWeight.bold, ), ), @@ -144,13 +146,14 @@ class _MihTextFormFieldState extends State { BorderRadius.circular(widget.borderRadius ?? 8.0), child: SizedBox( height: widget.height != null - ? widget.height! - 25 + ? widget.height! - 30 : null, child: TextFormField( controller: widget.controller, cursorColor: widget.inputColor, autofillHints: widget.autofillHints, - textAlign: TextAlign.start, + textAlign: + widget.textIputAlignment ?? TextAlign.start, textAlignVertical: widget.multiLineInput == true ? TextAlignVertical.top : TextAlignVertical.center, 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 42ff508c..5872bf6c 100644 --- a/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart +++ b/Frontend/lib/mih_components/mih_package_components/mih_toggle.dart @@ -44,7 +44,7 @@ class _MihToggleState extends State { style: TextStyle( fontWeight: FontWeight.bold, color: widget.fillColor, - fontSize: 15, + fontSize: 18, ), ), ),