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.
diplomatic-quarter/lib/widgets/dialogs/RadioStringDialog.dart

151 lines
5.0 KiB
Dart

4 years ago
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class RadioStringDialog extends StatefulWidget {
final List<String> radioList;
final Function(String) onValueSelected;
final String title;
String selectedValue;
RadioStringDialog(
{Key key,
this.radioList,
this.onValueSelected,
this.selectedValue,
this.title});
@override
_RadioStringDialogState createState() => _RadioStringDialogState();
}
class _RadioStringDialogState extends State<RadioStringDialog> {
@override
void initState() {
super.initState();
widget.selectedValue = widget.selectedValue ?? widget.radioList[0];
}
@override
Widget build(BuildContext context) {
return SimpleDialog(
title: Container(
width: double.infinity,
child: Center(
child: Texts(
widget.title,
textAlign: TextAlign.center,
))),
children: [
Container(
height: widget.radioList.length > 3
? MediaQuery.of(context).size.height * 0.6
: null,
child: SingleChildScrollView(
child: Column(
children: [
Divider(),
...List.generate(
widget.radioList.length,
(index) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 2,
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
setState(() {
widget.selectedValue =
widget.radioList[index];
});
},
child: ListTile(
title: Text(widget.radioList[index]),
leading: Radio(
value: widget.radioList[index],
groupValue: widget.selectedValue,
activeColor: Colors.red[800],
onChanged: (value) {
setState(() {
widget.selectedValue = value;
});
},
),
),
),
)
],
),
SizedBox(
height: 5.0,
),
],
),
),
SizedBox(
height: 5.0,
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Center(
child: Texts(
TranslationBase.of(context)
.cancel
.toUpperCase(),
color: Colors.red,
),
),
),
),
),
),
Container(
width: 1,
height: 30,
color: Colors.grey[500],
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
widget.onValueSelected(widget.selectedValue);
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Texts(
TranslationBase.of(context).ok,
fontWeight: FontWeight.w400,
),
),
),
),
),
],
)
],
),
),
)
],
);
}
}