fix datetpicker wip
This commit is contained in:
parent
4b71867ee0
commit
c12a957099
@ -54,6 +54,10 @@ class _EditEventState extends State<EditEvent>
|
|||||||
TextEditingController endTimepicker = TextEditingController();
|
TextEditingController endTimepicker = TextEditingController();
|
||||||
final _stringTagController = StringTagController();
|
final _stringTagController = StringTagController();
|
||||||
|
|
||||||
|
var dateS = null;
|
||||||
|
var timeS = null;
|
||||||
|
var dateE = null;
|
||||||
|
var timeE = null;
|
||||||
List<Map<String, dynamic>> suggestions = [];
|
List<Map<String, dynamic>> suggestions = [];
|
||||||
String geographicalZone = "";
|
String geographicalZone = "";
|
||||||
String imgUrl = "";
|
String imgUrl = "";
|
||||||
@ -66,20 +70,19 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
onTapFunctionDatePicker(
|
onTapFunctionDatePicker(
|
||||||
{required BuildContext context, required String position}) async {
|
{required BuildContext context, required String position}) async {
|
||||||
String date = "start_date";
|
DateTime date;
|
||||||
if (position == "end") {
|
if ((startDatepicker.text.isEmpty) || (endDatepicker.text.isEmpty)) {
|
||||||
date = "end_date";
|
date = DateTime.now();
|
||||||
}
|
|
||||||
DateTime dateEvent;
|
|
||||||
if (events[date].toString().isEmpty) {
|
|
||||||
dateEvent = DateTime.now();
|
|
||||||
} else {
|
} else {
|
||||||
dateEvent = DateTime.parse(events[date]);
|
date = DateTime.parse(formatDate(startDatepicker.text));
|
||||||
|
if (position == "end") {
|
||||||
|
date = DateTime.parse(formatDate(endDatepicker.text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
firstDate: dateEvent,
|
firstDate: date,
|
||||||
initialDate: dateEvent,
|
initialDate: date,
|
||||||
lastDate: DateTime(2104));
|
lastDate: DateTime(2104));
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
@ -92,18 +95,19 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
onTapFunctionTimePicker(
|
onTapFunctionTimePicker(
|
||||||
{required BuildContext context, required String position}) async {
|
{required BuildContext context, required String position}) async {
|
||||||
String date = "start_date";
|
TimeOfDay time;
|
||||||
if (position == "end") {
|
|
||||||
date = "end_date";
|
if ((startTimepicker.text.isEmpty) || (endTimepicker.text.isEmpty)) {
|
||||||
}
|
time = TimeOfDay.now();
|
||||||
TimeOfDay timeEvent;
|
|
||||||
if (widget.events[date].toString().isEmpty) {
|
|
||||||
timeEvent = TimeOfDay.now();
|
|
||||||
} else {
|
} else {
|
||||||
timeEvent = TimeOfDay.fromDateTime(DateTime.parse(widget.events[date]));
|
time = TimeOfDay.fromDateTime(DateTime.parse(startTimepicker.text));
|
||||||
|
if (position == "end") {
|
||||||
|
time = TimeOfDay.fromDateTime(DateTime.parse(endTimepicker.text));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TimeOfDay? pickedDate =
|
TimeOfDay? pickedDate =
|
||||||
await showTimePicker(context: context, initialTime: timeEvent);
|
await showTimePicker(context: context, initialTime: time);
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
startTimepicker.text = pickedDate.format(context);
|
startTimepicker.text = pickedDate.format(context);
|
||||||
@ -143,10 +147,6 @@ class _EditEventState extends State<EditEvent>
|
|||||||
String formerMap = "";
|
String formerMap = "";
|
||||||
String formerImage = "";
|
String formerImage = "";
|
||||||
String formerDesc = "";
|
String formerDesc = "";
|
||||||
var date = null;
|
|
||||||
var time = null;
|
|
||||||
var dateE = null;
|
|
||||||
var timeE = null;
|
|
||||||
List<String> formerTags = [];
|
List<String> formerTags = [];
|
||||||
List<String> formerOrga = [];
|
List<String> formerOrga = [];
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
formerTags = List<String>.from(events['tags'] as List);
|
formerTags = List<String>.from(events['tags'] as List);
|
||||||
formerOrga = List<String>.from(events['organizers'] as List);
|
formerOrga = List<String>.from(events['organizers'] as List);
|
||||||
final startDate = DateTime.parse(events["start_date"]);
|
final startDate = DateTime.parse(events["start_date"]);
|
||||||
date = DateFormat.yMd().format(startDate);
|
dateS = DateFormat.yMd().format(startDate);
|
||||||
time = DateFormat.Hm().format(startDate);
|
timeS = DateFormat.Hm().format(startDate);
|
||||||
|
|
||||||
final endDate = DateTime.parse(events["end_date"]);
|
final endDate = DateTime.parse(events["end_date"]);
|
||||||
|
|
||||||
@ -227,9 +227,9 @@ class _EditEventState extends State<EditEvent>
|
|||||||
// _counter without calling setState(), then the build method would not be
|
// _counter without calling setState(), then the build method would not be
|
||||||
// called again, and so nothing would appear to happen.
|
// called again, and so nothing would appear to happen.
|
||||||
inputName.text = formerName;
|
inputName.text = formerName;
|
||||||
startDatepicker.text = date.toString();
|
startDatepicker.text = DateFormat("dd-MM-yyyy").format(dateS);
|
||||||
startTimepicker.text = time.toString();
|
startTimepicker.text = timeS.toString();
|
||||||
endDatepicker.text = dateE.toString();
|
endDatepicker.text = DateFormat("dd-MM-yyyy").format(dateE);
|
||||||
endTimepicker.text = timeE.toString();
|
endTimepicker.text = timeE.toString();
|
||||||
initialOrga = formerOrga;
|
initialOrga = formerOrga;
|
||||||
inputGeo.text = formerMap;
|
inputGeo.text = formerMap;
|
||||||
|
@ -18,6 +18,7 @@ import '../classes/events.dart';
|
|||||||
import 'ListItemMenu.dart';
|
import 'ListItemMenu.dart';
|
||||||
import 'MapboxPages.dart';
|
import 'MapboxPages.dart';
|
||||||
import 'ListItemByOrganizers.dart';
|
import 'ListItemByOrganizers.dart';
|
||||||
|
import 'EditEvent.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
|
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
|
||||||
@ -76,6 +77,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
List<String> tags = [];
|
List<String> tags = [];
|
||||||
List<String> organizers = [];
|
List<String> organizers = [];
|
||||||
|
|
||||||
|
String id = "";
|
||||||
|
|
||||||
Events? events;
|
Events? events;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -104,6 +107,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
if (responseGet.statusCode == 200) {
|
if (responseGet.statusCode == 200) {
|
||||||
stderr.writeln('Username : ${responseGet.body}');
|
stderr.writeln('Username : ${responseGet.body}');
|
||||||
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
||||||
|
id = events["id"];
|
||||||
formerName = events["name"];
|
formerName = events["name"];
|
||||||
formerMap = "${events["place"]}";
|
formerMap = "${events["place"]}";
|
||||||
formerDesc = events["description"];
|
formerDesc = events["description"];
|
||||||
@ -397,7 +401,12 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => EditEvent(id: id)),
|
||||||
|
);
|
||||||
|
},
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
tooltip: 'Recherche',
|
tooltip: 'Recherche',
|
||||||
child: const Icon(Icons.edit, color: Colors.white),
|
child: const Icon(Icons.edit, color: Colors.white),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user