first ui elements using the new structs
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class Destination {
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String name;
|
||||
final String description;
|
||||
// final DestinationType type;
|
||||
final Duration duration;
|
||||
final bool visited;
|
||||
|
||||
const Destination({
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.name,
|
||||
required this.description,
|
||||
// required this.type,
|
||||
required this.duration,
|
||||
required this.visited,
|
||||
});
|
||||
|
||||
factory Destination.fromJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
'lat': double latitude,
|
||||
'lon': double longitude,
|
||||
'name': String name,
|
||||
'description': String description,
|
||||
// 'type': String type,
|
||||
'duration': int duration,
|
||||
'visited': bool visited
|
||||
|
||||
} =>
|
||||
Destination(
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
name: name,
|
||||
description: description,
|
||||
// type: "DestinationType.values.firstWhere((element) => element.name == type)",
|
||||
duration: Duration(minutes: duration),
|
||||
visited: visited
|
||||
),
|
||||
_ => throw const FormatException('Failed to load destination.'),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class DestinationType {
|
||||
final String name;
|
||||
final String description;
|
||||
final Icon icon;
|
||||
|
||||
const DestinationType({
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.icon,
|
||||
});
|
||||
}
|
||||
|
||||
|
56
frontend/lib/structs/landmark.dart
Normal file
56
frontend/lib/structs/landmark.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
class Landmark {
|
||||
final String name;
|
||||
final List location;
|
||||
final LandmarkType type;
|
||||
// final String description;
|
||||
// final Duration duration;
|
||||
// final bool visited;
|
||||
|
||||
const Landmark({
|
||||
required this.name,
|
||||
required this.location,
|
||||
required this.type,
|
||||
// required this.description,
|
||||
// required this.duration,
|
||||
// required this.visited,
|
||||
});
|
||||
|
||||
factory Landmark.fromJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
'loc': List location,
|
||||
'name': String name,
|
||||
'type': String type,
|
||||
// 'description': String description,
|
||||
// 'duration': int duration,
|
||||
// 'visited': bool visited
|
||||
|
||||
} =>
|
||||
Landmark(
|
||||
name: name,
|
||||
location: location,
|
||||
type: LandmarkType(name: type)
|
||||
// description: description,
|
||||
// duration: Duration(minutes: duration),
|
||||
// visited: visited
|
||||
),
|
||||
_ => throw const FormatException('Failed to load destination.'),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class LandmarkType {
|
||||
final String name;
|
||||
// final String description;
|
||||
// final Icon icon;
|
||||
|
||||
const LandmarkType({
|
||||
required this.name,
|
||||
// required this.description,
|
||||
// required this.icon,
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import "package:fast_network_navigation/structs/destination.dart";
|
||||
import "package:fast_network_navigation/structs/landmark.dart";
|
||||
|
||||
|
||||
class Route {
|
||||
final String name;
|
||||
final Duration duration;
|
||||
final List<Destination> destinations;
|
||||
final List<Landmark> landmarks;
|
||||
|
||||
Route({
|
||||
required this.name,
|
||||
required this.duration,
|
||||
required this.destinations
|
||||
required this.landmarks
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user