/// <summary> /// Loads current lunches. /// </summary> private async Task Initialize() { var lunches = await App.Api.GetAsync <IEnumerable <Lunch> >("Lunch"); if (null != lunches && lunches.Any()) { await DispatchHelper.RunAsync(() => { NoLunchesStringVisibility = Visibility.Collapsed; lunches.ForEach(x => Lunches.Add(x)); }); } }
/// <summary> /// Creates a new WelcomeViewModel with the default OOBE items. /// </summary> public WelcomeViewModel() { WelcomeItems = new ObservableCollection <WelcomeItem>(new[] { new WelcomeItem( "Welcome to Lunch Scheduler", "The easiest way to organize lunch with your friends, family, or coworkers.", ImageBase + "Lunchbox.png"), new WelcomeItem( "Organizing made easy", "Hungry? Avoid endless back-and-forth emails or texts. Simply tap 'New Lunch' " + "on the main menu and pick a who, where, and when. We'll take care of the rest.", ImageBase + "Plate.png"), new WelcomeItem( "Discover local delights", "When you're scheduling a new lunch, Lunch Scheduler can use your current location to " + "suggest tasty restaurants nearby.", ImageBase + "Location.png", async() => await DispatchHelper.RunAsync(async() => await Geolocator.RequestAccessAsync())), new WelcomeItem( "Get signed up", "To keep track of everything, you'll need an account with Lunch Scheduler. You can log in " + "with an existing Microsoft, Google, or Facebook account. Lunch Scheduler will never post " + "to your wall or send you unsolicted email. And there's no extra passwords to remember.", ImageBase + "Keys.png", AccountsSettingsPane.Show), new WelcomeItem( "Be notified", "Invited to lunch? We'll let you know with a push notification or text message." + " You can see the location and who's invited before you RSVP.", ImageBase + "Notification.png", async() => await new PhoneSignUpDialog().ShowAsync()), new WelcomeItem( "Good to go!", "You're all set! Enjoy lunching!", ImageBase + "Check.png", () => Window.Current.Content = new Views.Shell()), new WelcomeItem("", "", "") }); SelectedWelcomeItem = WelcomeItems[0]; }
/// <summary> /// Shows the add friend dialog to add a friend. /// </summary> public async void AddFriend() { await DispatchHelper.RunAsync(async() => { var dialog = new AddFriendDialog(); dialog.FriendAdded += async(s, e) => { var friend = await App.Api.GetAsync <User>("Users", new { Email = e }); if (null != friend) { Friends.Add(friend); } }; await dialog.ShowAsync(); }); }
/// <summary> /// Invokes a command when the user navigates from a welcome item. /// </summary> private async void OnSelectedWelcomeItemChanged() { IsEnabled = false; if (null != WelcomeItems) { int index = WelcomeItems.IndexOf(SelectedWelcomeItem) - 1; if (index >= 0 && null != WelcomeItems[index]?.OnNavigatedFrom) { WelcomeItems[index].OnNavigatedFrom(); } ChangeFontSize(); await Task.Run(async() => { await Task.Delay(1000); await DispatchHelper.RunAsync(() => IsEnabled = true); }); } }
/// <summary> /// Loads possible lunch locations based on the user's current location. /// </summary> private async Task Initialize() { await DispatchHelper.RunAsync(async() => { var restaurants = new List <Location> { new Location { Name = "Custom", ImageUrl = @"ms-appx:///Assets/Plus.png" } }; if (await Geolocator.RequestAccessAsync() == GeolocationAccessStatus.Allowed) { var location = await new Geolocator().GetGeopositionAsync(); var nearby = await App.Api.GetAsync <IEnumerable <Location> >("Locations", new { location.Coordinate.Point.Position.Longitude, location.Coordinate.Point.Position.Latitude }); restaurants.AddRange(nearby); } restaurants.ForEach(x => Locations.Add(x)); }); }
/// <summary> /// Shows the phone notification registration dialog. /// </summary> public async void RegisterPhone() => await DispatchHelper.RunAsync( async() => await new PhoneSignUpDialog().ShowAsync());