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 all 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
5 changes: 3 additions & 2 deletions lib/components/create_join_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ class CreateJoinBeaconDialog {
model.startingTime.minute,
);
// localNotif.scheduleNotification();
if (model.startsAt.isBefore(DateTime.now())) {
if (model.startsAt.isBefore(DateTime.now()
.subtract(Duration(minutes: 1)))) {
navigationService.showSnackBar(
"Enter a valid date and time!!");
"Enter a valid date and time!");
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! \nPlease 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