2024-09-06 14:13:30 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2024-09-02 13:39:56 +01:00
|
|
|
import 'package:latlong2/latlong.dart';
|
|
|
|
|
2024-08-22 09:20:59 +01:00
|
|
|
class Favorite {
|
|
|
|
int id;
|
|
|
|
String userId;
|
|
|
|
double lat;
|
|
|
|
double lng;
|
2024-08-26 11:09:47 +01:00
|
|
|
String name;
|
|
|
|
String description;
|
2024-08-22 09:20:59 +01:00
|
|
|
|
2024-08-26 11:09:47 +01:00
|
|
|
Favorite(this.id, this.userId, this.lat, this.lng, this.name, this.description);
|
2024-08-27 11:16:07 +01:00
|
|
|
|
|
|
|
factory Favorite.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Favorite(
|
|
|
|
json['id'],
|
|
|
|
json['user_id'],
|
|
|
|
json['lat'],
|
|
|
|
json['lng'],
|
|
|
|
json['name'],
|
|
|
|
json['description'],
|
|
|
|
);
|
|
|
|
}
|
2024-08-22 12:28:24 +01:00
|
|
|
}
|
|
|
|
|
2024-09-03 12:33:50 +01:00
|
|
|
class Review {
|
|
|
|
int id;
|
|
|
|
String userId;
|
|
|
|
double lat;
|
|
|
|
double lng;
|
|
|
|
String place_name;
|
|
|
|
String place_description;
|
|
|
|
String title;
|
2024-09-04 10:53:32 +01:00
|
|
|
String content;
|
2024-09-03 12:33:50 +01:00
|
|
|
int rating;
|
2024-09-11 11:46:49 +01:00
|
|
|
Image? image;
|
2024-09-03 12:33:50 +01:00
|
|
|
|
2024-09-11 11:46:49 +01:00
|
|
|
Review(this.id, this.userId, this.lat, this.lng, this.place_name, this.place_description, this.title, this.content, this.rating, this.image);
|
2024-09-03 12:33:50 +01:00
|
|
|
|
|
|
|
factory Review.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Review(
|
|
|
|
json['id'],
|
|
|
|
json['user_id'],
|
|
|
|
json['lat'],
|
|
|
|
json['lng'],
|
|
|
|
json['place_name'],
|
|
|
|
json['place_description'],
|
|
|
|
json['title'],
|
2024-09-04 10:53:32 +01:00
|
|
|
json['content'],
|
|
|
|
json['rating'],
|
2024-09-11 11:46:49 +01:00
|
|
|
json['image'] != null ? Image.fromJson(json['image']) : null,
|
2024-09-03 12:33:50 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-05 13:55:34 +01:00
|
|
|
class Place {
|
|
|
|
String name;
|
|
|
|
String description;
|
2024-09-05 17:11:35 +01:00
|
|
|
LatLng point;
|
2024-09-05 13:55:34 +01:00
|
|
|
|
2024-09-05 17:11:35 +01:00
|
|
|
Place(this.name, this.description, this.point);
|
2024-09-05 13:55:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class ReviewList {
|
|
|
|
List<Review> reviews;
|
|
|
|
Place place;
|
|
|
|
|
|
|
|
ReviewList(this.reviews, this.place);
|
|
|
|
}
|
|
|
|
|
2024-08-23 14:19:15 +01:00
|
|
|
class Login {
|
2024-08-22 12:28:24 +01:00
|
|
|
String token;
|
2024-08-23 11:34:38 +01:00
|
|
|
String id;
|
2024-09-02 10:39:03 +01:00
|
|
|
String refreshToken;
|
2024-08-23 14:19:15 +01:00
|
|
|
|
2024-09-02 10:39:03 +01:00
|
|
|
Login(this.token, this.id, this.refreshToken);
|
2024-08-23 14:19:15 +01:00
|
|
|
|
|
|
|
factory Login.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Login(
|
|
|
|
json['token'],
|
|
|
|
json['id'],
|
2024-09-02 10:39:03 +01:00
|
|
|
json['refreshToken'],
|
2024-08-23 14:19:15 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class User {
|
|
|
|
String id;
|
2024-08-23 11:34:38 +01:00
|
|
|
String email;
|
2024-09-06 14:13:30 +01:00
|
|
|
String username;
|
2024-09-09 14:36:32 +01:00
|
|
|
String profilePicture;
|
2024-08-23 11:34:38 +01:00
|
|
|
DateTime createdAt;
|
|
|
|
|
2024-09-06 14:13:30 +01:00
|
|
|
User( this.id, this.email, this.username, this.profilePicture, this.createdAt);
|
2024-08-23 11:34:38 +01:00
|
|
|
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
|
|
return User(
|
|
|
|
json['id'],
|
|
|
|
json['email'],
|
|
|
|
json['username'],
|
2024-09-06 14:13:30 +01:00
|
|
|
json['profilePicture'],
|
2024-08-23 11:34:38 +01:00
|
|
|
DateTime.parse(json['createdAt']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-09-02 13:39:56 +01:00
|
|
|
|
2024-09-10 14:44:50 +01:00
|
|
|
class Image {
|
|
|
|
int id;
|
|
|
|
String userId;
|
|
|
|
String imageUrl;
|
|
|
|
|
|
|
|
Image(this.id, this.userId, this.imageUrl);
|
|
|
|
|
|
|
|
factory Image.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Image(
|
|
|
|
json['id'],
|
|
|
|
json['user_id'],
|
|
|
|
json['image_url'],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-05 17:11:35 +01:00
|
|
|
class SearchResults {
|
2024-09-02 13:39:56 +01:00
|
|
|
LatLng location;
|
|
|
|
String name;
|
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
SearchResults(this.location, this.name);
|
|
|
|
|
|
|
|
factory SearchResults.fromJson(Map<String, dynamic> json) {
|
|
|
|
double lat = json['lat'];
|
|
|
|
double lon = json['lon'];
|
|
|
|
String name = json['tags']['name'] ?? 'Unknown';
|
|
|
|
|
|
|
|
return SearchResults(LatLng(lat, lon), name);
|
|
|
|
}
|
2024-09-02 13:39:56 +01:00
|
|
|
}
|
2024-09-12 12:29:06 +01:00
|
|
|
|