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.
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
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';
|
|
|
|
class MasterKeyDailog extends StatefulWidget {
|
|
final List<MasterKeyModel> list;
|
|
final okText;
|
|
final Function(MasterKeyModel) okFunction;
|
|
MasterKeyModel selectedValue;
|
|
|
|
MasterKeyDailog(
|
|
{@required this.list,
|
|
@required this.okText,
|
|
@required this.okFunction});
|
|
|
|
@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) {
|
|
return showAlertDialog(context);
|
|
}
|
|
|
|
showAlertDialog(BuildContext context) {
|
|
// 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(),
|
|
actions: [
|
|
cancelButton,
|
|
continueButton,
|
|
],
|
|
);
|
|
return alert;
|
|
}
|
|
|
|
Widget createDialogList() {
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
...widget.list
|
|
.map((item) => RadioListTile(
|
|
title: Text(item.nameEn.toString()),
|
|
groupValue: widget.selectedValue.id.toString(),
|
|
value: item.id.toString(),
|
|
activeColor: Colors.blue.shade700,
|
|
selected: item.id.toString() == widget.selectedValue.id.toString(),
|
|
onChanged: (val) {
|
|
setState(() {
|
|
widget.selectedValue = item;
|
|
});
|
|
},
|
|
))
|
|
.toList()
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static closeAlertDialog(BuildContext context) {
|
|
Navigator.of(context).pop();
|
|
}
|
|
}
|