|
|
|
|
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:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
|
class MasterKeyDailog extends StatefulWidget {
|
|
|
|
|
final List<MasterKeyModel> list;
|
|
|
|
|
final okText;
|
|
|
|
|
final Function(MasterKeyModel) okFunction;
|
|
|
|
|
MasterKeyModel selectedValue;
|
|
|
|
|
final bool isICD;
|
|
|
|
|
|
|
|
|
|
MasterKeyDailog(
|
|
|
|
|
{@required this.list,
|
|
|
|
|
@required this.okText,
|
|
|
|
|
@required this.okFunction,
|
|
|
|
|
this.selectedValue,
|
|
|
|
|
this.isICD = false});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_MasterKeyDailogState createState() => _MasterKeyDailogState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MasterKeyDailogState extends State<MasterKeyDailog> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
widget.selectedValue = widget.selectedValue ?? widget.list[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
|
return showAlertDialog(context, projectViewModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showAlertDialog(BuildContext context, ProjectViewModel projectViewModel) {
|
|
|
|
|
// set up the buttons
|
|
|
|
|
Widget cancelButton = FlatButton(
|
|
|
|
|
child: Text(TranslationBase.of(context).cancel),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
});
|
|
|
|
|
Widget continueButton = FlatButton(
|
|
|
|
|
child: Text(this.widget.okText),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
this.widget.okFunction(widget.selectedValue);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
});
|
|
|
|
|
// set up the AlertDialog
|
|
|
|
|
AlertDialog alert = AlertDialog(
|
|
|
|
|
// title: Text(widget.title),
|
|
|
|
|
content: createDialogList(projectViewModel),
|
|
|
|
|
actions: [
|
|
|
|
|
cancelButton,
|
|
|
|
|
continueButton,
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
return alert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget createDialogList(ProjectViewModel projectViewModel) {
|
|
|
|
|
return Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
...widget.list
|
|
|
|
|
.map((item) => RadioListTile(
|
|
|
|
|
title: Text(
|
|
|
|
|
'${projectViewModel.isArabic?item.nameAr:item.nameEn}' + (widget.isICD ? '/${item.code}' : '')),
|
|
|
|
|
groupValue: widget.isICD
|
|
|
|
|
? widget.selectedValue.code.toString()
|
|
|
|
|
: widget.selectedValue.id.toString(),
|
|
|
|
|
value: widget.isICD ? widget.selectedValue.code.toString() : item
|
|
|
|
|
.id.toString(),
|
|
|
|
|
activeColor: Colors.blue.shade700,
|
|
|
|
|
selected: widget.isICD ? item.code.toString() ==
|
|
|
|
|
widget.selectedValue.code.toString() : item.id.toString() ==
|
|
|
|
|
widget.selectedValue.id.toString(),
|
|
|
|
|
onChanged: (val) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.selectedValue = item;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
.toList()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static closeAlertDialog(BuildContext context) {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
}
|