private void Feed() { ProfileModel profile = ProfileManager.Instance.CurrentProfile; if (null == profile) { return; } if (profile.HasBabies) { if (1 == profile.Babies.Count) { PageManager.Me.SetCurrentPage(typeof(BottleFeedSelectionPage)); } else { PageManager.Me.SetCurrentPage(typeof(SelectChildPage), view => { (view as SelectChildPage).NextPageType = typeof(BottleFeedSelectionPage); }); } } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } }
/// <summary> /// Performs the actual signin to the cloud /// </summary> /// <returns></returns> async Task <bool> OnSignIn() { bool signedIn = false; try { if (!await LoginManager.Instance.Authenticator.Authenticate(Provider.Custom, EntryEmail.Text, EntryPassword.Text)) { EntryPassword.Text = string.Empty; IconPasswordChecked.IsVisible = false; ModalAlertPage.ShowAlertWithClose(AppResource.AuthenticationFailure); } else { await LoginManager.Instance.GetUserInfo(); signedIn = true; } } catch (Exception ex) { AnalyticsManager.Instance.TrackError(ex); } return(signedIn); }
private async Task <bool> CheckSoftware() { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsPickPhotoSupported || !CrossMedia.Current.IsPickVideoSupported) { ModalAlertPage.ShowAlertWithClose(AppResource.PhotoPermissionsDenied); return(false); } return(true); }
private async Task <bool> CheckHardware() { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { ModalAlertPage.ShowAlertWithClose(AppResource.NoCamera); return(false); } return(true); }
private void SelectChildToFeedAction(Type nextPage) { if (ProfileManager.Instance.CurrentProfile.Babies != null) { PageManager.Me.SetCurrentPage(typeof(SelectChildPage), view => { (view as SelectChildPage).NextPageType = nextPage; }); } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } }
void AddSession() { if (null == ProfileManager.Instance.CurrentProfile) { return; } if (ProfileManager.Instance.CurrentProfile.HasBabies) { PageManager.Me.SetCurrentPage(typeof(AddSessionPage)); } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } }
/// <summary> /// Constructor -- Initialize the model and binds buttons events and other ui actions /// </summary> public ChangePasswordPage() { InitializeComponent(); Titlebar.IsVisible = true; LeftPageType = typeof(ProfilePage); Titlebar.LeftButton.IsVisible = true; Titlebar.LeftButton.SetDynamicResource(StyleProperty, "CancelButton"); BindingContext = _model = new ChangePasswordModel(); GridPassConditions.BindingContext = _passModel = new PasswordConditionsModel(); EntryPasswordCurrent.Focused += PasswordEntry_Focused; EntryPasswordCurrent.Unfocused += PasswordEntry_Unfocused; EntryPasswordCurrent.TextChanged += (s, e) => ValidatePassword(EntryPasswordCurrent, IconPasswordCheckedCurrent); EntryPasswordNew.Focused += PasswordEntry_Focused; EntryPasswordNew.Unfocused += PasswordEntry_Unfocused; EntryPasswordNew.TextChanged += (s, e) => ValidatePassword(EntryPasswordNew, IconPasswordCheckedNew); BtnSave.Clicked += async(sender, args) => { if (!_model.IsPasswordInvalid) { BusyIndicator.IsRunning = true; if (await LoginManager.Instance.ChangePassword(EntryPasswordCurrent.Text, EntryPasswordNew.Text)) { PageManager.Me.SetCurrentPage(typeof(SignUpPage)); } else { ModalAlertPage.ShowAlertWithClose(AppResource.CurrentPasswordIncorrect); _model.IsPasswordInvalid = true; } BusyIndicator.IsRunning = false; } }; }
private async void SendEmailAsync() { if (ViewModel.IsEmailSending) { return; } ViewModel.IsEmailSending = true; bool success = await LoginManager.Instance.ForgotPassword(ViewModel.Text); ViewModel.IsEmailSending = false; if (success) { ShowSavedOverlay(); } else { ViewModel.IsEmailValid = false; ModalAlertPage.ShowAlertWithClose(AppResource.InvalidEntry); } }
private async void SaveCodeAsync() { if (ViewModel.IsCodeSending) { return; } ViewModel.IsCodeSending = true; string message = await ProfileManager.Instance.VerifyCaregiverCode(ViewModel.Text); ViewModel.IsCodeSending = false; if (String.IsNullOrEmpty(message)) { ShowSavedOverlay(); } else { //ModalAlertPage.ShowAlertWithClose(AppResource.InvalidEntry); ModalAlertPage.ShowAlertWithClose(message); } }
private async Task <bool> CheckPermissions() { var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera); var mediaStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.MediaLibrary); var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); var photoStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Photos); if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted || mediaStatus != PermissionStatus.Granted || photoStatus != PermissionStatus.Granted) { var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage, Permission.MediaLibrary, Permission.Photos }); cameraStatus = results[Permission.Camera]; storageStatus = results[Permission.Storage]; mediaStatus = results[Permission.MediaLibrary]; photoStatus = results[Permission.Photos]; } if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted && mediaStatus == PermissionStatus.Granted && photoStatus == PermissionStatus.Granted) { return(true); } else { ModalAlertPage.ShowAlertWithClose(AppResource.CameraPermissionsDenied); return(false); } //await DisplayAlert("Permissions Denied", "Unable to take photos.", "OK"); //On iOS you may want to send your user to the settings screen. //CrossPermissions.Current.OpenAppSettings(); }
/// <summary> /// Constructor -- Initialize the model and binds buttons events and other ui actions /// </summary> public SignUpViaEmailPage() { InitializeComponent(); Title = AppResource.CreateAccount.ToUpper(); Resources = Application.Current.Resources; var model = new SignupViaEmailModel(); BindingContext = model; var checkInputStatus = new Action(() => { model.ReadyToSignup = IconEmailChecked.IsVisible && IconPasswordChecked.IsVisible; }); EntryEmail.TextChanged += (s, e) => { IconEmailChecked.IsVisible = InputValidator.IsValidEmail(EntryEmail.Text.Trim()); checkInputStatus(); }; _passModel.Reset(); GridPassConditions.BindingContext = _passModel; EntryPassword.Focused += (sender, args) => { GridPassConditions.IsVisible = args.IsFocused && !_passModel.AllCriteriaMet; }; EntryPassword.Unfocused += (sender, args) => { GridPassConditions.IsVisible = args.IsFocused; }; EntryPassword.TextChanged += (s, e) => { String pass = EntryPassword.Text; if (String.IsNullOrEmpty(pass)) { _passModel.Reset(); } else { _passModel.FlagChars = pass.ContainsChar(2); _passModel.FlagDigits = pass.ContainsDigit(2); _passModel.FlagSymbols = pass.ContainsSymbol(); _passModel.FlagLength = pass.Length >= 8; } IconPasswordChecked.IsVisible = _passModel.AllCriteriaMet; if (EntryPassword.IsFocused) { GridPassConditions.IsVisible = !_passModel.AllCriteriaMet; } checkInputStatus(); }; BtnSignup.Clicked += async(s, e) => { if (model.ReadyToSignup) { BusyIndicator.IsRunning = true; bool signupSuccess = await LoginManager.Instance.SignUpPage(EntryEmail.Text, EntryPassword.Text); if (signupSuccess) { await LoginManager.Instance.Authenticator.Authenticate(Provider.Custom, EntryEmail.Text, EntryPassword.Text); if (!string.IsNullOrEmpty(LoginManager.Instance.UserId)) { await DataManager.Instance.SetNewUser(LoginManager.Instance.UserId); PageManager.Me.SetCurrentPage(typeof(TermsAndConditionsPage)); } else { ModalAlertPage.ShowAlertWithClose("Sign up success but authentication failed."); } } else { ModalAlertPage.ShowAlertWithClose("User already exists."); } BusyIndicator.IsRunning = false; } }; Titlebar.IsVisible = true; Titlebar.LeftButton.IsVisible = true; Titlebar.LeftButton.SetDynamicResource(StyleProperty, "CancelButton"); LeftPageType = typeof(SignUpPage); }
/// <summary> /// Constructor -- Initialize the model and binds buttons events and other ui actions /// </summary> public NurseSessionLogPage() { InitializeComponent(); // Moved from AddSession page. if (null == HistorySession) { HistorySession = HistoryManager.Instance.CreateSession(SessionType.Nurse); } BtnAddNote.CornerRadius = 1; _btnGroup.AddButton(BtnLeft); _btnGroup.AddButton(BtnRight); _btnGroup.Toggled += (sender, item, index) => { PullDataFromModel(item); }; ViewModel = new NurseSessionLogModel(ShowNotepad) { NotReadyToSave = true, ShowSavedPopupPage = false }; BindingContext = ViewModel; _updateTime = new Action(() => { if (HistorySession != null) { try { if (NurseStartTime.Time.HasValue) { HistorySession.LeftBreastStartTime = _selectedDate + _selectedStartTime; HistorySession.RightBreastStartTime = _selectedDate + _selectedStartTime; TotalCount(); ViewModel.NotReadyToSave = false; } else { TotalCount(); } if (NurseTotalTime.Time.HasValue) { if (!String.IsNullOrEmpty(ParseTime(ViewModel.FirstTime))) { if (TimeSpan.TryParseExact(ViewModel.FirstTime, @"mm\:ss", null, out TimeSpan resultTime)) { HistorySession.LeftBreastEndTime = HistorySession.LeftBreastStartTime + resultTime; } } if (!String.IsNullOrEmpty(ParseTime(ViewModel.LastTime))) { if (TimeSpan.TryParseExact(ViewModel.LastTime, @"mm\:ss", null, out TimeSpan resultTime)) { HistorySession.RightBreastEndTime = HistorySession.RightBreastStartTime + resultTime; } } } ResolveNurseStartTimeFormat(); } catch (Exception ex) { Debugger.Break(); NurseTotalTime.Time = TimeSpan.FromMinutes(0); } //if (_btnGroup.CurrentButton != null) //{ // if (NurseStartTime.Time.HasValue) // { // HistorySession.LeftBreastStartTime = _selectedDate + _selectedStartTime; // HistorySession.RightBreastStartTime = _selectedDate + _selectedStartTime; // } // if (NurseTotalTime.Time.HasValue) // { // try // { // //string[] parts = LblDuraPicker.Text.Split(new string[] {":"}, // // StringSplitOptions.RemoveEmptyEntries); // //if (parts.Length >= 2) // //{ // // if (_btnGroup.CurrentButton == BtnLeft) // // { // // HistorySession.LeftBreastEndTime = // // HistorySession.LeftBreastStartTime.AddHours(Convert.ToInt32(parts[0])); // // HistorySession.LeftBreastEndTime = HistorySession.LeftBreastEndTime.AddMinutes(Convert.ToInt32(parts[1])); // // model.NotReadyToSave = false; // // } // // else if (_btnGroup.CurrentButton == BtnRight) // // { // // HistorySession.RightBreastEndTime = // // HistorySession.RightBreastStartTime.AddHours(Convert.ToInt32(parts[0])); // // HistorySession.RightBreastEndTime = HistorySession.RightBreastEndTime.AddMinutes(Convert.ToInt32(parts[1])); // // model.NotReadyToSave = false; // // } // //} // } // catch // { // } // } //} } }); NurseDate.CalendarDate = DateTime.Now; NurseDate.ValidationFunc = (dateToValidate) => { if (dateToValidate > DateTime.Now.Date) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } if (dateToValidate + _selectedStartTime >= DateTime.Now) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } if (NurseTotalTime.Time.HasValue) { try { var date = dateToValidate + _selectedStartTime; date = date.AddHours(NurseTotalTime.Time.Value.Hours); date = date.AddMinutes(NurseTotalTime.Time.Value.Minutes); if (date >= DateTime.Now) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } } catch { return(false); } } return(true); }; NurseDate.AfterAction = () => { _selectedDate = NurseDate.Date.Value; _updateTime(); }; NurseStartTime.ValidationFunc = timeValidate => { if (_selectedDate + timeValidate >= DateTime.Now) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } if (NurseTotalTime.Time.HasValue) { try { var date = NurseDate.Date.Value + timeValidate; date = date.AddHours(NurseTotalTime.Time.Value.Hours); date = date.AddMinutes(NurseTotalTime.Time.Value.Minutes); if (date >= DateTime.Now) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } } catch { return(false); } } return(true); }; NurseStartTime.AfterAction = () => { _selectedStartTime = NurseStartTime.Time.Value; _updateTime(); }; NurseTotalTime.ValidationFunc = timeValidate => { if (NurseStartTime.Time.HasValue) { var date = _selectedDate + _selectedStartTime; date = date.AddHours(timeValidate.Hours); date = date.AddMinutes(timeValidate.Minutes); if (date >= DateTime.Now) { ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime); return(false); } } return(true); }; NurseTotalTime.AfterAction = () => { _updateTime(); }; BtnSave.Clicked += (s, e) => { if (_historyModel != null) { if (null != ProfileManager.Instance?.CurrentProfile?.CurrentBaby) { _historyModel.ChildID = ProfileManager.Instance.CurrentProfile.CurrentBaby.Id; _historyModel.ChildName = ProfileManager.Instance.CurrentProfile.CurrentBaby.Name; HistoryManager.Instance.AddSession(_historyModel); } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } } ViewModel.ShowSavedPopupPage = true; //UpdateTitlebarInfo(false, Color.FromHex("#11442B")); _timer.Enable = true; _timer.Start(() => { PageManager.Me.SetCurrentPage(typeof(DashboardTabPage)); return(false); }); }; Titlebar.IsVisible = true; LeftPageType = typeof(DashboardTabPage); Titlebar.LeftButton.IsVisible = true; Titlebar.LeftButton.SetDynamicResource(StyleProperty, "CancelButton"); NurseTotalTime.Time = TimeSpan.FromMinutes(0); }
/// <summary> /// Constructor -- Initialize the model and binds buttons events and other ui actions /// </summary> public DashboardDetailView() { InitializeComponent(); Title = ""; Titlebar.IsVisible = true; _rl1.SizeChanged += ONRL1_SizeChanged; listView.ItemsSource = new ListViewList <ExperienceModel>(ExperienceManager.Instance.AllExperiences); listView.ItemSelected += (s, e) => { if (e.SelectedItem != null) { var selectedItem = (ExperienceModel)e.SelectedItem; if (selectedItem != null) { ExperienceManager.Instance.CurrentExperience = selectedItem; } } }; BtnPumpSession.Clicked += (s, e) => { //#if MOCKEDPUMPING PumpManager.Instance.ConnectedPump = new PumpModel(); //#endif if (PumpManager.Instance.ConnectedPump == null) { ModalAlertPage.ShowAlertWithClose( "We couldn’t find your pump! Please make sure you are in range and that your pump is charged or plugged in."); return; } PageManager.Me.SetCurrentPage(typeof(PumpSessionPage)); }; BtnFeedSession.Clicked += (s, e) => { if (null == ProfileManager.Instance.CurrentProfile) { return; } if (0 < (ProfileManager.Instance.CurrentProfile.Babies?.Count ?? 0)) { if (1 == ProfileManager.Instance.CurrentProfile.Babies.Count) { PageManager.Me.SetCurrentPage(typeof(BottleFeedSelectionPage)); } else { PageManager.Me.SetCurrentPage(typeof(SelectChildPage), view => { (view as SelectChildPage).NextPageType = typeof(BottleFeedSelectionPage); }); } } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } }; BtnNurseSession.Clicked += (s, e) => { if (null == ProfileManager.Instance.CurrentProfile) { return; } if (0 < (ProfileManager.Instance.CurrentProfile.Babies?.Count ?? 0)) { if (1 == ProfileManager.Instance.CurrentProfile.Babies.Count) { PageManager.Me.SetCurrentPage(typeof(NurseSessionSelectionPage)); } else { PageManager.Me.SetCurrentPage(typeof(SelectChildPage), view => { (view as SelectChildPage).NextPageType = typeof(NurseSessionSelectionPage); }); } } else { ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError); } }; PumpConnect.Clicked += (s, e) => { PageManager.Me.SetCurrentPage(typeof(PumpAdditionPage), view => { (view as PumpAdditionPage).IsFirstTimeFlow = false; }); }; PumpManager.Instance.NewPumps.CollectionChanged += (sender, args) => { try { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { RefreshTitlebar(); }); } catch (Exception e) { Debug.WriteLine("Exeption: " + e.Message); } }; PumpManager.Instance.PumpConnectedEvent += (sender, args) => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { RefreshTitlebar(); }); }; PumpManager.Instance.PumpDisconnectedEvent += (sender, args) => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { RefreshTitlebar(); }); }; }