Skip to content

Commit

Permalink
Update [journeys_page.dart] and [challenges_page.dart] documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
shah-esha committed Nov 18, 2024
1 parent 0a23e06 commit 1e53d2e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
31 changes: 29 additions & 2 deletions game/lib/challenges/challenges_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ class ChallengeCellDto {
late String eventId;
}

/**
* `ChallengesPage` - A page that displays a list of challenges, allowing
* users to filter based on difficulty, location, category, and search text.
*
* @remarks
* This class manages the display of challenges by retrieving
* challenge data and applying various filters. The page updates dynamically
* based on the user's selected difficulty, locations, categories,
* and/or search text. It also utilizes the `ChallengeCell` widget to render
* each challenge's details.
*
* @param myDifficulty - The selected difficulty filter for the challenges.
* @param myLocations - The selected locations filter for the challenges.
* @param myCategories - The selected categories filter for the challenges.
* @param mySearchText - The search text used to filter challenges by name
* or location.
*/
class ChallengesPage extends StatefulWidget {
String? myDifficulty;
List<String>? myLocations;
Expand Down Expand Up @@ -79,6 +96,18 @@ class _ChallengesPageState extends State<ChallengesPage> {
mySearchText = searchText ?? '';
}

/**
* Builds and displays the challenges list based on the selected filters.
*
* @remarks
* This function fetches data from multiple models, applies filtering
* logic based on the user's preferences (difficulty, location, category,
* and search text), and renders the filtered challenges using `ChallengeCell`
* widgets. It returns a `ListView` widget displaying the challenge details
* dynamically.
*
* @returns A `Widget` representing the challenges list with filtered items.
*/
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -147,8 +176,6 @@ class _ChallengesPageState extends State<ChallengesPage> {

if (widget.myDifficulty?.length == 0 ||
widget.myDifficulty == event.difficulty?.name) {
print(widget.myDifficulty);
print(event.difficulty?.name);
eventMatchesDifficultySelection = true;
} else
eventMatchesDifficultySelection = false;
Expand Down
37 changes: 33 additions & 4 deletions game/lib/journeys/journeys_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ class JourneyCellDto {
late String eventId;
}

/**
* `JourneysPage` - A page that displays a list of journeys, allowing
* users to filter based on difficulty, location, category, and search text.
*
* @remarks
* This class manages the display of challenges by retrieving a
* journey and its challenges' data and applying various filters. The page updates dynamically
* based on the user's selected difficulty, locations, categories,
* and/or search text. It also utilizes the `JourneyCell` widget to render
* each challenge's details.
*
* @param myDifficulty - The selected difficulty filter for the challenges.
* @param myLocations - The selected locations filter for the challenges.
* @param myCategories - The selected categories filter for the challenges.
* @param mySearchText - The search text used to filter challenges by name
* or location.
*/
class JourneysPage extends StatefulWidget {
String? myDifficulty;
List<String>? myLocations;
Expand Down Expand Up @@ -104,6 +121,18 @@ class _JourneysPageState extends State<JourneysPage> {
});
}

/**
* Builds and displays the journeys list based on the selected filters.
*
* @remarks
* This function fetches data from multiple models, applies filtering
* logic based on the user's preferences (difficulty, location, category,
* and search text) for both the journey and its challenges, and renders the
* filtered journeys using `JourneyCell` widgets. It returns a `ListView`
* widget displaying the journey details dynamically.
*
* @returns A `Widget` representing the journeys list with filtered items.
*/
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -170,8 +199,8 @@ class _JourneysPageState extends State<JourneysPage> {

final challengeLocation = challenge.location?.name ?? "";
final challengeName = challenge.name ?? "";
final eventDifficulty = event.difficulty?.name ?? "";
final String eventName = event.name ?? "";
final journeyDifficulty = event.difficulty?.name ?? "";
final journeyName = event.name ?? "";

bool eventMatchesDifficultySelection = true;
bool eventMatchesCategorySelection = true;
Expand Down Expand Up @@ -219,13 +248,13 @@ class _JourneysPageState extends State<JourneysPage> {
eventMatchesSearchText = true;
} else
eventMatchesSearchText = false;
if (eventName
if (journeyName
.toLowerCase()
.contains(searchTerm.toLowerCase())) {
eventMatchesSearchText = true;
} else
eventMatchesSearchText = false;
if (eventDifficulty
if (journeyDifficulty
.toLowerCase()
.contains(searchTerm.toLowerCase())) {
eventMatchesSearchText = true;
Expand Down

0 comments on commit 1e53d2e

Please sign in to comment.