bool ValidateInput( ) { bool result = true; // Update the first name background color uint targetNameColor = ControlStylingConfig.BG_Layer_Color; if (string.IsNullOrEmpty(FirstName.Field.Text) /*&& UISwitchAnonymous.On == false*/) { targetNameColor = ControlStylingConfig.BadInput_BG_Layer_Color; result = false; } Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor(targetNameColor, FirstName.Background); // Update the LAST name background color uint targetLastNameColor = ControlStylingConfig.BG_Layer_Color; if (string.IsNullOrEmpty(LastName.Field.Text) /*&& UISwitchAnonymous.On == false*/) { targetLastNameColor = ControlStylingConfig.BadInput_BG_Layer_Color; result = false; } Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor(targetLastNameColor, LastName.Background); // Update the email background color uint targetEmailColor = ControlStylingConfig.BG_Layer_Color; if ((string.IsNullOrEmpty(Email.Field.Text) || Email.Field.Text.IsEmailFormat( ) == false) /*&& UISwitchAnonymous.On == false*/) { targetEmailColor = ControlStylingConfig.BadInput_BG_Layer_Color; result = false; } Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor(targetEmailColor, Email.Background); // Update the prayer background color uint targetPrayerColor = ControlStylingConfig.BG_Layer_Color; if (string.IsNullOrEmpty(PrayerRequest.Text) == true) { targetPrayerColor = ControlStylingConfig.BadInput_BG_Layer_Color; result = false; } Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor(targetPrayerColor, PrayerRequestLayer); // update the category int categoryId = RockLaunchData.Instance.Data.PrayerCategoryToId(CategoryButton.Title(UIControlState.Normal)); uint targetCategoryColor = ControlStylingConfig.BG_Layer_Color; if (categoryId == -1) { targetCategoryColor = ControlStylingConfig.BadInput_BG_Layer_Color; result = false; } Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor(targetCategoryColor, CategoryLayer); return(result); }
/// <summary> /// Builds a prayer request from data in the UI Fields and kicks off the post UI Control /// </summary> void SubmitPrayerRequest(object sender, EventArgs e) { if (PickerAdjustManager.Revealed == true) { OnToggleCategoryPicker(false); } else { // if first and last name are valid, OR anonymous is on // and if there's text in the request field. if (CheckDebug( ) == false) { if (ValidateInput( )) { Rock.Client.PrayerRequest prayerRequest = new Rock.Client.PrayerRequest(); EnableControls(false); prayerRequest.FirstName = FirstName.Field.Text; prayerRequest.LastName = LastName.Field.Text; prayerRequest.Email = Email.Field.Text; // see if there's a person alias ID to use. int?personAliasId = null; if (MobileApp.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId.HasValue) { personAliasId = MobileApp.Shared.Network.RockMobileUser.Instance.Person.PrimaryAliasId; } prayerRequest.Text = PrayerRequest.Text; prayerRequest.EnteredDateTime = DateTime.Now; prayerRequest.ExpirationDate = DateTime.Now.Add(PrivatePrayerConfig.PrayerExpirationTime); prayerRequest.CategoryId = RockLaunchData.Instance.Data.PrayerCategoryToId(CategoryButton.Title(UIControlState.Normal)); prayerRequest.IsActive = true; prayerRequest.IsPublic = UIPublicSwitch.On; // use the public switch's state to determine whether it's a public prayer or not. prayerRequest.Guid = Guid.NewGuid( ); prayerRequest.IsApproved = false; prayerRequest.CreatedByPersonAliasId = /*UISwitchAnonymous.On == true ? null :*/ personAliasId; // launch the post view controller Prayer_PostUIViewController postPrayerVC = new Prayer_PostUIViewController(); postPrayerVC.PrayerRequest = prayerRequest; Task.PerformSegue(this, postPrayerVC); } } } }