-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Compass App: Activities screen, error handling and logs #2371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d0f2006
Compass App: Add "server" dart shelf-app and "shared" dart package (#…
miquelbeltran c975205
add logging
miquelbeltran 576cd9e
dart format
miquelbeltran fc4b108
remove duplicated json
miquelbeltran e6393e6
error filled button
miquelbeltran 7f98337
fix analyze issues
miquelbeltran 1a50897
Created Dimens and support basic adaptive ui
miquelbeltran c0349b9
TimeOfDay as Enum
miquelbeltran 93e642a
simple app localization
miquelbeltran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
class Assets { | ||
static const activities = 'assets/activities.json'; | ||
static const destinations = 'assets/destinations.json'; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
39 changes: 39 additions & 0 deletions
39
compass_app/app/lib/ui/activities/widgets/activities_header.dart
This file contains hidden or 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,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
|
||
import '../../core/localization/applocalization.dart'; | ||
import '../../core/themes/dimens.dart'; | ||
import '../../core/ui/back_button.dart'; | ||
import '../../core/ui/home_button.dart'; | ||
|
||
class ActivitiesHeader extends StatelessWidget { | ||
const ActivitiesHeader({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: EdgeInsets.only( | ||
left: Dimens.of(context).paddingScreenHorizontal, | ||
right: Dimens.of(context).paddingScreenHorizontal, | ||
top: Dimens.of(context).paddingScreenVertical, | ||
bottom: Dimens.paddingVertical, | ||
), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
CustomBackButton( | ||
onTap: () { | ||
// Navigate to ResultsScreen and edit search | ||
context.go('/results'); | ||
}, | ||
), | ||
Text( | ||
AppLocalization.of(context).activities, | ||
style: Theme.of(context).textTheme.titleLarge, | ||
), | ||
const HomeButton(), | ||
], | ||
), | ||
); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
compass_app/app/lib/ui/activities/widgets/activities_list.dart
This file contains hidden or 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,57 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../core/themes/dimens.dart'; | ||
import '../view_models/activities_viewmodel.dart'; | ||
import 'activity_entry.dart'; | ||
import 'activity_time_of_day.dart'; | ||
|
||
class ActivitiesList extends StatelessWidget { | ||
const ActivitiesList({ | ||
super.key, | ||
required this.viewModel, | ||
required this.activityTimeOfDay, | ||
}); | ||
|
||
final ActivitiesViewModel viewModel; | ||
final ActivityTimeOfDay activityTimeOfDay; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final list = switch (activityTimeOfDay) { | ||
ActivityTimeOfDay.daytime => viewModel.daytimeActivities, | ||
ActivityTimeOfDay.evening => viewModel.eveningActivities, | ||
}; | ||
return SliverPadding( | ||
padding: EdgeInsets.only( | ||
top: Dimens.paddingVertical, | ||
left: Dimens.of(context).paddingScreenHorizontal, | ||
right: Dimens.of(context).paddingScreenHorizontal, | ||
bottom: Dimens.paddingVertical, | ||
), | ||
sliver: SliverList( | ||
delegate: SliverChildBuilderDelegate( | ||
(context, index) { | ||
final activity = list[index]; | ||
return Padding( | ||
padding: | ||
EdgeInsets.only(bottom: index < list.length - 1 ? 20 : 0), | ||
child: ActivityEntry( | ||
key: ValueKey(activity.ref), | ||
activity: activity, | ||
selected: viewModel.selectedActivities.contains(activity.ref), | ||
onChanged: (value) { | ||
if (value!) { | ||
viewModel.addActivity(activity.ref); | ||
} else { | ||
viewModel.removeActivity(activity.ref); | ||
} | ||
}, | ||
), | ||
); | ||
}, | ||
childCount: list.length, | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit / nonblocking comment:
I've recently learned about UnmodifiableListView, and I think this is the perfect place to use it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will give it a try!