Merge branch 'feature-ucaf' into 'development'

Feature ucaf

See merge request Cloud_Solution/doctor_app_flutter!284
merge-requests/285/merge
Mohammad Aljammal 5 years ago
commit 1f6d2c940c

@ -52,6 +52,8 @@ const Map<String, Map<String, String>> localizedValues = {
'referPatient': {'en': 'Referral Patient', 'ar': 'إحالة مريض'}, 'referPatient': {'en': 'Referral Patient', 'ar': 'إحالة مريض'},
'myReferral': {'en': 'My Referral', 'ar': 'إحالة'}, 'myReferral': {'en': 'My Referral', 'ar': 'إحالة'},
'myReferredPatient': {'en': 'My Referred Patient', 'ar': 'مرضاي المحالين'}, 'myReferredPatient': {'en': 'My Referred Patient', 'ar': 'مرضاي المحالين'},
'referredPatient': {'en': 'Referred Patient', 'ar': 'المرضى المحالين'},
'referredOn': {'en': 'referred On : ', 'ar': ' : تمت الإحالة في'},
'firstName': {'en': 'First Name', 'ar': 'الاسم الاول'}, 'firstName': {'en': 'First Name', 'ar': 'الاسم الاول'},
'middleName': {'en': 'Middle Name', 'ar': 'اسم الاب'}, 'middleName': {'en': 'Middle Name', 'ar': 'اسم الاب'},
'lastName': {'en': 'Last Name', 'ar': 'اسم العائلة'}, 'lastName': {'en': 'Last Name', 'ar': 'اسم العائلة'},
@ -692,5 +694,7 @@ const Map<String, Map<String, String>> localizedValues = {
'referralStatusCancelled': {'en': "Cancelled", 'ar': "ملغاة"}, 'referralStatusCancelled': {'en': "Cancelled", 'ar': "ملغاة"},
'referralStatusCompleted': {'en': "Completed", 'ar': "مكتمل"}, 'referralStatusCompleted': {'en': "Completed", 'ar': "مكتمل"},
'referralStatusNotSeen': {'en': "NotSeen", 'ar': "لم يرى"}, 'referralStatusNotSeen': {'en': "NotSeen", 'ar': "لم يرى"},
'clinicSearch': {'en': "Search Clinic", 'ar': "بحث عن عيادة"},
'doctorSearch': {'en': "Search Doctor", 'ar': "بحث عن طبيب"},
// 'icd': {'en': "ICD", 'ar': " "}, // 'icd': {'en': "ICD", 'ar': " "},
}; };

