You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
7.3 KiB
Dart
186 lines
7.3 KiB
Dart
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart';
|
|
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'app-textfield-custom.dart';
|
|
import 'app_texts_widget.dart';
|
|
|
|
class MasterKeyCheckboxSearchWidget extends StatefulWidget {
|
|
final SOAPViewModel model;
|
|
final Function addSelectedHistories;
|
|
final Function(MasterKeyModel) removeHistory;
|
|
final Function(MasterKeyModel) addHistory;
|
|
final bool Function(MasterKeyModel) isServiceSelected;
|
|
final List<MasterKeyModel> masterList;
|
|
final String buttonName;
|
|
final String hintSearchText;
|
|
|
|
MasterKeyCheckboxSearchWidget(
|
|
{Key key,
|
|
this.model,
|
|
this.addSelectedHistories,
|
|
this.removeHistory,
|
|
this.masterList,
|
|
this.addHistory,
|
|
this.isServiceSelected, this.buttonName, this.hintSearchText})
|
|
: super(key: key);
|
|
|
|
@override
|
|
_MasterKeyCheckboxSearchWidgetState createState() => _MasterKeyCheckboxSearchWidgetState();
|
|
}
|
|
|
|
class _MasterKeyCheckboxSearchWidgetState extends State<MasterKeyCheckboxSearchWidget> {
|
|
List<MasterKeyModel> items = List();
|
|
|
|
@override
|
|
void initState() {
|
|
items.addAll(widget.masterList);
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
return Container(
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.rectangle,
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.fromBorderSide(BorderSide(
|
|
color: Colors.grey.shade400,
|
|
width: 0.4,
|
|
)),
|
|
),
|
|
height: MediaQuery.of(context).size.height * 0.60,
|
|
child: Center(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white),
|
|
child: ListView(
|
|
children: [
|
|
AppTextFieldCustom(
|
|
height: MediaQuery.of(context).size.height * 0.070,
|
|
hintText: TranslationBase.of(context).searchHistory,
|
|
isDropDown: true,
|
|
hasBorder: false,
|
|
// controller: filteredSearchController,
|
|
onChanged: (value) {
|
|
filterSearchResults(value);
|
|
},
|
|
suffixIcon: Icon(
|
|
Icons.search,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
|
|
// SizedBox(height: 15,),
|
|
DividerWithSpacesAround(),
|
|
Container(
|
|
// padding:EdgeInsets.all(20),
|
|
child: Column(
|
|
children: items.map((historyInfo) {
|
|
return Column(
|
|
children: [
|
|
InkWell(
|
|
onTap:(){
|
|
|
|
setState(() {
|
|
if (widget
|
|
.isServiceSelected(historyInfo)) {
|
|
widget.removeHistory(historyInfo);
|
|
} else {
|
|
widget.addHistory(historyInfo);
|
|
}
|
|
});
|
|
},
|
|
|
|
child: Row(
|
|
children: [
|
|
Checkbox(
|
|
value:
|
|
widget.isServiceSelected(historyInfo),
|
|
activeColor: Colors.red[800],
|
|
onChanged: (bool newValue) {
|
|
setState(() {
|
|
if (widget
|
|
.isServiceSelected(historyInfo)) {
|
|
widget.removeHistory(historyInfo);
|
|
} else {
|
|
widget.addHistory(historyInfo);
|
|
}
|
|
});
|
|
}),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 10, vertical: 0),
|
|
child: AppText(projectViewModel.isArabic
|
|
? historyInfo.nameAr!=""?historyInfo.nameAr:historyInfo.nameEn
|
|
: historyInfo.nameEn,
|
|
color: Color(0xFF575757),
|
|
fontSize: 16,
|
|
fontWeight:FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// DividerWithSpacesAround(),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void filterSearchResults(String query) {
|
|
List<MasterKeyModel> dummySearchList = List();
|
|
dummySearchList.addAll(widget.masterList);
|
|
if (query.isNotEmpty) {
|
|
List<MasterKeyModel> dummyListData = List();
|
|
dummySearchList.forEach((item) {
|
|
if (item.nameAr.toLowerCase().contains(query.toLowerCase()) ||
|
|
item.nameEn.toLowerCase().contains(query.toLowerCase())) {
|
|
dummyListData.add(item);
|
|
}
|
|
});
|
|
setState(() {
|
|
items.clear();
|
|
items.addAll(dummyListData);
|
|
});
|
|
return;
|
|
} else {
|
|
setState(() {
|
|
items.clear();
|
|
items.addAll(widget.masterList);
|
|
});
|
|
}
|
|
}
|
|
}
|