public override void ViewDidLoad() { base.ViewDidLoad(); RefreshProfileTimer = new System.Timers.Timer(); RefreshProfileTimer.AutoReset = true; RefreshProfileTimer.Interval = 300 * 1000; // every 5 minutes RefreshProfileTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { RefreshProfile( ); }); }; // setup the fake header HeaderView = new UIView( ); View.AddSubview(HeaderView); HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor); // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X) nfloat safeAreaTopInset = 0; // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11. if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top; } if (safeAreaTopInset == 0) { string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS; LogoView = new UIImageView(new UIImage(imagePath)); LogoView.SizeToFit( ); LogoView.Layer.AnchorPoint = CGPoint.Empty; HeaderView.AddSubview(LogoView); } ScrollView = new UIScrollViewWrapper(); View.AddSubview(ScrollView); ScrollView.Parent = this; BlockerView = new UIBlockerView(ScrollView, View.Bounds.ToRectF( )); //setup styles View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor); NickName = new StyledTextField(); ScrollView.AddSubview(NickName.Background); ControlStyling.StyleTextField(NickName.Field, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(NickName.Background); NickName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; NickName.Field.AutocorrectionType = UITextAutocorrectionType.No; NickName.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; LastName = new StyledTextField(); LastName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; LastName.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(LastName.Field, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(LastName.Background); LastName.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Email = new StyledTextField(); ScrollView.AddSubview(Email.Background); Email.Field.AutocapitalizationType = UITextAutocapitalizationType.None; Email.Field.AutocorrectionType = UITextAutocorrectionType.No; ScrollView.AddSubview(LastName.Background); ControlStyling.StyleTextField(Email.Field, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Email.Background); Email.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; CellPhone = new StyledTextField(); ScrollView.AddSubview(CellPhone.Background); CellPhone.Field.AutocapitalizationType = UITextAutocapitalizationType.None; CellPhone.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(CellPhone.Field, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(CellPhone.Background); CellPhone.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Street = new StyledTextField(); ScrollView.AddSubview(Street.Background); Street.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; Street.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(Street.Field, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Street.Background); Street.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; City = new StyledTextField(); ScrollView.AddSubview(City.Background); City.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; City.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(City.Field, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(City.Background); City.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; State = new StyledTextField(); ScrollView.AddSubview(State.Background); State.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; State.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(State.Field, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(State.Background); State.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Zip = new StyledTextField(); ScrollView.AddSubview(Zip.Background); Zip.Field.AutocapitalizationType = UITextAutocapitalizationType.None; Zip.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(Zip.Field, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Zip.Background); Zip.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; // Gender Gender = new StyledTextField(); ScrollView.AddSubview(Gender.Background); Gender.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField(Gender.Field, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Gender.Background); GenderButton = new UIButton( ); ScrollView.AddSubview(GenderButton); GenderButton.TouchUpInside += (object sender, EventArgs e) => { // don't allow multiple pickers if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { HideKeyboard( ); // if they have a gender selected, default to that. if (string.IsNullOrWhiteSpace(Gender.Field.Text) == false) { ((UIPickerView)GenderPicker.Picker).Select(RockLaunchData.Instance.Data.Genders.IndexOf(Gender.Field.Text) - 1, 0, false); } GenderPicker.TogglePicker(true); } }; // // Birthday Birthdate = new StyledTextField( ); ScrollView.AddSubview(Birthdate.Background); Birthdate.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField(Birthdate.Field, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Birthdate.Background); BirthdayButton = new UIButton( ); ScrollView.AddSubview(BirthdayButton); BirthdayButton.TouchUpInside += (object sender, EventArgs e) => { // don't allow multiple pickers if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { HideKeyboard( ); // setup the default date time to display DateTime initialDate = DateTime.Now; if (string.IsNullOrWhiteSpace(Birthdate.Field.Text) == false) { initialDate = DateTime.Parse(Birthdate.Field.Text); } ((UIDatePicker)BirthdatePicker.Picker).Date = initialDate.DateTimeToNSDate( ); BirthdatePicker.TogglePicker(true); } }; // // setup the home campus chooser HomeCampus = new StyledTextField( ); ScrollView.AddSubview(HomeCampus.Background); HomeCampus.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField(HomeCampus.Field, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(HomeCampus.Background); HomeCampusButton = new UIButton( ); ScrollView.AddSubview(HomeCampusButton); HomeCampusButton.TouchUpInside += (object sender, EventArgs e) => { UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SelectCampus_SourceTitle, ProfileStrings.SelectCampus_SourceDescription, UIAlertControllerStyle.ActionSheet); // if the device is a tablet, anchor the menu if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { actionSheet.PopoverPresentationController.SourceView = HomeCampusButton; actionSheet.PopoverPresentationController.SourceRect = HomeCampusButton.Bounds; } // for each campus, create an entry in the action sheet, and its callback will assign // that campus index to the user's viewing preference for (int i = 0; i < RockLaunchData.Instance.Data.Campuses.Count; i++) { UIAlertAction campusAction = UIAlertAction.Create(RockLaunchData.Instance.Data.Campuses[i].Name, UIAlertActionStyle.Default, delegate(UIAlertAction obj) { // update the home campus text and flag as dirty HomeCampus.Field.Text = obj.Title; Dirty = true; }); actionSheet.AddAction(campusAction); } // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction(cancelAction); PresentViewController(actionSheet, true, null); }; DoneButton = new UIButton( ); ScrollView.AddSubview(DoneButton); ControlStyling.StyleButton(DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); DoneButton.SizeToFit( ); LogoutButton = new UIButton( ); ScrollView.AddSubview(LogoutButton); LogoutButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal); LogoutButton.SetTitle(ProfileStrings.LogoutButtonTitle, UIControlState.Normal); LogoutButton.SizeToFit( ); // setup the pickers UILabel genderPickerLabel = new UILabel( ); ControlStyling.StyleUILabel(genderPickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); genderPickerLabel.Text = ProfileStrings.SelectGenderLabel; GenderPicker = new PickerAdjustManager(View, ScrollView, genderPickerLabel, Gender.Background); UIPickerView genderPicker = new UIPickerView(); genderPicker.Model = new GenderPickerModel() { Parent = this }; GenderPicker.SetPicker(genderPicker); UILabel birthdatePickerLabel = new UILabel( ); ControlStyling.StyleUILabel(birthdatePickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); birthdatePickerLabel.Text = ProfileStrings.SelectBirthdateLabel; BirthdatePicker = new PickerAdjustManager(View, ScrollView, birthdatePickerLabel, Birthdate.Background); UIDatePicker datePicker = new UIDatePicker(); datePicker.SetValueForKey(UIColor.White, new NSString("textColor")); datePicker.Mode = UIDatePickerMode.Date; datePicker.MinimumDate = new DateTime(1900, 1, 1).DateTimeToNSDate( ); datePicker.MaximumDate = DateTime.Now.DateTimeToNSDate( ); datePicker.ValueChanged += (object sender, EventArgs e) => { NSDate pickerDate = ((UIDatePicker)sender).Date; Birthdate.Field.Text = string.Format("{0:MMMMM dd yyyy}", pickerDate.NSDateToDateTime( )); }; BirthdatePicker.SetPicker(datePicker); // Allow the return on username and password to start // the login process NickName.Field.ShouldReturn += TextFieldShouldReturn; LastName.Field.ShouldReturn += TextFieldShouldReturn; Email.Field.ShouldReturn += TextFieldShouldReturn; // If submit is pressed with dirty changes, prompt the user to save them. DoneButton.TouchUpInside += (object sender, EventArgs e) => { // dont' allow changes while the profile is refreshing. if (RefreshingProfile == false) { if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { if (Dirty == true) { // make sure the input is valid before asking them what they want to do. if (ValidateInput( )) { // if there were changes, create an action sheet for them to confirm. UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SubmitChangesTitle, null, UIAlertControllerStyle.ActionSheet); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { actionSheet.PopoverPresentationController.SourceView = DoneButton; actionSheet.PopoverPresentationController.SourceRect = DoneButton.Bounds; } UIAlertAction submitAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Default, delegate { Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController(this, null); }); actionSheet.AddAction(submitAction); UIAlertAction noSubmitAction = UIAlertAction.Create(GeneralStrings.No, UIAlertActionStyle.Destructive, delegate { Dirty = false; Springboard.ResignModelViewController(this, null); }); actionSheet.AddAction(noSubmitAction); // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction(cancelAction); PresentViewController(actionSheet, true, null); } } else { Springboard.ResignModelViewController(this, null); } } else { GenderPicker.TogglePicker(false); BirthdatePicker.TogglePicker(false); Dirty = true; } } }; // On logout, make sure the user really wants to log out. LogoutButton.TouchUpInside += (object sender, EventArgs e) => { // don't allow changes while the profile is refreshing if (RefreshingProfile == false) { if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { // if they tap logout, and confirm it UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.LogoutTitle, null, UIAlertControllerStyle.ActionSheet); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { actionSheet.PopoverPresentationController.SourceView = LogoutButton; actionSheet.PopoverPresentationController.SourceRect = LogoutButton.Bounds; } UIAlertAction logoutAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate { // then log them out. RockMobileUser.Instance.LogoutAndUnbind( ); Springboard.ResignModelViewController(this, null); }); actionSheet.AddAction(logoutAction); // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction(cancelAction); PresentViewController(actionSheet, true, null); } else { GenderPicker.TogglePicker(false); BirthdatePicker.TogglePicker(false); Dirty = true; } } }; ResultView = new UIResultView(ScrollView, View.Bounds.ToRectF( ), delegate { Springboard.ResignModelViewController(this, null); }); Dirty = false; // logged in sanity check. if (RockMobileUser.Instance.LoggedIn == false) { throw new Exception("A user must be logged in before viewing a profile. How did you do this?"); } }
public override void ViewDidLoad() { base.ViewDidLoad(); // setup the fake header HeaderView = new UIView( ); View.AddSubview( HeaderView ); HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ); string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS; LogoView = new UIImageView( new UIImage( imagePath ) ); LogoView.SizeToFit( ); LogoView.Layer.AnchorPoint = CGPoint.Empty; HeaderView.AddSubview( LogoView ); ScrollView = new UIScrollViewWrapper(); View.AddSubview( ScrollView ); ScrollView.Parent = this; //setup styles View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ); NickName = new StyledTextField(); ScrollView.AddSubview( NickName.Background ); ControlStyling.StyleTextField( NickName.Field, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( NickName.Background ); NickName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; NickName.Field.AutocorrectionType = UITextAutocorrectionType.No; NickName.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; LastName = new StyledTextField(); LastName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; LastName.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( LastName.Field, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( LastName.Background ); LastName.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Email = new StyledTextField(); ScrollView.AddSubview( Email.Background ); Email.Field.AutocapitalizationType = UITextAutocapitalizationType.None; Email.Field.AutocorrectionType = UITextAutocorrectionType.No; ScrollView.AddSubview( LastName.Background ); ControlStyling.StyleTextField( Email.Field, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( Email.Background ); Email.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; CellPhone = new StyledTextField(); ScrollView.AddSubview( CellPhone.Background ); CellPhone.Field.AutocapitalizationType = UITextAutocapitalizationType.None; CellPhone.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( CellPhone.Field, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( CellPhone.Background ); CellPhone.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Street = new StyledTextField(); ScrollView.AddSubview( Street.Background ); Street.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; Street.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( Street.Field, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( Street.Background ); Street.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; City = new StyledTextField(); ScrollView.AddSubview( City.Background ); City.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; City.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( City.Field, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( City.Background ); City.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; State = new StyledTextField(); ScrollView.AddSubview( State.Background ); State.Field.AutocapitalizationType = UITextAutocapitalizationType.Words; State.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( State.Field, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( State.Background ); State.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; Zip = new StyledTextField(); ScrollView.AddSubview( Zip.Background ); Zip.Field.AutocapitalizationType = UITextAutocapitalizationType.None; Zip.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField( Zip.Field, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( Zip.Background ); Zip.Field.EditingDidBegin += (sender, e) => { Dirty = true; }; // Gender Gender = new StyledTextField(); ScrollView.AddSubview( Gender.Background ); Gender.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField( Gender.Field, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( Gender.Background ); GenderButton = new UIButton( ); ScrollView.AddSubview( GenderButton ); GenderButton.TouchUpInside += (object sender, EventArgs e ) => { // don't allow multiple pickers if( GenderPicker.Revealed == false && BirthdatePicker.Revealed == false ) { HideKeyboard( ); // if they have a gender selected, default to that. if( string.IsNullOrEmpty( Gender.Field.Text ) == false ) { ((UIPickerView)GenderPicker.Picker).Select( RockGeneralData.Instance.Data.Genders.IndexOf( Gender.Field.Text ) - 1, 0, false ); } GenderPicker.TogglePicker( true ); } }; // // Birthday Birthdate = new StyledTextField( ); ScrollView.AddSubview( Birthdate.Background ); Birthdate.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField( Birthdate.Field, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( Birthdate.Background ); BirthdayButton = new UIButton( ); ScrollView.AddSubview( BirthdayButton ); BirthdayButton.TouchUpInside += (object sender, EventArgs e ) => { // don't allow multiple pickers if( GenderPicker.Revealed == false && BirthdatePicker.Revealed == false ) { HideKeyboard( ); // setup the default date time to display DateTime initialDate = DateTime.Now; if( string.IsNullOrEmpty( Birthdate.Field.Text ) == false ) { initialDate = DateTime.Parse( Birthdate.Field.Text ); } ((UIDatePicker)BirthdatePicker.Picker).Date = initialDate.DateTimeToNSDate( ); BirthdatePicker.TogglePicker( true ); } }; // // setup the home campus chooser HomeCampus = new StyledTextField( ); ScrollView.AddSubview( HomeCampus.Background ); HomeCampus.Field.UserInteractionEnabled = false; ControlStyling.StyleTextField( HomeCampus.Field, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( HomeCampus.Background ); HomeCampusButton = new UIButton( ); ScrollView.AddSubview( HomeCampusButton ); HomeCampusButton.TouchUpInside += (object sender, EventArgs e ) => { UIAlertController actionSheet = UIAlertController.Create( ProfileStrings.SelectCampus_SourceTitle, ProfileStrings.SelectCampus_SourceDescription, UIAlertControllerStyle.ActionSheet ); // if the device is a tablet, anchor the menu if( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ) { actionSheet.PopoverPresentationController.SourceView = HomeCampusButton; actionSheet.PopoverPresentationController.SourceRect = HomeCampusButton.Bounds; } // for each campus, create an entry in the action sheet, and its callback will assign // that campus index to the user's viewing preference for( int i = 0; i < RockGeneralData.Instance.Data.Campuses.Count; i++ ) { UIAlertAction campusAction = UIAlertAction.Create( RockGeneralData.Instance.Data.Campuses[ i ].Name, UIAlertActionStyle.Default, delegate(UIAlertAction obj) { // update the home campus text and flag as dirty HomeCampus.Field.Text = obj.Title; Dirty = true; } ); actionSheet.AddAction( campusAction ); } // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create( GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction( cancelAction ); PresentViewController( actionSheet, true, null ); }; DoneButton = new UIButton( ); ScrollView.AddSubview( DoneButton ); ControlStyling.StyleButton( DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); DoneButton.SizeToFit( ); LogoutButton = new UIButton( ); ScrollView.AddSubview( LogoutButton ); LogoutButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ), UIControlState.Normal ); LogoutButton.SetTitle( ProfileStrings.LogoutButtonTitle, UIControlState.Normal ); LogoutButton.SizeToFit( ); // setup the pickers UILabel genderPickerLabel = new UILabel( ); ControlStyling.StyleUILabel( genderPickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); genderPickerLabel.Text = ProfileStrings.SelectGenderLabel; GenderPicker = new PickerAdjustManager( View, ScrollView, genderPickerLabel, Gender.Background ); UIPickerView genderPicker = new UIPickerView(); genderPicker.Model = new GenderPickerModel() { Parent = this }; GenderPicker.SetPicker( genderPicker ); UILabel birthdatePickerLabel = new UILabel( ); ControlStyling.StyleUILabel( birthdatePickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); birthdatePickerLabel.Text = ProfileStrings.SelectBirthdateLabel; BirthdatePicker = new PickerAdjustManager( View, ScrollView, birthdatePickerLabel, Birthdate.Background ); UIDatePicker datePicker = new UIDatePicker(); datePicker.SetValueForKey( UIColor.White, new NSString( "textColor" ) ); datePicker.Mode = UIDatePickerMode.Date; datePicker.MinimumDate = new DateTime( 1900, 1, 1 ).DateTimeToNSDate( ); datePicker.MaximumDate = DateTime.Now.DateTimeToNSDate( ); datePicker.ValueChanged += (object sender, EventArgs e ) => { NSDate pickerDate = ((UIDatePicker) sender).Date; Birthdate.Field.Text = string.Format( "{0:MMMMM dd yyyy}", pickerDate.NSDateToDateTime( ) ); }; BirthdatePicker.SetPicker( datePicker ); // Allow the return on username and password to start // the login process NickName.Field.ShouldReturn += TextFieldShouldReturn; LastName.Field.ShouldReturn += TextFieldShouldReturn; Email.Field.ShouldReturn += TextFieldShouldReturn; // If submit is pressed with dirty changes, prompt the user to save them. DoneButton.TouchUpInside += (object sender, EventArgs e) => { if( GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { if( Dirty == true ) { // make sure the input is valid before asking them what they want to do. if ( ValidateInput( ) ) { // if there were changes, create an action sheet for them to confirm. UIAlertController actionSheet = UIAlertController.Create( ProfileStrings.SubmitChangesTitle, null, UIAlertControllerStyle.ActionSheet ); if( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ) { actionSheet.PopoverPresentationController.SourceView = DoneButton; actionSheet.PopoverPresentationController.SourceRect = DoneButton.Bounds; } UIAlertAction submitAction = UIAlertAction.Create( GeneralStrings.Yes, UIAlertActionStyle.Default, delegate { Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController( this, null ); }); actionSheet.AddAction( submitAction ); UIAlertAction noSubmitAction = UIAlertAction.Create( GeneralStrings.No, UIAlertActionStyle.Destructive, delegate { Dirty = false; Springboard.ResignModelViewController( this, null ); }); actionSheet.AddAction( noSubmitAction ); // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create( GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction( cancelAction ); PresentViewController( actionSheet, true, null ); } } else { Springboard.ResignModelViewController( this, null ); } } else { GenderPicker.TogglePicker( false ); BirthdatePicker.TogglePicker( false ); Dirty = true; } }; // On logout, make sure the user really wants to log out. LogoutButton.TouchUpInside += (object sender, EventArgs e) => { if( GenderPicker.Revealed == false && BirthdatePicker.Revealed == false) { // if they tap logout, and confirm it UIAlertController actionSheet = UIAlertController.Create( ProfileStrings.LogoutTitle, null, UIAlertControllerStyle.ActionSheet ); if( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ) { actionSheet.PopoverPresentationController.SourceView = LogoutButton; actionSheet.PopoverPresentationController.SourceRect = LogoutButton.Bounds; } UIAlertAction logoutAction = UIAlertAction.Create( GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate { // then log them out. RockMobileUser.Instance.LogoutAndUnbind( ); Springboard.ResignModelViewController( this, null ); }); actionSheet.AddAction( logoutAction ); // let them cancel, too UIAlertAction cancelAction = UIAlertAction.Create( GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { }); actionSheet.AddAction( cancelAction ); PresentViewController( actionSheet, true, null ); } else { GenderPicker.TogglePicker( false ); BirthdatePicker.TogglePicker( false ); Dirty = true; } }; Dirty = false; // logged in sanity check. if( RockMobileUser.Instance.LoggedIn == false ) throw new Exception("A user must be logged in before viewing a profile. How did you do this?" ); }
public static UIDatePicker SetPrimaryDatePickerStyle(this UIDatePicker picker) { picker.SetValueForKey(AppColors.LightBlueColor, new NSString("textColor")); return(picker); }