@ -42,7 +42,8 @@ class MyReferralDetailScreen extends StatelessWidget {
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).referPatient, appBarTitle: TranslationBase.of(context).referPatient,
body: model.patientArrivalList != null && model.patientArrivalList.length > 0 body: model.patientArrivalList != null &&
model.patientArrivalList.length > 0
? Column( ? Column(
children: [ children: [
Expanded( Expanded(
@ -77,6 +78,7 @@ class MyReferralDetailScreen extends StatelessWidget {
), ),
), ),
PatientReferralItemWidget( PatientReferralItemWidget(
"${pendingReferral.patientID}",
patientName: pendingReferral.patientName, patientName: pendingReferral.patientName,
referralStatus: null, referralStatus: null,
isReferredTo: false, isReferredTo: false,
@ -86,6 +88,7 @@ class MyReferralDetailScreen extends StatelessWidget {
pendingReferral.referredByDoctorInfo, pendingReferral.referredByDoctorInfo,
clinicDescription: null, clinicDescription: null,
remark: pendingReferral.remarksFromSource, remark: pendingReferral.remarksFromSource,
referredOn: pendingReferral.referredOn,
), ),
SizedBox( SizedBox(
child: GridView.count( child: GridView.count(
@ -147,8 +150,9 @@ class MyReferralDetailScreen extends StatelessWidget {
hPadding: 8, hPadding: 8,
vPadding: 12, vPadding: 12,
handler: () async { handler: () async {
await model.responseReferral(pendingReferral, true); await model.responseReferral(
if(model.state == ViewState.ErrorLocal){ pendingReferral, true);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error); DrAppToastMsg.showErrorToast(model.error);
} }
}, },
@ -166,8 +170,9 @@ class MyReferralDetailScreen extends StatelessWidget {
hPadding: 8, hPadding: 8,
vPadding: 12, vPadding: 12,
handler: () async { handler: () async {
await model.responseReferral(pendingReferral, true); await model.responseReferral(
if(model.state == ViewState.ErrorLocal){ pendingReferral, true);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error); DrAppToastMsg.showErrorToast(model.error);
} }
}, },

@ -23,8 +23,7 @@ class MyReferralPatientScreen extends StatelessWidget {
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).referPatient, appBarTitle: TranslationBase.of(context).referPatient,
body: model.pendingReferral == null || body: model.pendingReferral == null || model.pendingReferral.length == 0
model.pendingReferral.length == 0
? Center( ? Center(
child: AppText( child: AppText(
TranslationBase.of(context).referralEmptyMsg, TranslationBase.of(context).referralEmptyMsg,
@ -62,6 +61,7 @@ class MyReferralPatientScreen extends StatelessWidget {
...List.generate( ...List.generate(
model.pendingReferral.length, model.pendingReferral.length,
(index) => PatientReferralItemWidget( (index) => PatientReferralItemWidget(
"${model.pendingReferral[index].patientID}",
patientName: model.pendingReferral[index].patientName, patientName: model.pendingReferral[index].patientName,
referralStatus: null, referralStatus: null,
isReferredTo: false, isReferredTo: false,
@ -72,13 +72,13 @@ class MyReferralPatientScreen extends StatelessWidget {
clinicDescription: null, clinicDescription: null,
remark: remark:
model.pendingReferral[index].remarksFromSource, model.pendingReferral[index].remarksFromSource,
referredOn: model.pendingReferral[index].referredOn,
infoIcon: InkWell( infoIcon: InkWell(
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context)
MY_REFERRAL_DETAIL, .pushNamed(MY_REFERRAL_DETAIL, arguments: {
arguments: { 'referral': model.pendingReferral[index]
'referral': model.pendingReferral[index] });
});
}, },
child: Icon( child: Icon(
Icons.info_outline, Icons.info_outline,

@ -1,17 +1,14 @@
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart';
@ -20,8 +17,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import '../../../QR_reader_screen.dart';
class PatientMakeReferralScreen extends StatefulWidget { class PatientMakeReferralScreen extends StatefulWidget {
// previous design page is: ReferPatientScreen // previous design page is: ReferPatientScreen
@override @override
@ -96,6 +91,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
model.patientReferral.length == 0 model.patientReferral.length == 0
? ReferralForm(model, screenSize) ? ReferralForm(model, screenSize)
: PatientReferralItemWidget( : PatientReferralItemWidget(
"${model.patientReferral[0].patientID}",
patientName: model.patientReferral[0].patientName, patientName: model.patientReferral[0].patientName,
referralStatus: referralStatus:
"${model.patientReferral[0].referralStatus}", "${model.patientReferral[0].referralStatus}",
@ -105,7 +101,9 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
referralDoctorName: referralDoctorName:
model.patientReferral[0].referredByDoctorInfo, model.patientReferral[0].referredByDoctorInfo,
clinicDescription: null, clinicDescription: null,
remark: model.patientReferral[0].remarksFromSource), remark: model.patientReferral[0].remarksFromSource,
referredOn: model.patientReferral[0].referredOn,
),
], ],
), ),
if (model.patientReferral.length == 0) if (model.patientReferral.length == 0)
@ -201,7 +199,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
} }
: null, : null,
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).referTo, TranslationBase.of(context).referTo,
_referTo != null ? _referTo['name'] : null, _referTo != null ? _referTo['name'] : null,
true), true),
@ -248,7 +246,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
} }
: null, : null,
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).branch, TranslationBase.of(context).branch,
_selectedBranch != null _selectedBranch != null
? _selectedBranch['facilityName'] ? _selectedBranch['facilityName']
@ -272,6 +270,8 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
list: model.clinicsList, list: model.clinicsList,
attributeName: 'ClinicDescription', attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID', attributeValueId: 'ClinicID',
usingSearch: true,
hintSearchText: TranslationBase.of(context).clinicSearch,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
@ -296,7 +296,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
} }
: null, : null,
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).clinic, TranslationBase.of(context).clinic,
_selectedClinic != null _selectedClinic != null
? _selectedClinic['ClinicDescription'] ? _selectedClinic['ClinicDescription']
@ -320,6 +320,8 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
list: model.doctorsList, list: model.doctorsList,
attributeName: 'DoctorName', attributeName: 'DoctorName',
attributeValueId: 'DoctorID', attributeValueId: 'DoctorID',
usingSearch: true,
hintSearchText: TranslationBase.of(context).doctorSearch,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
@ -337,7 +339,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
} }
: null, : null,
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).doctor, TranslationBase.of(context).doctor,
_selectedDoctor != null _selectedDoctor != null
? _selectedDoctor['DoctorName'] ? _selectedDoctor['DoctorName']
@ -355,7 +357,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
child: InkWell( child: InkWell(
onTap: () => _selectDate(context, model), onTap: () => _selectDate(context, model),
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).chooseAppointment, TranslationBase.of(context).chooseAppointment,
appointmentDate != null appointmentDate != null
? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}" ? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}"
@ -374,7 +376,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
), ),
Container( Container(
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: Helpers.textFieldSelectorDecoration(
TranslationBase.of(context).remarks, null, false), TranslationBase.of(context).remarks, null, false),
enabled: true, enabled: true,
controller: _remarksController, controller: _remarksController,
@ -453,49 +455,4 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
});*/ });*/
} }
} }
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown
? suffixIcon != null
? suffixIcon
: Icon(
Icons.arrow_drop_down,
color: Colors.black,
)
: null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
BoxDecoration containerBorderDecoration(
Color containerColor, Color borderColor) {
return BoxDecoration(
color: containerColor,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.all(Radius.circular(6)),
border: Border.fromBorderSide(BorderSide(
color: borderColor,
width: 2.0,
)),
);
}
} }

