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.
162 lines
5.8 KiB
Dart
162 lines
5.8 KiB
Dart
import 'package:device_calendar/device_calendar.dart';
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.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 DayCheckBoxDialog extends StatefulWidget {
|
|
final Function(List<DayOfWeek>) onValueSelected;
|
|
final String title;
|
|
final List<DayOfWeek> selectedDaysOfWeek;
|
|
final List<DayOfWeek> daysOfWeek = [
|
|
DayOfWeek.Monday,
|
|
DayOfWeek.Tuesday,
|
|
DayOfWeek.Wednesday,
|
|
DayOfWeek.Thursday,
|
|
DayOfWeek.Friday,
|
|
DayOfWeek.Saturday,
|
|
DayOfWeek.Sunday,
|
|
];
|
|
|
|
DayCheckBoxDialog(
|
|
{Key key, this.onValueSelected, this.selectedDaysOfWeek, this.title});
|
|
|
|
@override
|
|
_DayCheckBoxDialogState createState() => _DayCheckBoxDialogState();
|
|
}
|
|
|
|
class _DayCheckBoxDialogState extends State<DayCheckBoxDialog> {
|
|
@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.daysOfWeek.length > 3
|
|
? MediaQuery.of(context).size.height * 0.6
|
|
: null,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Divider(),
|
|
...List.generate(
|
|
widget.daysOfWeek.length,
|
|
(index) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 2,
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
if (widget.selectedDaysOfWeek
|
|
.contains(widget.daysOfWeek[index]))
|
|
widget.selectedDaysOfWeek
|
|
.remove(widget.daysOfWeek[index]);
|
|
else
|
|
widget.selectedDaysOfWeek
|
|
.add(widget.daysOfWeek[index]);
|
|
});
|
|
},
|
|
child: ListTile(
|
|
title: Text(DateUtil.getDay(widget.daysOfWeek[index])),
|
|
leading: Checkbox(
|
|
value: widget.selectedDaysOfWeek
|
|
.contains(widget.daysOfWeek[index]),
|
|
onChanged: (value) {
|
|
setState(() {
|
|
if (widget.selectedDaysOfWeek
|
|
.contains(widget.daysOfWeek[index]))
|
|
widget.selectedDaysOfWeek
|
|
.remove(widget.daysOfWeek[index]);
|
|
else
|
|
widget.selectedDaysOfWeek
|
|
.add(widget.daysOfWeek[index]);
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
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.selectedDaysOfWeek);
|
|
Navigator.pop(context);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Center(
|
|
child: Texts(
|
|
TranslationBase.of(context).ok,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
|
|
}
|