Skip to content

Commit

Permalink
different markers on map for temp and address location
Browse files Browse the repository at this point in the history
  • Loading branch information
LGro committed May 28, 2024
1 parent ef3f1c2 commit 7ebab0a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
6 changes: 4 additions & 2 deletions lib/ui/map/cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Iterable<Location> contactToLocations(CoagContact contact) =>
latitude: l.latitude,
label:
contact.details?.displayName ?? contact.systemContact!.displayName,
subLabel: l.name));
subLabel: l.name,
marker: MarkerType.address));

Location temporaryLocationToLocation(
CoagContact contact, ContactTemporaryLocation l) =>
Expand All @@ -33,7 +34,8 @@ Location temporaryLocationToLocation(
'unknown',
subLabel: l.name,
longitude: l.longitude,
latitude: l.latitude);
latitude: l.latitude,
marker: MarkerType.temporary);

class MapCubit extends Cubit<MapState> {
MapCubit(this.contactsRepository)
Expand Down
7 changes: 7 additions & 0 deletions lib/ui/map/cubit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/ui/map/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ Marker _buildMarker(
color: Colors.black),
),
])),
const Icon(Icons.location_pin,
size: 50, color: Colors.deepPurple),
Icon(
(location.marker == MarkerType.address)
? Icons.house
: Icons.location_pin,
size: 50,
color: Colors.deepPurple),
])));

class MapPage extends StatelessWidget {
Expand Down
19 changes: 12 additions & 7 deletions lib/ui/map/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ extension MapStatusX on MapStatus {
bool get isDenied => this == MapStatus.denied;
}

// TODO: Add custom marker as attribute
enum MarkerType { address, temporary }

// TODO: Add color or indicator whether it's a contact or profile location
@JsonSerializable()
class Location {
Location(
{required this.coagContactId,
required this.longitude,
required this.latitude,
required this.label,
required this.subLabel});
Location({
required this.coagContactId,
required this.longitude,
required this.latitude,
required this.label,
required this.subLabel,
required this.marker,
});
factory Location.fromJson(Map<String, dynamic> json) =>
_$LocationFromJson(json);

Expand All @@ -28,6 +32,7 @@ class Location {
final double latitude;
final String label;
final String subLabel;
final MarkerType marker;
Map<String, dynamic> toJson() => _$LocationToJson(this);
}

Expand Down

0 comments on commit 7ebab0a

Please sign in to comment.