diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 2ca6603e..59579424 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; @@ -6,7 +7,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; import '../../config/config.dart'; @@ -39,8 +40,12 @@ class _EntityListCheckboxSearchWidgetState extends State= 3) { + setState(() { + _isSearching = true; + }); + widget.model.filterSearchResults(query, widget.masterList, items); + if (mounted) { + setState(() { + _isSearching = false; + }); + } + } else { + setState(() { + _isSearching = false; + }); + } + }); + } + TextEditingController remarksController = TextEditingController(); + Widget _buildProcedureItem(EntityList historyInfo) { + return ExpansionTile( + key: PageStorageKey(historyInfo.procedureId.toString()), + title: Row( + children: [ + Checkbox( + value: widget.isEntityListSelected(historyInfo), + activeColor: Color(0xffD02127), + onChanged: (bool? newValue) { + if (!mounted) return; + setState(() { + if (widget.isEntityListSelected(historyInfo)) { + widget.removeProcedure(historyInfo); + } else { + widget.addProcedure(historyInfo); + } + }); + }, + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: AppText( + Utils.convertToTitleCase(historyInfo.procedureName!), + fontSize: 14.0, + variant: "bodyText", + bold: true, + color: Color(0xff575757), + ), + ), + ), + ], + ), + children: [ + Container( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 11), + child: AppText( + TranslationBase.of(context).orderType, + fontWeight: FontWeight.w700, + color: Color(0xff2B353E), + ), + ), + ], + ), + Row( + children: [ + Radio( + activeColor: Color(0xFFD02127), + value: '0', + groupValue: historyInfo.type, + onChanged: (value) { + if (!mounted) return; + setState(() { + historyInfo.type = value.toString(); + setSelectedType(value!); + }); + }, + ), + AppText( + 'routine', + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + Radio( + activeColor: Color(0xFFD02127), + groupValue: historyInfo.type, + value: '1', + onChanged: (value) { + if (!mounted) return; + setState(() { + historyInfo.type = value.toString(); + setSelectedType(value!); + }); + }, + ), + AppText( + TranslationBase.of(context).urgent, + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + ], + ), + ], + ), + ), + ), + SizedBox(height: 2.0), + Padding( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12.0), + child: TextFields( + hintText: TranslationBase.of(context).remarks, + onChanged: (value) { + historyInfo.remarks = value; + }, + minLines: 3, + maxLines: 5, + borderWidth: 0.5, + borderColor: Colors.grey[500]!, + ), + ), + DividerWithSpacesAround(), + ], + ); + } + @override Widget build(BuildContext context) { return Container( @@ -70,136 +226,81 @@ class _EntityListCheckboxSearchWidgetState extends State(Color(0xFFD02127)), ), - ], - ); - }).toList(), - ) - : Center( - child: Container( - child: AppText("Sorry , No Match", color: AppGlobal.appRedColor), - ), - ) + ), + ) + : InkWell( + onTap: () { + if (procedureName.text.length >= 3) { + widget.model.filterSearchResults( + procedureName.text, widget.masterList, items); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + setState(() {}); + } + }); + } + }, + child: Icon( + Icons.search, + size: 25.0, + ), + ), + hintText: TranslationBase.of(context).searchProcedureHere, + isTextFieldHasSuffix: false, + maxLines: 1, + minLines: 1, + hasBorder: true, + controller: procedureName, + onChanged: (value) { + _onSearchChanged(value ?? ''); + }, + onFieldSubmitted: () { + if (procedureName.text.length >= 3) { + widget.model.filterSearchResults( + procedureName.text, widget.masterList, items); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + setState(() {}); + } + }); + } + }, + ), + ), + if (items.isEmpty && procedureName.text.length >= 3) + Center( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: AppText("Sorry, No Match", color: AppGlobal.appRedColor), + ), + ) + else if (items.isEmpty && procedureName.text.length > 0 && procedureName.text.length < 3) + Center( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: AppText("Please enter at least 3 characters to search", color: Colors.grey), + ), + ) + else + ...items.map((historyInfo) => _buildProcedureItem(historyInfo)).toList(), ], ), )),