diff --git a/lib/models/ui/comment_details.dart b/lib/models/ui/comment_details.dart index 9f496df4..697ac964 100644 --- a/lib/models/ui/comment_details.dart +++ b/lib/models/ui/comment_details.dart @@ -56,6 +56,7 @@ class CommentDetails { UserFirestore owner, ) { final ownerData = owner.data; + return CommentDetails( content: commentData.content, ownerDisplayName: ownerData.displayName, diff --git a/lib/models/ui/linear_segmented_hsv_colormap.dart b/lib/models/ui/linear_segmented_hsv_colormap.dart index 755f8ce6..05336a91 100644 --- a/lib/models/ui/linear_segmented_hsv_colormap.dart +++ b/lib/models/ui/linear_segmented_hsv_colormap.dart @@ -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); } diff --git a/lib/models/ui/post_details.dart b/lib/models/ui/post_details.dart index 34e7c568..074da214 100644 --- a/lib/models/ui/post_details.dart +++ b/lib/models/ui/post_details.dart @@ -87,6 +87,8 @@ class PostDetails { GeoFirePoint geoFirePoint, bool isChallenge, ) { + final geopoint = postFirestore.location.geoPoint; + return PostDetails( postId: postFirestore.id, title: postFirestore.data.title, @@ -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, ); } diff --git a/lib/viewmodels/map/map_view_model.dart b/lib/viewmodels/map/map_view_model.dart index 004b5d50..9bbfbe98 100644 --- a/lib/viewmodels/map/map_view_model.dart +++ b/lib/viewmodels/map/map_view_model.dart @@ -17,16 +17,14 @@ class MapViewModel extends AutoDisposeFamilyAsyncNotifier { Future 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()); } } diff --git a/lib/viewmodels/user_comments_view_model.dart b/lib/viewmodels/user_comments_view_model.dart index 8b0227e3..30e1f038 100644 --- a/lib/viewmodels/user_comments_view_model.dart +++ b/lib/viewmodels/user_comments_view_model.dart @@ -32,6 +32,7 @@ class UserCommentViewModel extends AutoDisposeAsyncNotifier { parentPostId: comment.data.parentPostId, description: comment.data.content, ); + return userComment; }).toList(); diff --git a/lib/viewmodels/users_ranking_view_model.dart b/lib/viewmodels/users_ranking_view_model.dart index 5ad10edc..54376a1d 100644 --- a/lib/viewmodels/users_ranking_view_model.dart +++ b/lib/viewmodels/users_ranking_view_model.dart @@ -81,6 +81,7 @@ class UsersRankingViewModel extends AutoDisposeAsyncNotifier { ) .refresh(); } + return state; } diff --git a/lib/views/components/async/loading_icon_button.dart b/lib/views/components/async/loading_icon_button.dart index 91425f6c..e53b41a0 100644 --- a/lib/views/components/async/loading_icon_button.dart +++ b/lib/views/components/async/loading_icon_button.dart @@ -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 { @@ -70,3 +64,9 @@ class DeleteButton extends LoadingIconButton { const DeleteButton({super.key, required super.onClick}) : super(icon: Icons.delete); } + +enum LoadingState { + still, + pending, + completed, +} diff --git a/lib/views/navigation/map_action.dart b/lib/views/navigation/map_action.dart index 63986a45..8987bf3a 100644 --- a/lib/views/navigation/map_action.dart +++ b/lib/views/navigation/map_action.dart @@ -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 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); } diff --git a/lib/views/pages/home/content/challenge/challenge_list.dart b/lib/views/pages/home/content/challenge/challenge_list.dart index ce43e06d..b8a7f053 100644 --- a/lib/views/pages/home/content/challenge/challenge_list.dart +++ b/lib/views/pages/home/content/challenge/challenge_list.dart @@ -19,6 +19,7 @@ class ChallengeList extends ConsumerWidget { ); final onRefresh = ref.read(challengeViewModelProvider.notifier).refresh; + return CircularValue( future: asyncChallenges, builder: (context, challenges) { diff --git a/lib/views/pages/home/content/map/components/post_map.dart b/lib/views/pages/home/content/map/components/post_map.dart index 171c142a..5604441f 100644 --- a/lib/views/pages/home/content/map/components/post_map.dart +++ b/lib/views/pages/home/content/map/components/post_map.dart @@ -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. @@ -41,24 +59,6 @@ class PostMap extends ConsumerWidget { //Set of markers to be displayed on the map Set 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) { @@ -86,7 +86,7 @@ class PostMap extends ConsumerWidget { markers.clear(); for (final pin in data) { markers.add( - mapPinDetailsToMarker(pin), + mapPinDetailsToMarker(context, pin), ); } }, diff --git a/lib/views/pages/profile/profile_page.dart b/lib/views/pages/profile/profile_page.dart index e5933e2a..218b9bd0 100644 --- a/lib/views/pages/profile/profile_page.dart +++ b/lib/views/pages/profile/profile_page.dart @@ -45,6 +45,7 @@ class ProfilePage extends ConsumerWidget { future: asyncUserData, builder: (context, value) { final user = value.firestoreUser; + return DefaultTabController( length: 2, child: Scaffold(