-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into app-diagram
- Loading branch information
Showing
38 changed files
with
582 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:proxima/views/navigation/bottom_navigation_bar/navigation_bar_routes.dart"; | ||
|
||
/// A class that holds the currently open page in the home screen, with optional | ||
/// arguments. | ||
class SelectedPageDetails { | ||
final NavigationBarRoutes route; | ||
final Object? args; | ||
|
||
const SelectedPageDetails({ | ||
required this.route, | ||
this.args, | ||
}); | ||
|
||
Widget page() { | ||
return route.page(args); | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (identical(this, other)) return true; | ||
|
||
return other is SelectedPageDetails && | ||
other.route == route && | ||
other.args == args; | ||
} | ||
|
||
@override | ||
int get hashCode { | ||
return Object.hash(route, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import "package:cloud_firestore/cloud_firestore.dart"; | ||
import "package:google_maps_flutter/google_maps_flutter.dart"; | ||
|
||
extension ToLatLng on GeoPoint { | ||
LatLng toLatLng() { | ||
return LatLng(latitude, longitude); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
lib/viewmodels/option_selection/selected_page_view_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "package:hooks_riverpod/hooks_riverpod.dart"; | ||
import "package:proxima/models/ui/selected_page_details.dart"; | ||
import "package:proxima/viewmodels/option_selection/options_view_model.dart"; | ||
import "package:proxima/views/navigation/bottom_navigation_bar/navigation_bar_routes.dart"; | ||
|
||
/// A view model that holds the currently open page in the home screen. This | ||
/// should never contain a page that does not have a bottom navigation bar. | ||
/// Those should instead be pushed directly to the navigation stack. | ||
class SelectedPageViewModel extends OptionsViewModel<SelectedPageDetails> { | ||
static const defaultSelectedPage = | ||
SelectedPageDetails(route: NavigationBarRoutes.feed); | ||
|
||
SelectedPageViewModel() : super(defaultSelectedPage); | ||
|
||
@override | ||
void setOption(SelectedPageDetails option) { | ||
if (option.route.routeDestination != null) { | ||
throw Exception( | ||
"This page should be pushed and not set as the selected page, push it directly from your context instead.", | ||
); | ||
} | ||
super.setOption(option); | ||
} | ||
|
||
void selectPage(NavigationBarRoutes route, [Object? args]) { | ||
setOption(SelectedPageDetails(route: route, args: args)); | ||
} | ||
} | ||
|
||
final selectedPageViewModelProvider = | ||
NotifierProvider<SelectedPageViewModel, SelectedPageDetails>( | ||
() => SelectedPageViewModel(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.