@ -1,5 +1,6 @@
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
@ -14,7 +15,7 @@ class ReferredPatientScreen extends StatelessWidget {
onModelReady: (model) => model.getMyReferredPatient(), onModelReady: (model) => model.getMyReferredPatient(),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).referPatient, appBarTitle: TranslationBase.of(context).referredPatient,
body: model.listMyReferredPatientModel == null || body: model.listMyReferredPatientModel == null ||
model.listMyReferredPatientModel.length == 0 model.listMyReferredPatientModel.length == 0
? Center( ? Center(
@ -45,6 +46,7 @@ class ReferredPatientScreen extends StatelessWidget {
...List.generate( ...List.generate(
model.listMyReferredPatientModel.length, model.listMyReferredPatientModel.length,
(index) => PatientReferralItemWidget( (index) => PatientReferralItemWidget(
"${model.getReferredPatientItem(index).patientId}",
patientName: patientName:
"${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}", "${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}",
referralStatus: referralStatus:
@ -62,6 +64,12 @@ class ReferredPatientScreen extends StatelessWidget {
remark: model remark: model
.getReferredPatientItem(index) .getReferredPatientItem(index)
.referringDoctorRemarks, .referringDoctorRemarks,
referredOn: model
.getReferredPatientItem(index)
.referralDate !=
null
? DateUtils.convertDateFromServerFormat(model.getReferredPatientItem(index).referralDate, "dd/MM/yyyy")
: null,
), ),
), ),
], ],

@ -117,6 +117,10 @@ class TranslationBase {
String get myReferredPatient => String get myReferredPatient =>
localizedValues['myReferredPatient'][locale.languageCode]; localizedValues['myReferredPatient'][locale.languageCode];
String get referredPatient =>
localizedValues['referredPatient'][locale.languageCode];
String get referredOn =>
localizedValues['referredOn'][locale.languageCode];
String get firstName => localizedValues['firstName'][locale.languageCode]; String get firstName => localizedValues['firstName'][locale.languageCode];
@ -1065,6 +1069,8 @@ String get ICDName =>
String get referralStatusCancelled => localizedValues['referralStatusCancelled'][locale.languageCode]; String get referralStatusCancelled => localizedValues['referralStatusCancelled'][locale.languageCode];
String get referralStatusCompleted => localizedValues['referralStatusCompleted'][locale.languageCode]; String get referralStatusCompleted => localizedValues['referralStatusCompleted'][locale.languageCode];
String get referralStatusNotSeen => localizedValues['referralStatusNotSeen'][locale.languageCode]; String get referralStatusNotSeen => localizedValues['referralStatusNotSeen'][locale.languageCode];
String get clinicSearch => localizedValues['clinicSearch'][locale.languageCode];
String get doctorSearch => localizedValues['doctorSearch'][locale.languageCode];
String get patientName => String get patientName =>
localizedValues['patient-name'][locale.languageCode]; localizedValues['patient-name'][locale.languageCode];

@ -4,15 +4,18 @@ import 'package:flutter/material.dart';
class PatientReferralItemWidget extends StatelessWidget { class PatientReferralItemWidget extends StatelessWidget {
final String patientName; final String patientName;
final String patientID;
final String referralStatus; final String referralStatus;
final isReferredTo; final isReferredTo;
final isSameBranch; final isSameBranch;
final String referralDoctorName; final String referralDoctorName;
final String clinicDescription; final String clinicDescription;
final String remark; final String remark;
final String referredOn;
final Widget infoIcon; final Widget infoIcon;
PatientReferralItemWidget({ PatientReferralItemWidget(
this.patientID, {
this.patientName, this.patientName,
this.referralStatus, this.referralStatus,
this.isReferredTo = false, this.isReferredTo = false,
@ -20,6 +23,7 @@ class PatientReferralItemWidget extends StatelessWidget {
this.referralDoctorName, this.referralDoctorName,
this.clinicDescription, this.clinicDescription,
this.remark, this.remark,
this.referredOn,
this.infoIcon, this.infoIcon,
}); });
@ -35,7 +39,6 @@ class PatientReferralItemWidget extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
if (referralStatus != null) if (referralStatus != null)
Row( Row(
children: [ children: [
@ -131,6 +134,25 @@ class PatientReferralItemWidget extends StatelessWidget {
SizedBox( SizedBox(
height: 8, height: 8,
), ),
Row(
children: [
AppText(
"${TranslationBase.of(context).patientID}: ",
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 12,
),
AppText(
patientID ?? '-',
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 12,
),
],
),
SizedBox(
height: 8,
),
Row( Row(
children: [ children: [
AppText( AppText(
@ -140,7 +162,7 @@ class PatientReferralItemWidget extends StatelessWidget {
fontSize: 12, fontSize: 12,
), ),
AppText( AppText(
patientName??'-', patientName ?? '-',
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 12,
@ -166,6 +188,25 @@ class PatientReferralItemWidget extends StatelessWidget {
), ),
], ],
), ),
SizedBox(
height: 8,
),
Row(
children: [
AppText(
TranslationBase.of(context).referredOn,
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 12,
),
AppText(
referredOn ?? '-',
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 12,
),
],
),
SizedBox( SizedBox(
height: 16, height: 16,
), ),

@ -2,6 +2,8 @@ import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ListSelectDialog extends StatefulWidget { class ListSelectDialog extends StatefulWidget {
@ -12,24 +14,32 @@ class ListSelectDialog extends StatefulWidget {
final Function(dynamic) okFunction; final Function(dynamic) okFunction;
dynamic selectedValue; dynamic selectedValue;
final Widget searchWidget; final Widget searchWidget;
final bool usingSearch;
final String hintSearchText;
ListSelectDialog( ListSelectDialog({
{@required this.list, @required this.list,
@required this.attributeName, @required this.attributeName,
@required this.attributeValueId, @required this.attributeValueId,
@required this.okText, @required this.okText,
@required this.okFunction, @required this.okFunction,
this.searchWidget}); this.searchWidget,
this.usingSearch = false,
this.hintSearchText,
});
@override @override
_ListSelectDialogState createState() => _ListSelectDialogState(); _ListSelectDialogState createState() => _ListSelectDialogState();
} }
class _ListSelectDialogState extends State<ListSelectDialog> { class _ListSelectDialogState extends State<ListSelectDialog> {
List<dynamic> items = List();
@override @override
void initState() { void initState() {
super.initState();
widget.selectedValue = widget.selectedValue ?? widget.list[0]; widget.selectedValue = widget.selectedValue ?? widget.list[0];
items.addAll(widget.list);
super.initState();
} }
@override @override
@ -69,7 +79,21 @@ class _ListSelectDialogState extends State<ListSelectDialog> {
child: Column( child: Column(
children: [ children: [
if (widget.searchWidget != null) widget.searchWidget, if (widget.searchWidget != null) widget.searchWidget,
...widget.list if(widget.usingSearch)
Container(
height: MediaQuery.of(context).size.height * 0.070,
child: TextField(
decoration: Helpers.textFieldSelectorDecoration(
widget.hintSearchText ?? TranslationBase
.of(context)
.search, null, false, suffixIcon: Icon(Icons.search,)),
enabled: true,
keyboardType: TextInputType.text,
onChanged: (value) {
filterSearchResults(value);
},
)),
...items
.map((item) => RadioListTile( .map((item) => RadioListTile(
title: Text("${item[widget.attributeName].toString()}"), title: Text("${item[widget.attributeName].toString()}"),
groupValue: widget.selectedValue[widget.attributeValueId] groupValue: widget.selectedValue[widget.attributeValueId]
@ -95,4 +119,27 @@ class _ListSelectDialogState extends State<ListSelectDialog> {
static closeAlertDialog(BuildContext context) { static closeAlertDialog(BuildContext context) {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
void filterSearchResults(String query) {
List<dynamic> dummySearchList = List();
dummySearchList.addAll(widget.list);
if (query.isNotEmpty) {
List<dynamic> dummyListData = List();
dummySearchList.forEach((item) {
if ("${item[widget.attributeName].toString()}".toLowerCase().contains(query.toLowerCase())) {
dummyListData.add(item);
}
});
setState(() {
items.clear();
items.addAll(dummyListData);
});
return;
} else {
setState(() {
items.clear();
items.addAll(widget.list);
});
}
}
} }

Loading…
Cancel
Save