Skip to content

Commit

Permalink
Merge pull request #372 from ProximaEPFL/dcm-fixes
Browse files Browse the repository at this point in the history
Apply DCM main suggestions
  • Loading branch information
gruvw authored Jun 4, 2024
2 parents ada4722 + d48f0a3 commit 3c16741
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 35 deletions.
1 change: 1 addition & 0 deletions lib/models/ui/comment_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CommentDetails {
UserFirestore owner,
) {
final ownerData = owner.data;

return CommentDetails(
content: commentData.content,
ownerDisplayName: ownerData.displayName,
Expand Down
2 changes: 2 additions & 0 deletions lib/models/ui/linear_segmented_hsv_colormap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class LinearSegmentedHSVColormap {
assert(stops.length >= 2, "There must be at least two color stops");
final colors = stops.mapIndexed((i, _) {
final hue = hueStart + (hueEnd - hueStart) * i / (stops.length - 1);

return HSVColor.fromAHSV(1, hue, saturation, value);
});

final colorStops = Map.fromIterables(stops, colors);

return LinearSegmentedHSVColormap(colorStops);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/models/ui/post_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class PostDetails {
GeoFirePoint geoFirePoint,
bool isChallenge,
) {
final geopoint = postFirestore.location.geoPoint;

return PostDetails(
postId: postFirestore.id,
title: postFirestore.data.title,
Expand All @@ -99,11 +101,11 @@ class PostDetails {
ownerCentauriPoints: userFirestore.data.centauriPoints,
publicationDate: postFirestore.data.publicationTime.toDate(),
distance: (geoFirePoint.distanceBetweenInKm(
geopoint: postFirestore.location.geoPoint,
geopoint: geopoint,
) *
1000)
.round(),
location: postFirestore.location.geoPoint.toLatLng(),
location: geopoint.toLatLng(),
isChallenge: isChallenge,
);
}
Expand Down
10 changes: 4 additions & 6 deletions lib/viewmodels/map/map_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ class MapViewModel extends AutoDisposeFamilyAsyncNotifier<MapDetails, LatLng?> {
Future<MapDetails> build([LatLng? arg]) async {
if (arg != null) {
disableFollowUser();
return MapDetails(
initialLocation: arg,
);

return MapDetails(initialLocation: arg);
} else {
enableFollowUser();
final geoPoint =
await ref.read(geolocationServiceProvider).getCurrentPosition();
return MapDetails(
initialLocation: geoPoint.toLatLng(),
);

return MapDetails(initialLocation: geoPoint.toLatLng());
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/viewmodels/user_comments_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UserCommentViewModel extends AutoDisposeAsyncNotifier<UserCommentsState> {
parentPostId: comment.data.parentPostId,
description: comment.data.content,
);

return userComment;
}).toList();

Expand Down
1 change: 1 addition & 0 deletions lib/viewmodels/users_ranking_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class UsersRankingViewModel extends AutoDisposeAsyncNotifier<RankingDetails> {
)
.refresh();
}

return state;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/views/components/async/loading_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import "package:flutter/material.dart";
import "package:flutter_hooks/flutter_hooks.dart";
import "package:proxima/views/helpers/types/future_void_callback.dart";

enum LoadingState {
still,
pending,
completed,
}

/// An async capable button that displays a [CircularProgressIndicator] once it is pressed
/// and until the future of the callback function completes.
class LoadingIconButton extends HookWidget {
Expand Down Expand Up @@ -70,3 +64,9 @@ class DeleteButton extends LoadingIconButton {
const DeleteButton({super.key, required super.onClick})
: super(icon: Icons.delete);
}

enum LoadingState {
still,
pending,
completed,
}
4 changes: 2 additions & 2 deletions lib/views/navigation/map_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class MapAction extends ConsumerWidget {

/// Open the map with the given [mapOption] and [initialLocation].
/// The [depth] is used to pop the navigation stack back to the root page.
static Future<void> openMap(
static void openMap(
WidgetRef ref,
BuildContext context,
MapSelectionOptions mapOption,
int depth,
LatLng initialLocation,
) async {
) {
for (var i = 0; i < depth; i++) {
Navigator.pop(context);
}
Expand Down
1 change: 1 addition & 0 deletions lib/views/pages/home/content/challenge/challenge_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ChallengeList extends ConsumerWidget {
);

final onRefresh = ref.read(challengeViewModelProvider.notifier).refresh;

return CircularValue(
future: asyncChallenges,
builder: (context, challenges) {
Expand Down
38 changes: 19 additions & 19 deletions lib/views/pages/home/content/map/components/post_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ class PostMap extends ConsumerWidget {
this.initialLocation,
});

static Marker mapPinDetailsToMarker(BuildContext context, MapPinDetails pin) {
return Marker(
markerId: pin.id,
position: pin.position,
onTap: () {
showDialog(
context: context,
builder: (context) {
return MapPinPopUp(
key: mapPinPopUpKey,
mapPinPopUpDetails: pin.mapPopUpDetails,
);
},
);
},
);
}

@override
Widget build(BuildContext context, WidgetRef ref) {
// This provider is used to get information about the map.
Expand All @@ -41,24 +59,6 @@ class PostMap extends ConsumerWidget {
//Set of markers to be displayed on the map
Set<Marker> markers = {};

Marker mapPinDetailsToMarker(MapPinDetails pin) {
return Marker(
markerId: pin.id,
position: pin.position,
onTap: () {
showDialog(
context: context,
builder: (context) {
return MapPinPopUp(
key: mapPinPopUpKey,
mapPinPopUpDetails: pin.mapPopUpDetails,
);
},
);
},
);
}

// This will redraw the circle and update camera when the user's position changes.
positionValue.when(
data: (geoPoint) {
Expand Down Expand Up @@ -86,7 +86,7 @@ class PostMap extends ConsumerWidget {
markers.clear();
for (final pin in data) {
markers.add(
mapPinDetailsToMarker(pin),
mapPinDetailsToMarker(context, pin),
);
}
},
Expand Down
1 change: 1 addition & 0 deletions lib/views/pages/profile/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ProfilePage extends ConsumerWidget {
future: asyncUserData,
builder: (context, value) {
final user = value.firestoreUser;

return DefaultTabController(
length: 2,
child: Scaffold(
Expand Down

0 comments on commit 3c16741

Please sign in to comment.