From e6970408f851b408bafb517333f5465ca4488f76 Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Mon, 29 Jul 2024 16:06:53 +0200 Subject: [PATCH] add editable option --- .../lib/components/myDropdownInput.dart | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Frontend/patient_manager/lib/components/myDropdownInput.dart b/Frontend/patient_manager/lib/components/myDropdownInput.dart index 8bb84a0e..d4fcbf81 100644 --- a/Frontend/patient_manager/lib/components/myDropdownInput.dart +++ b/Frontend/patient_manager/lib/components/myDropdownInput.dart @@ -7,7 +7,7 @@ class MyDropdownField extends StatefulWidget { final bool required; final List dropdownOptions; final void Function(String?)? onSelect; - //final bool editable; + final bool editable; const MyDropdownField({ super.key, @@ -15,6 +15,7 @@ class MyDropdownField extends StatefulWidget { required this.hintText, required this.dropdownOptions, required this.required, + required this.editable, this.onSelect, }); @@ -100,6 +101,7 @@ class _MyDropdownFieldState extends State { return Padding( padding: const EdgeInsets.symmetric(horizontal: 25.0), child: DropdownMenu( + enabled: widget.editable, trailingIcon: Icon( Icons.arrow_drop_down, color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), @@ -117,9 +119,14 @@ class _MyDropdownFieldState extends State { errorText: _errorText, focusNode: _focus, - onSelected: (_) => setState(() { - startup = false; - }), + onSelected: (_) { + setState(() { + startup = false; + }); + // if (widget.editable == false) { + // return false; + // } + }, leadingIcon: IconButton( onPressed: () { setState(() { @@ -149,9 +156,10 @@ class _MyDropdownFieldState extends State { fontWeight: FontWeight.bold), fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: - MzanziInnovationHub.of(context)!.theme.secondaryColor())), + borderSide: BorderSide( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + ), + ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( color: MzanziInnovationHub.of(context)!.theme.errorColor(), @@ -170,6 +178,12 @@ class _MyDropdownFieldState extends State { width: 2.0, ), ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + width: 2.0, + ), + ), outlineBorder: BorderSide( color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), ),