Skip to content
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

Create Hikes immediately #83

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/components/create_join_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ class CreateJoinBeaconDialog {
model.startingTime.minute,
);
// localNotif.scheduleNotification();
if (model.startsAt.isBefore(DateTime.now())) {
navigationService.showSnackBar(
"Enter a valid date and time!!");
if (model.startsAt.isBefore(DateTime.now()
.subtract(Duration(minutes: 1)))) {
navigationService
.showSnackBar("Enter a valid date and time!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of snack bar, I guess it would be better to add validations in the fields itself. When keyboard is on snackbar popups aren't displayed well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! So should I close the keyboard upon this error and then show snackbar or validate the field itself?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validating fields would be better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any progress? @ItsAdityaKSingh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite! Got busy in academics. Gonna run through the required changes requested and update soon :)

return;
}
model.createHikeRoom();
Expand Down
21 changes: 12 additions & 9 deletions lib/view_model/home_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ class HomeViewModel extends BaseModel {
hasStarted = DateTime.now()
.isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt));
if (hasStarted) {
navigationService.pushScreen('/hikeScreen',
arguments: HikeScreen(
beacon,
isLeader: true,
));
navigationService.pushScreen(
'/hikeScreen',
arguments: HikeScreen(
beacon,
isLeader: true,
),
);
} else {
localNotif.scheduleNotification(beacon);
setState(ViewState.idle);
navigationService.showSnackBar(
'Beacon has not yet started! Please come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt)).toString()}',
'Yay! New beacon created for ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt)).toString()}',
);
return;
}
Expand All @@ -74,10 +76,11 @@ class HomeViewModel extends BaseModel {
if (beacon != null) {
hasStarted = DateTime.now()
.isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt));

if (hasStarted) {
navigationService.pushScreen('/hikeScreen',
arguments: HikeScreen(beacon, isLeader: false));
navigationService.pushScreen(
'/hikeScreen',
arguments: HikeScreen(beacon, isLeader: false),
);
} else {
localNotif.scheduleNotification(beacon);
setState(ViewState.idle);
Expand Down