mobile-flutter/covas_mobile/lib/pages/UpdateEventImage.dart

744 lines
30 KiB
Dart
Raw Permalink Normal View History

2024-07-28 21:54:37 +02:00
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
2024-12-22 22:11:20 +01:00
import 'package:uuid/uuid.dart';
2024-08-14 22:55:41 +02:00
import 'package:intl/intl.dart';
2024-09-17 23:50:23 +02:00
import 'package:flutter_dotenv/flutter_dotenv.dart';
2024-10-03 23:54:54 +02:00
import 'package:textfield_tags/textfield_tags.dart';
2025-01-10 21:06:41 +01:00
import '../classes/MyDrawer.dart';
2024-07-28 21:54:37 +02:00
import 'dart:convert';
import 'dart:io';
2024-09-12 23:54:59 +02:00
import 'dart:typed_data';
2024-07-28 21:54:37 +02:00
2024-12-04 23:28:09 +01:00
import 'ItemMenu.dart';
2024-07-28 21:54:37 +02:00
import '../classes/alert.dart';
2024-07-30 23:46:15 +02:00
import '../classes/eventAdded.dart';
2024-07-28 21:54:37 +02:00
import '../variable/globals.dart' as globals;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
2024-07-30 23:19:37 +02:00
Map<String, dynamic> events = {};
2024-09-01 22:27:18 +02:00
String imagePath = "";
2024-07-28 21:54:37 +02:00
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
2024-09-01 22:27:18 +02:00
home: UpdateeventImage(events: events, imagePath: imagePath),
2024-07-28 21:54:37 +02:00
);
}
}
class UpdateeventImage extends StatefulWidget {
2024-09-01 22:27:18 +02:00
const UpdateeventImage(
{Key? key, required this.events, required this.imagePath})
: super(key: key);
2024-07-30 23:19:37 +02:00
final Map<String, dynamic> events;
2024-09-01 22:27:18 +02:00
final String imagePath;
2024-07-30 23:19:37 +02:00
2024-07-28 21:54:37 +02:00
@override
_UpdateeventImageState createState() => _UpdateeventImageState();
}
class _UpdateeventImageState extends State<UpdateeventImage>
2024-12-30 22:34:17 +01:00
with ShowAlertDialog, ShowEventDialog {
2024-07-30 23:19:37 +02:00
TextEditingController inputName = TextEditingController();
2024-08-30 23:57:10 +02:00
2024-07-30 23:19:37 +02:00
TextEditingController inputDate = TextEditingController();
2024-09-01 22:57:16 +02:00
TextEditingController inputDesc = TextEditingController();
2024-11-07 23:10:03 +01:00
TextEditingController inputGeo = TextEditingController();
2024-08-14 22:55:41 +02:00
TextEditingController startDatepicker = TextEditingController();
2024-08-14 23:15:30 +02:00
TextEditingController startTimepicker = TextEditingController();
2024-08-14 23:20:31 +02:00
TextEditingController endDatepicker = TextEditingController();
TextEditingController endTimepicker = TextEditingController();
2024-10-03 23:54:54 +02:00
final _stringTagController = StringTagController();
2024-11-07 23:10:03 +01:00
List<Map<String, dynamic>> suggestions = [];
String geographicalZone = "";
2024-10-14 17:49:39 +02:00
List<String> initialTags = [];
2024-08-14 22:55:41 +02:00
2024-10-15 23:57:22 +02:00
final _stringOrgaController = StringTagController();
List<String> initialOrga = [];
2024-08-14 23:34:42 +02:00
onTapFunctionDatePicker(
{required BuildContext context, required String position}) async {
2024-10-18 22:53:50 +02:00
String date = "start_date";
if (position == "end") {
date = "end_date";
}
2024-11-08 16:57:07 +01:00
DateTime dateEvent;
if (widget.events[date].toString().isEmpty) {
dateEvent = DateTime.now();
} else {
dateEvent = DateTime.parse(widget.events[date]);
}
2024-08-14 22:55:41 +02:00
DateTime? pickedDate = await showDatePicker(
context: context,
2024-11-08 16:57:07 +01:00
firstDate: dateEvent,
initialDate: dateEvent,
2024-08-14 23:52:06 +02:00
lastDate: DateTime(2104));
2024-08-14 22:55:41 +02:00
if (pickedDate == null) return;
2024-08-14 23:34:42 +02:00
if (position == "start") {
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
}
if (position == "end") {
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
}
2024-08-14 22:55:41 +02:00
}
2024-07-30 23:19:37 +02:00
2024-08-14 23:34:42 +02:00
onTapFunctionTimePicker(
{required BuildContext context, required String position}) async {
2024-10-18 22:53:50 +02:00
String date = "start_date";
if (position == "end") {
date = "end_date";
}
2024-11-08 16:57:07 +01:00
TimeOfDay timeEvent;
if (widget.events[date].toString().isEmpty) {
timeEvent = TimeOfDay.now();
} else {
timeEvent = TimeOfDay.fromDateTime(DateTime.parse(widget.events[date]));
}
TimeOfDay? pickedDate =
await showTimePicker(context: context, initialTime: timeEvent);
2024-08-14 23:15:30 +02:00
if (pickedDate == null) return;
2024-08-14 23:34:42 +02:00
if (position == "start") {
startTimepicker.text = pickedDate.format(context);
}
if (position == "end") {
endTimepicker.text = pickedDate.format(context);
}
2024-08-14 23:15:30 +02:00
}
2024-09-17 23:50:23 +02:00
convertNulltoEmptyString(var check) {
if (check == null) {
return "";
}
return check;
}
2024-10-14 17:49:39 +02:00
convertNulltoArray(List<String> check) {
if (check == null) {
return [];
}
return check;
}
2024-09-03 15:54:37 +02:00
String formatDate(String date) {
var splitedDate = date.split("-");
var day = splitedDate[0];
var month = splitedDate[1];
var year = splitedDate[2];
return "${year}-${month}-${day}";
}
2024-07-30 23:46:15 +02:00
Future<void> _updateEvent(BuildContext context) async {
2024-12-22 22:11:20 +01:00
// Gather inputs
2024-07-30 23:46:15 +02:00
var name = inputName.text;
2024-11-07 23:10:03 +01:00
var place = inputGeo.text;
2024-09-03 15:54:37 +02:00
var description = inputDesc.text;
2024-10-15 23:44:41 +02:00
List<String> tags = List<String>.from(_stringTagController.getTags as List);
2024-10-18 21:40:20 +02:00
List<String> organizers =
List<String>.from(_stringOrgaController.getTags as List);
2024-09-03 15:54:37 +02:00
var startDateFormat = formatDate(startDatepicker.text);
2024-12-04 23:01:06 +01:00
DateTime startDateCompare = DateTime.parse(startDateFormat);
DateTime dateNow = DateTime.now();
2024-09-03 15:54:37 +02:00
var endDateFormat = formatDate(endDatepicker.text);
var startDate =
"${startDateFormat}T${startTimepicker.text.replaceAll('-', ':')}";
var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}";
2024-12-22 22:11:20 +01:00
if (!startDateCompare.isAfter(dateNow)) {
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur evenement", "Evenement non futur");
2024-12-22 22:11:20 +01:00
return;
}
SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? "";
if (accessToken.isEmpty) {
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur token", "Token d'accès manquant");
2024-12-22 22:11:20 +01:00
return;
}
try {
await dotenv.load();
final ApiTokenGoogle = dotenv.env['PLACE_API_KEY'] ?? '';
2024-12-22 22:11:20 +01:00
// Searchbox API for geocoding the place (No session token)
final searchboxUrl = Uri.parse(
'https://maps.googleapis.com/maps/api/place/textsearch/json?query=${place}&key=${ApiTokenGoogle}');
2024-12-22 22:11:20 +01:00
// Perform the request
2024-12-22 22:11:20 +01:00
final searchboxResponse = await http.get(searchboxUrl);
if (searchboxResponse.statusCode != 200) {
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur map",
"Erreur lors de la géocodage avec Searchbox");
2024-12-22 22:11:20 +01:00
return;
}
final searchboxData = json.decode(searchboxResponse.body);
if (searchboxData['results'].isEmpty) {
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur", "Lieu introuvable");
2024-12-22 22:11:20 +01:00
return;
}
// Extract place details from the searchbox response
final firstFeature = searchboxData['results'][0];
place = firstFeature["formatted_address"];
final coordinates = firstFeature['geometry']['location'];
final longitude = coordinates["lng"];
final latitude = coordinates["lat"];
2024-12-22 22:11:20 +01:00
// Check if a similar event exists
final eventsUrl = Uri.parse(
"${globals.api}/events/search?item=$name&date_event=$startDate");
final eventsResponse = await http.get(eventsUrl, headers: {
HttpHeaders.cookieHeader: 'access_token=$accessToken',
});
if (eventsResponse.statusCode == 200) {
final events = json.decode(utf8.decode(eventsResponse.bodyBytes));
if (events.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ItemMenu(title: events[0]["id"]),
),
);
return;
2024-07-28 21:54:37 +02:00
}
2024-12-22 22:11:20 +01:00
}
// Upload image to imgbb
final imgbbUrl = Uri.parse(
'https://api.imgbb.com/1/upload?expiration=15552000&key=${dotenv.env["IMGBB_API_KEY"]}');
File image = File(widget.imagePath);
Uint8List imageBytes = await image.readAsBytes();
String base64Image = base64.encode(imageBytes);
final imgbbRequest = http.MultipartRequest('POST', imgbbUrl)
..fields['image'] = base64Image;
final imgbbResponse =
await http.Response.fromStream(await imgbbRequest.send());
if (imgbbResponse.statusCode != 200) {
2024-12-30 22:34:17 +01:00
showAlertDialog(
context, "Erreur serveur", "Erreur lors de l'upload d'image");
2024-12-22 22:11:20 +01:00
return;
}
final imgbbData = json.decode(imgbbResponse.body);
final imgUrl = imgbbData['data']['url'];
// Create or update the event
final eventUrl = Uri.parse("${globals.api}/events");
final eventResponse = await http.put(
eventUrl,
headers: {
HttpHeaders.cookieHeader: 'access_token=$accessToken',
HttpHeaders.acceptHeader: 'application/json, text/plain, */*',
HttpHeaders.contentTypeHeader: 'application/json',
},
body: jsonEncode({
'name': name,
'place': place,
'start_date': startDate,
'end_date': endDate,
'organizers': organizers,
'latitude': latitude,
'longitude': longitude,
'description': description,
'imgUrl': imgUrl,
'tags': tags,
}),
);
if (eventResponse.statusCode == 200 || eventResponse.statusCode == 201) {
showEventDialog(context, "Événement $name ajouté");
2024-12-04 23:01:06 +01:00
} else {
2024-12-22 22:11:20 +01:00
handleHttpError(eventResponse.statusCode, context);
2024-07-28 21:54:37 +02:00
}
2024-12-22 22:11:20 +01:00
} catch (e) {
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur", "Erreur: ${e.toString()}");
2024-07-28 21:54:37 +02:00
}
}
2024-12-22 22:11:20 +01:00
// Utility function to handle HTTP errors
void handleHttpError(int statusCode, BuildContext context) {
final errorMessages = {
400: "Requête mal construite",
403: "Utilisateur désactivé",
404: "Utilisateur inconnu",
406: "Mot de passe incorrect",
410: "Token invalide",
500: "Problème interne du serveur",
};
2024-12-30 22:34:17 +01:00
showAlertDialog(context, "Erreur serveur",
errorMessages[statusCode] ?? "Erreur inconnue");
2024-12-22 22:11:20 +01:00
}
2024-07-28 21:54:37 +02:00
void start() async {
2024-11-07 23:10:03 +01:00
print("events : ${widget.events}");
2024-09-17 23:50:23 +02:00
inputName.text = convertNulltoEmptyString(widget.events["name"]);
2024-11-07 23:10:03 +01:00
inputGeo.text = convertNulltoEmptyString(widget.events["place"]);
2024-09-17 23:50:23 +02:00
inputDesc.text = convertNulltoEmptyString(widget.events["description"]);
2024-11-08 16:57:07 +01:00
if (widget.events["start_date"].toString().isNotEmpty) {
DateTime pickedStartDate =
DateTime.parse(convertNulltoEmptyString(widget.events["start_date"]));
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
startTimepicker.text = DateFormat("HH-mm").format(pickedStartDate);
}
if (widget.events["end_date"].toString().isNotEmpty) {
DateTime pickedEndDate =
DateTime.parse(convertNulltoEmptyString(widget.events["end_date"]));
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
endTimepicker.text = DateFormat("HH-mm").format(pickedEndDate);
}
2024-10-14 17:49:39 +02:00
initialTags = List<String>.from(widget.events['tags'] as List);
2024-10-15 23:57:22 +02:00
initialOrga = List<String>.from(widget.events['organizers'] as List);
2024-07-28 21:54:37 +02:00
}
@override
void initState() {
start();
super.initState();
}
2024-10-18 22:53:50 +02:00
final _formKey = GlobalKey<FormState>();
String? _validateField(String? value) {
return value!.isEmpty ? 'Champ requis' : null;
}
2024-11-07 23:10:03 +01:00
Future<void> searchSuggestions(String input) async {
await dotenv.load(fileName: ".env"); // Load .env file
final ApiTokenGoogle = dotenv.env['PLACE_API_KEY'] ?? '';
2024-12-22 22:11:20 +01:00
// Define the Searchbox API URL
final searchboxUrl = Uri.parse(
'https://maps.googleapis.com/maps/api/place/textsearch/json?query=${input}&key=${ApiTokenGoogle}');
2024-12-22 22:11:20 +01:00
// Perform the request
final response = await http.get(searchboxUrl);
print("response code suggestion: ${response.statusCode}");
2024-11-07 23:10:03 +01:00
if (response.statusCode == 200) {
final data = json.decode(response.body);
2024-12-22 22:11:20 +01:00
print("data suggestion: ${data}");
2024-11-07 23:10:03 +01:00
setState(() {
2024-12-22 22:11:20 +01:00
// Map the results to extract name and full_address
suggestions = (data['results'] as List)
2024-11-07 23:10:03 +01:00
.map((feature) => {
2024-12-22 22:11:20 +01:00
'name': feature['name'],
'formatted_address': feature[
'formatted_address'] // Adjusted to match the data structure
2024-11-07 23:10:03 +01:00
})
.toList();
});
} else {
throw Exception('Failed to load suggestions');
}
}
Padding _buildGeographicalZoneSearchField() {
return Padding(
padding:
const EdgeInsets.only(left: 15.0, right: 15.0, top: 15, bottom: 0),
child: Column(
children: [
TextField(
controller: inputGeo,
decoration: InputDecoration(
labelText: 'Lieu',
border: OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
setState(() {
inputGeo.clear(); // Clear the text field
geographicalZone = ''; // Reset the geographical zone state
suggestions.clear(); // Optionally clear suggestions
});
},
),
),
onChanged: (value) {
setState(() {
geographicalZone = value;
searchSuggestions(value);
});
},
),
if (suggestions.isNotEmpty)
Container(
height: 200,
decoration: BoxDecoration(
border: Border.all(color: Colors.blue),
borderRadius: BorderRadius.circular(8),
),
child: ListView.builder(
shrinkWrap: true,
itemCount: suggestions.length,
itemBuilder: (context, index) {
return ListTile(
2024-12-22 22:11:20 +01:00
title: Text(suggestions[index]['name']),
subtitle: Text(suggestions[index]['formatted_address']),
2024-11-07 23:10:03 +01:00
onTap: () async {
2024-11-16 20:06:58 +01:00
print("suggestion tapped : ${suggestions[index]}");
2024-11-07 23:10:03 +01:00
setState(() {
geographicalZone =
suggestions[index]['formatted_address'];
2024-11-07 23:10:03 +01:00
inputGeo.text = geographicalZone;
suggestions.clear();
});
},
);
},
),
),
],
),
);
}
2024-07-28 21:54:37 +02:00
@override
Widget build(BuildContext context) {
return Scaffold(
2024-10-18 22:53:50 +02:00
backgroundColor: Colors.white,
appBar: AppBar(
title: Text("Add or Update a event"),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
2025-01-10 21:06:41 +01:00
drawer: MyDrawer(),
2024-10-18 22:53:50 +02:00
body: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 60.0),
child: Center(
child: Container(
width: 200,
height: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100.0)),
child: Image.file(File(widget.imagePath))),
),
),
Padding(
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
padding: EdgeInsets.symmetric(horizontal: 15),
child: TextFormField(
controller: inputName,
validator: (value) => _validateField(value),
decoration: InputDecoration(
2024-10-09 23:28:24 +02:00
border: OutlineInputBorder(),
2024-10-18 22:53:50 +02:00
labelText: 'Nom',
hintText: 'Modifier le nom de l\'évènement'),
),
),
2024-11-07 23:10:03 +01:00
_buildGeographicalZoneSearchField(),
2024-10-18 22:53:50 +02:00
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: TextFormField(
controller: startDatepicker,
readOnly: true,
validator: (value) => _validateField(value),
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Date de debut',
hintText: 'Cliquez ici pour selectionner une date'),
onTap: () => onTapFunctionDatePicker(
context: context, position: "start")),
),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: TextFormField(
controller: startTimepicker,
readOnly: true,
validator: (value) => _validateField(value),
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Heure de debut',
hintText: 'Cliquez ici pour selectionner une heure'),
onTap: () => onTapFunctionTimePicker(
context: context, position: "start")),
),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: TextFormField(
controller: endDatepicker,
readOnly: true,
validator: (value) => _validateField(value),
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Date de fin',
hintText: 'Cliquez ici pour selectionner une date'),
onTap: () => onTapFunctionDatePicker(
context: context, position: "end")),
),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: TextFormField(
controller: endTimepicker,
readOnly: true,
validator: (value) => _validateField(value),
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Heure de fin',
hintText: 'Cliquez ici pour selectionner une heure'),
onTap: () => onTapFunctionTimePicker(
context: context, position: "end")),
),
TextFieldTags<String>(
textfieldTagsController: _stringTagController,
initialTags: initialTags,
textSeparators: const [' ', ','],
validator: (String tag) {
if (_stringTagController.getTags!.contains(tag)) {
return 'Tu as deja rentre ce tag';
}
return null;
},
inputFieldBuilder: (context, inputFieldValues) {
return Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
child: TextField(
controller: inputFieldValues.textEditingController,
focusNode: inputFieldValues.focusNode,
onChanged: inputFieldValues.onTagChanged,
onSubmitted: inputFieldValues.onTagSubmitted,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Tags',
hintText: inputFieldValues.tags.isNotEmpty
? ''
: "Enter tag...",
errorText: inputFieldValues.error,
prefixIcon: inputFieldValues.tags.isNotEmpty
? SingleChildScrollView(
controller:
inputFieldValues.tagScrollController,
scrollDirection: Axis.vertical,
child: Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 8,
left: 8,
),
child: Wrap(
runSpacing: 4.0,
spacing: 4.0,
children: inputFieldValues.tags
.map((String tag) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20.0),
2024-10-15 23:57:22 +02:00
),
2024-10-18 22:53:50 +02:00
color: Colors.blue,
),
margin:
const EdgeInsets.symmetric(
horizontal: 5.0),
padding:
const EdgeInsets.symmetric(
horizontal: 10.0,
vertical: 5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
child: Text(
'$tag',
style: const TextStyle(
color: Colors.white),
),
onTap: () {
//print("$tag selected");
},
),
const SizedBox(width: 4.0),
InkWell(
child: const Icon(
Icons.cancel,
size: 14.0,
color: Color.fromARGB(
255, 233, 233, 233),
),
onTap: () {
inputFieldValues
.onTagRemoved(tag);
},
)
],
2024-10-15 23:57:22 +02:00
),
2024-10-18 22:53:50 +02:00
);
}).toList()),
),
)
: null,
),
),
);
}),
TextFieldTags<String>(
textfieldTagsController: _stringOrgaController,
initialTags: initialOrga,
textSeparators: const [','],
validator: (String tag) {
if (_stringOrgaController.getTags!.contains(tag)) {
return 'Cet organisateur est déjà rentré';
}
return null;
},
inputFieldBuilder: (context, inputFieldValues) {
return Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
child: TextField(
controller: inputFieldValues.textEditingController,
focusNode: inputFieldValues.focusNode,
onChanged: inputFieldValues.onTagChanged,
onSubmitted: inputFieldValues.onTagSubmitted,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Organisateurs',
hintText: inputFieldValues.tags.isNotEmpty
? ''
: "Enter un organisateur...",
errorText: inputFieldValues.error,
prefixIcon: inputFieldValues.tags.isNotEmpty
? SingleChildScrollView(
controller:
inputFieldValues.tagScrollController,
scrollDirection: Axis.vertical,
child: Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 8,
left: 8,
),
child: Wrap(
runSpacing: 4.0,
spacing: 4.0,
children: inputFieldValues.tags
.map((String tag) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20.0),
2024-10-09 23:28:24 +02:00
),
2024-10-18 22:53:50 +02:00
color: Colors.blue,
),
margin:
const EdgeInsets.symmetric(
horizontal: 5.0),
padding:
const EdgeInsets.symmetric(
horizontal: 10.0,
vertical: 5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
child: Text(
'$tag',
style: const TextStyle(
color: Colors.white),
),
onTap: () {
//print("$tag selected");
},
),
const SizedBox(width: 4.0),
InkWell(
child: const Icon(
Icons.cancel,
size: 14.0,
color: Color.fromARGB(
255, 233, 233, 233),
),
onTap: () {
inputFieldValues
.onTagRemoved(tag);
},
)
],
),
);
}).toList()),
),
)
: null,
),
),
);
}),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15),
child: TextField(
controller: inputDesc,
keyboardType: TextInputType.multiline,
maxLines: 10,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Description',
hintText: 'Décrire l\'evènement'),
),
),
SizedBox(
height: 30,
),
Container(
height: 50,
width: 250,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(20)),
child: TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_updateEvent(context);
}
},
child: Text(
'Ajouter',
style: TextStyle(color: Colors.white, fontSize: 25),
2024-10-09 23:28:24 +02:00
),
2024-10-18 22:53:50 +02:00
),
)
],
2024-07-28 21:54:37 +02:00
),
2024-10-18 22:53:50 +02:00
),
));
2024-07-28 21:54:37 +02:00
}
}