mobile-flutter/covas_mobile/lib/classes/descriptionImage.dart

48 lines
1.5 KiB
Dart
Raw Normal View History

2024-07-17 23:39:51 +02:00
import 'package:flutter/material.dart';
2024-07-25 22:23:45 +02:00
import 'events.dart';
2024-07-26 15:06:15 +02:00
import '../variable/globals.dart' as globals;
import 'package:http/http.dart' as http;
import 'dart:io';
2024-07-17 23:39:51 +02:00
2024-07-25 22:44:06 +02:00
import 'package:shared_preferences/shared_preferences.dart';
2024-07-17 23:39:51 +02:00
mixin ShowDescImageAdd<T extends StatefulWidget> on State<T> {
2024-07-25 22:44:06 +02:00
Future<void> addEvents(var events) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? "";
2024-07-26 15:06:15 +02:00
if (accessToken.isNotEmpty) {
var urlGet = Uri.parse("${globals.api}/events");
var responseGet = await http.get(urlGet,
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
}
2024-07-25 22:44:06 +02:00
}
2024-07-25 22:23:45 +02:00
void showDescImageAddDialog(BuildContext context, var events) {
2024-07-17 23:39:51 +02:00
// Create AlertDialog
2024-07-25 22:23:45 +02:00
String name = events['name'];
2024-07-17 23:39:51 +02:00
AlertDialog dialog = AlertDialog(
2024-07-25 22:23:45 +02:00
title: Text("Ajouter un evenement"),
content: Text("${name} n'a pas été trouvé. Voulez-vous l'ajouter ? "),
2024-07-17 23:39:51 +02:00
actions: [
2024-07-25 22:34:35 +02:00
TextButton(
child: Text("Annuler"),
2024-07-25 22:23:45 +02:00
onPressed: () {
Navigator.of(context).pop("Yes, Of course!"); // Return value
}),
2024-07-25 22:34:35 +02:00
TextButton(
child: Text("Oui"),
2024-07-17 23:39:51 +02:00
onPressed: () {
2024-07-25 22:44:06 +02:00
addEvents(events); // Return value
2024-07-17 23:39:51 +02:00
}),
],
);
// Call showDialog function to show dialog.
Future futureValue = showDialog(
context: context,
builder: (BuildContext context) {
return dialog;
});
}
}