Compare commits
14 Commits
feature/in
...
75b42dd091
Author | SHA1 | Date | |
---|---|---|---|
75b42dd091 | |||
dfe21960be | |||
4a936cc267 | |||
bd5bfa94ca | |||
f30aa8f630 | |||
924794e8a0 | |||
7528e55dca | |||
02ba067615 | |||
9eafb30374 | |||
24cb90959d | |||
1620d84137 | |||
6e8ba642a2 | |||
0113fcc382 | |||
e4571cabe7 |
@@ -5,11 +5,15 @@ class Events {
|
|||||||
String? startDate;
|
String? startDate;
|
||||||
String? endDate;
|
String? endDate;
|
||||||
String? description;
|
String? description;
|
||||||
|
String? link;
|
||||||
|
String? ticket;
|
||||||
double? latitude;
|
double? latitude;
|
||||||
double? longitude;
|
double? longitude;
|
||||||
List<String>? tags;
|
List<String>? tags;
|
||||||
List<String>? organizers;
|
List<String>? organizers;
|
||||||
String? imgUrl;
|
String? imgUrl;
|
||||||
|
int? interestedCount;
|
||||||
|
bool? interested;
|
||||||
Events(
|
Events(
|
||||||
{this.place,
|
{this.place,
|
||||||
this.id,
|
this.id,
|
||||||
@@ -21,7 +25,11 @@ class Events {
|
|||||||
this.latitude,
|
this.latitude,
|
||||||
this.longitude,
|
this.longitude,
|
||||||
this.organizers,
|
this.organizers,
|
||||||
this.imgUrl});
|
this.link,
|
||||||
|
this.ticket,
|
||||||
|
this.imgUrl,
|
||||||
|
this.interestedCount,
|
||||||
|
this.interested});
|
||||||
|
|
||||||
Events.fromJson(Map<String, dynamic> json) {
|
Events.fromJson(Map<String, dynamic> json) {
|
||||||
id = json['id'] as String?;
|
id = json['id'] as String?;
|
||||||
@@ -38,5 +46,9 @@ class Events {
|
|||||||
organizers = (json['organizers'] as List<dynamic>?)
|
organizers = (json['organizers'] as List<dynamic>?)
|
||||||
?.cast<String>(); // Convert List<dynamic> to List<String>
|
?.cast<String>(); // Convert List<dynamic> to List<String>
|
||||||
imgUrl = json['imgUrl'] as String?;
|
imgUrl = json['imgUrl'] as String?;
|
||||||
|
link = json['link'] as String?;
|
||||||
|
ticket = json['ticket'] as String?;
|
||||||
|
interested = json['interested'] as bool?;
|
||||||
|
interestedCount = json['interested_count'] as int?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -130,5 +130,14 @@
|
|||||||
"unknown_error": "Unbekannter Fehler",
|
"unknown_error": "Unbekannter Fehler",
|
||||||
"app_error": "Anwendungsfehler",
|
"app_error": "Anwendungsfehler",
|
||||||
"at": "um",
|
"at": "um",
|
||||||
"to_date": "bis"
|
"to_date": "bis",
|
||||||
|
"item_link": "Link : ",
|
||||||
|
"item_ticket": "Abendkarte : ",
|
||||||
|
"link": "Link",
|
||||||
|
"edit_link": "Linkereignis bearbeiten",
|
||||||
|
"ticket": "Abendkarte",
|
||||||
|
"edit_ticket": "Ticketlink bearbeiten",
|
||||||
|
"toogle_interest": "Fehler beim Umschalten des Interesses",
|
||||||
|
"error_update": "Fehler beim Update",
|
||||||
|
"count_interested": "Anzahl der Interessenten"
|
||||||
}
|
}
|
||||||
|
@@ -132,5 +132,14 @@
|
|||||||
"unknown_error": "Unknown error",
|
"unknown_error": "Unknown error",
|
||||||
"app_error": "Application error",
|
"app_error": "Application error",
|
||||||
"at": "at",
|
"at": "at",
|
||||||
"to_date": "to"
|
"to_date": "to",
|
||||||
|
"item_link": "Link : ",
|
||||||
|
"item_ticket": "Ticket : ",
|
||||||
|
"link": "Link",
|
||||||
|
"edit_link": "Edit link name",
|
||||||
|
"ticket": "Ticket",
|
||||||
|
"edit_ticket": "Edit ticket link",
|
||||||
|
"toogle_interest": "Error toggle interest",
|
||||||
|
"error_update": "Error when updating",
|
||||||
|
"count_interested": "Interested people number"
|
||||||
}
|
}
|
@@ -132,6 +132,15 @@
|
|||||||
"unknown_error": "Erreur inconnue",
|
"unknown_error": "Erreur inconnue",
|
||||||
"app_error": "Erreur d'application",
|
"app_error": "Erreur d'application",
|
||||||
"at": "à",
|
"at": "à",
|
||||||
"to_date": "jusqu'à"
|
"to_date": "jusqu'à",
|
||||||
|
"item_link": "Lien : ",
|
||||||
|
"item_ticket": "Billet : ",
|
||||||
|
"link": "Lien",
|
||||||
|
"edit_link": "Editer le lien",
|
||||||
|
"ticket": "Billet",
|
||||||
|
"edit_ticket": "Editer le lien du billet",
|
||||||
|
"toogle_interest": "Erreur de bouton de changement",
|
||||||
|
"error_update": "Erreur lors de la mise à jour",
|
||||||
|
"count_interested": "Nombre de personne interessé"
|
||||||
|
|
||||||
}
|
}
|
@@ -66,6 +66,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
|
|
||||||
TextEditingController inputName = TextEditingController();
|
TextEditingController inputName = TextEditingController();
|
||||||
|
|
||||||
|
TextEditingController inputTicket = TextEditingController();
|
||||||
|
TextEditingController inputLink = TextEditingController();
|
||||||
TextEditingController inputDate = TextEditingController();
|
TextEditingController inputDate = TextEditingController();
|
||||||
TextEditingController inputDesc = TextEditingController();
|
TextEditingController inputDesc = TextEditingController();
|
||||||
|
|
||||||
@@ -311,6 +313,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
'longitude': location['lng'],
|
'longitude': location['lng'],
|
||||||
'description': inputDesc.text,
|
'description': inputDesc.text,
|
||||||
"imgUrl": imgUrl,
|
"imgUrl": imgUrl,
|
||||||
|
'link': inputLink.text,
|
||||||
|
'ticket': inputTicket.text,
|
||||||
"tags": List<String>.from(_stringTagController.getTags as List)
|
"tags": List<String>.from(_stringTagController.getTags as List)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -354,6 +358,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
inputName.text = widget.events!.name ?? "";
|
inputName.text = widget.events!.name ?? "";
|
||||||
|
inputTicket.text = widget.events!.ticket ?? "";
|
||||||
|
inputLink.text = widget.events!.link ?? "";
|
||||||
startDatepicker.text = DateFormat("dd/MM/yyyy")
|
startDatepicker.text = DateFormat("dd/MM/yyyy")
|
||||||
.format(DateTime.parse(
|
.format(DateTime.parse(
|
||||||
widget.events!.startDate ?? DateTime.now().toString()))
|
widget.events!.startDate ?? DateTime.now().toString()))
|
||||||
@@ -641,6 +647,35 @@ class _EditEventState extends State<EditEvent>
|
|||||||
onTap: () => onTapFunctionTimePicker(
|
onTap: () => onTapFunctionTimePicker(
|
||||||
context: context, position: "end")),
|
context: context, position: "end")),
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: inputLink,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
labelText: AppLocalizations.of(context)?.link ?? "Link",
|
||||||
|
hintText: AppLocalizations.of(context)?.edit_link ??
|
||||||
|
"Edit link event"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 15.0, right: 15.0, top: 15, bottom: 0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: inputTicket,
|
||||||
|
validator: (value) => _validateField(value),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
labelText:
|
||||||
|
AppLocalizations.of(context)?.ticket ?? "Ticket",
|
||||||
|
hintText: AppLocalizations.of(context)?.edit_ticket ??
|
||||||
|
"Edit ticket link"),
|
||||||
|
),
|
||||||
|
),
|
||||||
TextFieldTags<String>(
|
TextFieldTags<String>(
|
||||||
textfieldTagsController: _stringTagController,
|
textfieldTagsController: _stringTagController,
|
||||||
initialTags: initialTags,
|
initialTags: initialTags,
|
||||||
|
@@ -87,6 +87,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
|||||||
String eventName = "";
|
String eventName = "";
|
||||||
String eventStartDate = "";
|
String eventStartDate = "";
|
||||||
String eventDescription = "";
|
String eventDescription = "";
|
||||||
|
String eventTicket = "";
|
||||||
|
String eventLink = "";
|
||||||
String place = "";
|
String place = "";
|
||||||
String imgUrl = "";
|
String imgUrl = "";
|
||||||
List<String> tags = [];
|
List<String> tags = [];
|
||||||
@@ -128,17 +130,17 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
|||||||
if (responseGet.statusCode == 200) {
|
if (responseGet.statusCode == 200) {
|
||||||
final responseBody = utf8.decode(responseGet.bodyBytes);
|
final responseBody = utf8.decode(responseGet.bodyBytes);
|
||||||
|
|
||||||
final event = Events.fromJson(jsonDecode(responseBody));
|
events = Events.fromJson(jsonDecode(responseBody));
|
||||||
final locale = Provider.of<LocaleProvider>(context, listen: false)
|
final locale = Provider.of<LocaleProvider>(context, listen: false)
|
||||||
.locale
|
.locale
|
||||||
?.toString() ??
|
?.toString() ??
|
||||||
'en_US';
|
'en_US';
|
||||||
final startDate =
|
final startDate =
|
||||||
DateTime.parse(event.startDate ?? DateTime.now().toString());
|
DateTime.parse(events?.startDate ?? DateTime.now().toString());
|
||||||
//final date = DateFormat.yMd().format(startDate);
|
//final date = DateFormat.yMd().format(startDate);
|
||||||
//final time = DateFormat.Hm().format(startDate);
|
//final time = DateFormat.Hm().format(startDate);
|
||||||
final endDate =
|
final endDate =
|
||||||
DateTime.parse(event.endDate ?? DateTime.now().toString());
|
DateTime.parse(events?.endDate ?? DateTime.now().toString());
|
||||||
String separator = AppLocalizations.of(context)?.at ?? "at";
|
String separator = AppLocalizations.of(context)?.at ?? "at";
|
||||||
final formattedStartDate =
|
final formattedStartDate =
|
||||||
DateFormat("EEEE d MMMM y '${separator}' HH:mm", locale)
|
DateFormat("EEEE d MMMM y '${separator}' HH:mm", locale)
|
||||||
@@ -151,14 +153,16 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
|||||||
String link = AppLocalizations.of(context)?.to_date ?? "to";
|
String link = AppLocalizations.of(context)?.to_date ?? "to";
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
eventName = event.name ?? "";
|
eventName = events?.name ?? "";
|
||||||
|
|
||||||
eventStartDate = "$formattedStartDate ${link} $formattedEndDate";
|
eventStartDate = "$formattedStartDate ${link} $formattedEndDate";
|
||||||
organizers = List<String>.from(event.organizers ?? []);
|
organizers = List<String>.from(events?.organizers ?? []);
|
||||||
place = event.place ?? "";
|
place = events?.place ?? "";
|
||||||
imgUrl = event.imgUrl ?? "";
|
imgUrl = events?.imgUrl ?? "";
|
||||||
eventDescription = event.description ?? "";
|
eventLink = events?.link ?? "";
|
||||||
tags = List<String>.from(event.tags ?? []);
|
eventTicket = events?.ticket ?? "";
|
||||||
|
eventDescription = events?.description ?? "";
|
||||||
|
tags = List<String>.from(events?.tags ?? []);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
final messages = {
|
final messages = {
|
||||||
@@ -276,6 +280,34 @@ class _ItemMenuState extends State<ItemMenu> with ShowAlertDialog {
|
|||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
overflow: TextOverflow.ellipsis)))
|
overflow: TextOverflow.ellipsis)))
|
||||||
]),
|
]),
|
||||||
|
Row(children: [
|
||||||
|
Icon(Icons.link),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)?.item_link ?? "Link : ",
|
||||||
|
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child:
|
||||||
|
Text("${eventLink}", style: TextStyle(fontSize: 15.0)))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(children: [
|
||||||
|
Icon(Icons.add_shopping_cart),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)?.item_ticket ?? "Ticket : ",
|
||||||
|
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Text("${eventTicket}",
|
||||||
|
style: TextStyle(fontSize: 15.0)))
|
||||||
|
],
|
||||||
|
),
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Icon(Icons.group),
|
Icon(Icons.group),
|
||||||
Text(
|
Text(
|
||||||
|
@@ -94,6 +94,30 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> toggleInterested(String eventId) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
final url = Uri.parse("${globals.api}/events/${eventId}/interest");
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
HttpHeaders.cookieHeader: "access_token=$accessToken"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw (AppLocalizations.of(context)?.toogle_interest ??
|
||||||
|
"Error toogle interest: ${response.statusCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var event = json.decode(response.body);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
return {"interested": false, "interested_count": 0};
|
||||||
|
}
|
||||||
|
|
||||||
// variable to call and store future list of posts
|
// variable to call and store future list of posts
|
||||||
|
|
||||||
// function to fetch data from api and return future list of posts
|
// function to fetch data from api and return future list of posts
|
||||||
@@ -190,10 +214,39 @@ class _MyHomePageState extends State<ListItemOrganizers> {
|
|||||||
|
|
||||||
final dateLongue =
|
final dateLongue =
|
||||||
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
||||||
|
final countInterestedString =
|
||||||
|
AppLocalizations.of(context)?.count_interested ??
|
||||||
|
"Interested people number";
|
||||||
|
final countInterested =
|
||||||
|
"${countInterestedString} : ${post.interestedCount}";
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('${post.name!}'),
|
title: Text('${post.name!}'),
|
||||||
subtitle: Text('${post.place!}\n${dateLongue}'),
|
subtitle:
|
||||||
|
Text('${post.place!}\n${dateLongue}\n${countInterested}'),
|
||||||
|
trailing: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
final result = await toggleInterested(post.id!);
|
||||||
|
setState(() {
|
||||||
|
post.interested = result["interested"];
|
||||||
|
post.interestedCount = result["interested_count"];
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context)?.error_update ??
|
||||||
|
"Error when updating")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
post.interested ?? false
|
||||||
|
? Icons.favorite
|
||||||
|
: Icons.favorite_border,
|
||||||
|
color:
|
||||||
|
post.interested ?? false ? Colors.red : Colors.grey)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@@ -121,6 +121,30 @@ class _MyHomePageState extends State<ListItemTags> {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> toggleInterested(String eventId) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
final url = Uri.parse("${globals.api}/events/${eventId}/interest");
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
HttpHeaders.cookieHeader: "access_token=$accessToken"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw (AppLocalizations.of(context)?.toogle_interest ??
|
||||||
|
"Error toogle interest: ${response.statusCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var event = json.decode(response.body);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
return {"interested": false, "interested_count": 0};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -168,6 +192,7 @@ class _MyHomePageState extends State<ListItemTags> {
|
|||||||
Widget buildPosts(List<Events> posts) {
|
Widget buildPosts(List<Events> posts) {
|
||||||
// ListView Builder to show data in a list
|
// ListView Builder to show data in a list
|
||||||
String tag = AppLocalizations.of(context)?.item_tags ?? "Tags : ";
|
String tag = AppLocalizations.of(context)?.item_tags ?? "Tags : ";
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
// Here we take the value from the MyHomePage object that was created by
|
||||||
@@ -191,9 +216,39 @@ class _MyHomePageState extends State<ListItemTags> {
|
|||||||
final dateLongue =
|
final dateLongue =
|
||||||
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
||||||
|
|
||||||
|
final countInterestedString =
|
||||||
|
AppLocalizations.of(context)?.count_interested ??
|
||||||
|
"Interested people number";
|
||||||
|
final countInterested =
|
||||||
|
"${countInterestedString} : ${post.interestedCount}";
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('${post.name!}'),
|
title: Text('${post.name!}'),
|
||||||
subtitle: Text('${post.place!}\n${dateLongue}'),
|
subtitle:
|
||||||
|
Text('${post.place!}\n${dateLongue}\n${countInterested}'),
|
||||||
|
trailing: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
final result = await toggleInterested(post.id!);
|
||||||
|
setState(() {
|
||||||
|
post.interested = result["interested"];
|
||||||
|
post.interestedCount = result["interested_count"];
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context)?.error_update ??
|
||||||
|
"Error when updating")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
post.interested ?? false
|
||||||
|
? Icons.favorite
|
||||||
|
: Icons.favorite_border,
|
||||||
|
color:
|
||||||
|
post.interested ?? false ? Colors.red : Colors.grey)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@@ -423,7 +423,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
var url = await getUrlForEvents();
|
var url = await getUrlForEvents();
|
||||||
final response = await http.get(url, headers: {
|
final response = await http.get(url, headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
HttpHeaders.cookieHeader: "acce0ss_token=$accessToken"
|
HttpHeaders.cookieHeader: "access_token=$accessToken"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@@ -469,6 +469,30 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> toggleInterested(String eventId) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
final url = Uri.parse("${globals.api}/events/${eventId}/interest");
|
||||||
|
if (accessToken.isNotEmpty) {
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
HttpHeaders.cookieHeader: "access_token=$accessToken"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw (AppLocalizations.of(context)?.toogle_interest ??
|
||||||
|
"Error toogle interest: ${response.statusCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var event = json.decode(response.body);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
return {"interested": false, "interested_count": 0};
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> fetchPostsByLocation() async {
|
Future<void> fetchPostsByLocation() async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
@@ -871,9 +895,37 @@ class _MyHomePageState extends State<ListItemMenu> {
|
|||||||
'en_US';
|
'en_US';
|
||||||
final dateLongue =
|
final dateLongue =
|
||||||
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
DateFormat('EEEE d MMMM y', locale).format(startDate);
|
||||||
|
final countInterestedString =
|
||||||
|
AppLocalizations.of(context)?.count_interested ??
|
||||||
|
"Interested people number";
|
||||||
|
final countInterested =
|
||||||
|
"${countInterestedString} : ${post.interestedCount}";
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('${post.name!}'),
|
title: Text('${post.name!}'),
|
||||||
subtitle: Text('${post.place!}\n${dateLongue}'),
|
subtitle: Text('${post.place!}\n${dateLongue}\n${countInterested}'),
|
||||||
|
trailing: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
final result = await toggleInterested(post.id!);
|
||||||
|
setState(() {
|
||||||
|
post.interested = result["interested"];
|
||||||
|
post.interestedCount = result["interested_count"];
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context)?.error_update ??
|
||||||
|
"Error when updating")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
post.interested ?? false
|
||||||
|
? Icons.favorite
|
||||||
|
: Icons.favorite_border,
|
||||||
|
color:
|
||||||
|
post.interested ?? false ? Colors.red : Colors.grey)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
Reference in New Issue
Block a user