add classes
This commit is contained in:
parent
6f185d99ce
commit
8a3ce376ce
67
covas_mobile/lib/classes/getEventImage.dart
Normal file
67
covas_mobile/lib/classes/getEventImage.dart
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'events.dart';
|
||||||
|
import '../variable/globals.dart' as globals;
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
mixin ShowDescImageGet<T extends StatefulWidget> on State<T> {
|
||||||
|
Future<void> getEvents(var events) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
List<String> send = ["toto"];
|
||||||
|
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
var urlPut = Uri.parse("${globals.api}/events");
|
||||||
|
print("start date : ${events["start_date"]}");
|
||||||
|
var responsePut = await http.put(urlPut,
|
||||||
|
headers: {
|
||||||
|
HttpHeaders.cookieHeader: 'access_token=${accessToken}',
|
||||||
|
HttpHeaders.acceptHeader: 'application/json, text/plain, */*',
|
||||||
|
HttpHeaders.contentTypeHeader: 'application/json'
|
||||||
|
},
|
||||||
|
body: jsonEncode({
|
||||||
|
'name': events["name"],
|
||||||
|
'place': events["place"],
|
||||||
|
'start_date': events['date'],
|
||||||
|
'end_date': events['date'],
|
||||||
|
'organizers': send,
|
||||||
|
'latitude': '0.0',
|
||||||
|
'longitude': '0.0',
|
||||||
|
}));
|
||||||
|
|
||||||
|
print("http put code status : ${responsePut.statusCode}");
|
||||||
|
print("http put body : ${responsePut.body}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showDescImageUpdateDialog(BuildContext context, var events) {
|
||||||
|
// Create AlertDialog
|
||||||
|
String name = events['name'];
|
||||||
|
AlertDialog dialog = AlertDialog(
|
||||||
|
title: Text("Voir la description de l'evenement"),
|
||||||
|
content: Text("${name} a été trouvé. Voulez-vous voir sa description ? "),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: Text("Annuler"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop("Yes, Of course!"); // Return value
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: Text("Oui"),
|
||||||
|
onPressed: () {
|
||||||
|
getEvents(events); // Return value
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Call showDialog function to show dialog.
|
||||||
|
Future futureValue = showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
67
covas_mobile/lib/classes/updateEventImage.dart
Normal file
67
covas_mobile/lib/classes/updateEventImage.dart
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'events.dart';
|
||||||
|
import '../variable/globals.dart' as globals;
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
mixin ShowDescImageUpdate<T extends StatefulWidget> on State<T> {
|
||||||
|
Future<void> updateEvents(var events) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
List<String> send = ["toto"];
|
||||||
|
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
var urlPut = Uri.parse("${globals.api}/events");
|
||||||
|
print("start date : ${events["start_date"]}");
|
||||||
|
var responsePut = await http.put(urlPut,
|
||||||
|
headers: {
|
||||||
|
HttpHeaders.cookieHeader: 'access_token=${accessToken}',
|
||||||
|
HttpHeaders.acceptHeader: 'application/json, text/plain, */*',
|
||||||
|
HttpHeaders.contentTypeHeader: 'application/json'
|
||||||
|
},
|
||||||
|
body: jsonEncode({
|
||||||
|
'name': events["name"],
|
||||||
|
'place': events["place"],
|
||||||
|
'start_date': events['date'],
|
||||||
|
'end_date': events['date'],
|
||||||
|
'organizers': send,
|
||||||
|
'latitude': '0.0',
|
||||||
|
'longitude': '0.0',
|
||||||
|
}));
|
||||||
|
|
||||||
|
print("http put code status : ${responsePut.statusCode}");
|
||||||
|
print("http put body : ${responsePut.body}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showDescImageUpdateDialog(BuildContext context, var events) {
|
||||||
|
// Create AlertDialog
|
||||||
|
String name = events['name'];
|
||||||
|
AlertDialog dialog = AlertDialog(
|
||||||
|
title: Text("Modifier un evenement"),
|
||||||
|
content: Text("${name} a été trouvé. Voulez-vous le modifier ou voir ? "),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: Text("Annuler"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop("Yes, Of course!"); // Return value
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: Text("Oui"),
|
||||||
|
onPressed: () {
|
||||||
|
updateEvents(events); // Return value
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Call showDialog function to show dialog.
|
||||||
|
Future futureValue = showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import '../classes/descriptionImage.dart';
|
import '../classes/addEventImage.dart';
|
||||||
import '../classes/alert.dart';
|
import '../classes/alert.dart';
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_gemini/flutter_gemini.dart';
|
import 'package:flutter_gemini/flutter_gemini.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user