|
|
|
|
@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/utils/utils.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
@ -15,17 +16,20 @@ class MasterKeyDailog extends StatefulWidget {
|
|
|
|
|
MasterKeyModel? selectedValue;
|
|
|
|
|
String? selectedStringValue;
|
|
|
|
|
final bool isICD;
|
|
|
|
|
|
|
|
|
|
MasterKeyDailog({required this.list, required this.okText, required this.okFunction, this.selectedValue, this.isICD = false, this.selectedStringValue});
|
|
|
|
|
final bool isSearch;
|
|
|
|
|
MasterKeyDailog({required this.list, required this.okText, required this.okFunction, this.selectedValue, this.isICD = false, this.selectedStringValue, this.isSearch =false});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_MasterKeyDailogState createState() => _MasterKeyDailogState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MasterKeyDailogState extends State<MasterKeyDailog> {
|
|
|
|
|
List<MasterKeyModel> items = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
items.addAll(widget.list);
|
|
|
|
|
widget.selectedValue = widget.selectedValue ?? widget.list.first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -74,6 +78,20 @@ class _MasterKeyDailogState extends State<MasterKeyDailog> {
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
if (widget.isSearch)
|
|
|
|
|
Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.070,
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: Utils.textFieldSelectorDecoration(TranslationBase.of(context).search, "", false,
|
|
|
|
|
suffixIcon: Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
)),
|
|
|
|
|
enabled: true,
|
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
filterSearchResults(value, projectViewModel);
|
|
|
|
|
},
|
|
|
|
|
)),
|
|
|
|
|
...widget.list
|
|
|
|
|
.map((item) => RadioListTile(
|
|
|
|
|
title: AppText(
|
|
|
|
|
@ -99,4 +117,27 @@ class _MasterKeyDailogState extends State<MasterKeyDailog> {
|
|
|
|
|
static closeAlertDialog(BuildContext context) {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterSearchResults(String query,ProjectViewModel projectViewModel ) {
|
|
|
|
|
List<MasterKeyModel> dummySearchList = [];
|
|
|
|
|
dummySearchList.addAll(widget.list);
|
|
|
|
|
if (query.isNotEmpty) {
|
|
|
|
|
List<MasterKeyModel> dummyListData = [];
|
|
|
|
|
dummySearchList.forEach((item) {
|
|
|
|
|
if ((projectViewModel.isArabic ? item.nameAr : item.nameEn! + (widget.isICD ? '/${item.code}' : ''))!.toLowerCase().contains(query.toLowerCase())) {
|
|
|
|
|
dummyListData.add(item);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
setState(() {
|
|
|
|
|
items.clear();
|
|
|
|
|
items.addAll(dummyListData);
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
items.clear();
|
|
|
|
|
items.addAll(widget.list);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|