From 5419da7a982bd8eac3b3ad766536cd901123a2ad Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 3 Jan 2025 15:06:08 +0100 Subject: [PATCH] edit profile wip --- covas_mobile/lib/pages/EditProfile.dart | 339 +----------------------- 1 file changed, 2 insertions(+), 337 deletions(-) diff --git a/covas_mobile/lib/pages/EditProfile.dart b/covas_mobile/lib/pages/EditProfile.dart index 593d1fe..e884d75 100644 --- a/covas_mobile/lib/pages/EditProfile.dart +++ b/covas_mobile/lib/pages/EditProfile.dart @@ -12,10 +12,6 @@ import 'dart:io'; import 'dart:typed_data'; import '../classes/events.dart'; -import 'ItemMenu.dart'; -import 'CameraEdit.dart'; -import 'package:camera/camera.dart'; - import '../classes/alert.dart'; import '../classes/eventAdded.dart'; @@ -54,16 +50,6 @@ class _EditProfileState extends State TextEditingController inputGeo = TextEditingController(); TextEditingController startDatepicker = TextEditingController(); - TextEditingController startTimepicker = TextEditingController(); - TextEditingController endDatepicker = TextEditingController(); - TextEditingController endTimepicker = TextEditingController(); - final _stringTagController = StringTagController(); - - DateTime startDate = DateTime.now(); - DateTime endDate = DateTime.now(); - List> suggestions = []; - String geographicalZone = ""; - String imgUrl = ""; List initialTags = []; @@ -95,37 +81,6 @@ class _EditProfileState extends State } } - onTapFunctionTimePicker( - {required BuildContext context, required String position}) async { - TimeOfDay time; - - if ((startTimepicker.text.isEmpty) || (endTimepicker.text.isEmpty)) { - time = TimeOfDay.now(); - } else { - DateTime date = new DateTime.now(); - date = date.copyWith( - hour: int.parse(startTimepicker.text.split(":")[0]), - minute: int.parse(startTimepicker.text.split(":")[1])); - time = TimeOfDay.fromDateTime(date); - if (position == "end") { - date = date.copyWith( - hour: int.parse(endTimepicker.text.split(":")[0]), - minute: int.parse(endTimepicker.text.split(":")[1])); - time = TimeOfDay.fromDateTime(date); - } - } - - TimeOfDay? pickedDate = - await showTimePicker(context: context, initialTime: time); - if (pickedDate == null) return; - if (position == "start") { - startTimepicker.text = pickedDate.format(context); - } - if (position == "end") { - endTimepicker.text = pickedDate.format(context); - } - } - convertNulltoEmptyString(var check) { if (check == null) { return ""; @@ -150,13 +105,10 @@ class _EditProfileState extends State return "${year}-${month}-${day}"; } - Future _updateEvent(BuildContext context) async { + Future _updateProfile(BuildContext context) async { var name = inputName.text; var place = inputGeo.text; var description = inputDesc.text; - List tags = List.from(_stringTagController.getTags as List); - List organizers = - List.from(_stringOrgaController.getTags as List); var startDateFormat = formatDate(startDatepicker.text); //DateTime startDateCompare = DateTime.parse(startDateFormat); @@ -344,57 +296,6 @@ class _EditProfileState extends State child: SingleChildScrollView( child: Column( children: [ - if (widget.imgPath.isNotEmpty) - 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.imgPath))), - ), - ), - if (widget.imgPath.isEmpty) - Padding( - padding: const EdgeInsets.only(top: 60.0), - child: Image.network( - imgUrl, - width: MediaQuery.of(context).size.width * - 0.5, // 50% of screen width - height: MediaQuery.of(context).size.height * 0.5, - loadingBuilder: (BuildContext context, Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) { - return child; // The image has finished loading - } - return Center( - child: CircularProgressIndicator(), - ); - }, - errorBuilder: (BuildContext context, Object error, - StackTrace? stackTrace) { - return Center( - child: Icon(Icons.error, - size: MediaQuery.of(context).size.width * 0.1), - ); - }, - )), - Padding( - padding: EdgeInsets.symmetric(horizontal: 15), - child: ElevatedButton.icon( - onPressed: popCamera, - icon: Icon(Icons.edit, size: 16), // Edit icon - label: Text("Edit Image"), // Button text - style: ElevatedButton.styleFrom( - backgroundColor: Colors.blue, // Button color - foregroundColor: Colors.white, // Text color - padding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - ), - ), - ), Padding( //padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0), padding: EdgeInsets.symmetric(horizontal: 15), @@ -407,7 +308,6 @@ class _EditProfileState extends State hintText: 'Modifier le nom de l\'évènement'), ), ), - _buildGeographicalZoneSearchField(), Padding( padding: const EdgeInsets.only( left: 15.0, right: 15.0, top: 15, bottom: 0), @@ -423,241 +323,6 @@ class _EditProfileState extends State 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( - 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), - ), - 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, - ), - ), - ); - }), - TextFieldTags( - 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), - ), - 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), @@ -684,7 +349,7 @@ class _EditProfileState extends State child: TextButton( onPressed: () { if (_formKey.currentState!.validate()) { - _updateEvent(context); + _updateProfile(context); } }, child: Text(