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.
129 lines
4.1 KiB
Dart
129 lines
4.1 KiB
Dart
import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:progress_hud_v2/generated/i18n.dart';
|
|
|
|
showClickListDialog(BuildContext context, List<ListClinicCentralized> clinicsList, {Function(ListClinicCentralized) onSelection}) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return Dialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(4.0),
|
|
), //this right here
|
|
child: Container(
|
|
width: double.infinity,
|
|
// width: MediaQuery.of(context).size.width - 10,
|
|
height: MediaQuery.of(context).size.height - 80,
|
|
child: ClickListDialog(
|
|
clinicsList: clinicsList,
|
|
onSelection: onSelection,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
class ClickListDialog extends StatefulWidget {
|
|
List<ListClinicCentralized> clinicsList;
|
|
Function(ListClinicCentralized) onSelection;
|
|
|
|
ClickListDialog({this.clinicsList, this.onSelection});
|
|
|
|
@override
|
|
_ClickListDialogState createState() => _ClickListDialogState();
|
|
}
|
|
|
|
class _ClickListDialogState extends State<ClickListDialog> {
|
|
TextEditingController controller = new TextEditingController();
|
|
List<ListClinicCentralized> tempClinicsList = [];
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
addAllData();
|
|
}
|
|
|
|
addAllData() {
|
|
tempClinicsList.clear();
|
|
for (int i = 0; i < widget.clinicsList.length; i++) {
|
|
tempClinicsList.add(widget.clinicsList[i]);
|
|
}
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: TextField(
|
|
controller: controller,
|
|
onChanged: (v) {
|
|
if (v.length > 0) {
|
|
tempClinicsList.clear();
|
|
for (int i = 0; i < widget.clinicsList.length; i++) {
|
|
if (widget.clinicsList[i].clinicDescription.toLowerCase().contains(v.toLowerCase())) {
|
|
tempClinicsList.add(widget.clinicsList[i]);
|
|
}
|
|
}
|
|
} else {
|
|
addAllData();
|
|
}
|
|
setState(() {});
|
|
},
|
|
decoration: InputDecoration(
|
|
hintStyle: TextStyle(fontSize: 17),
|
|
hintText: 'Search Clinic',
|
|
suffixIcon: Icon(Icons.search),
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.all(12),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.separated(
|
|
padding: EdgeInsets.all(12),
|
|
itemBuilder: (context, index) {
|
|
return InkWell(
|
|
onTap: () {
|
|
widget.onSelection(tempClinicsList[index]);
|
|
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(child: Text(tempClinicsList[index].clinicDescription)),
|
|
tempClinicsList[index].isLiveCareClinicAndOnline
|
|
? SvgPicture.asset(
|
|
'assets/images/new-design/video_icon_green_right.svg',
|
|
height: 12,
|
|
width: 12,
|
|
fit: BoxFit.cover,
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
itemCount: tempClinicsList.length,
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return mHeight(8);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|