public override void ViewDidLoad() { base.ViewDidLoad(); // set the background view to black so we don't get white aliasing flicker during // the pan View.BackgroundColor = UIColor.Black; View.Layer.AnchorPoint = CGPoint.Empty; // scroll view ScrollView = new UIScrollViewWrapper( ); ScrollView.Layer.AnchorPoint = CGPoint.Empty; ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ); ScrollView.Parent = this; View.AddSubview( ScrollView ); // create our keyboard adjustment manager, which works to make sure text fields scroll into visible // range when a keyboard appears KeyboardAdjustManager = new Rock.Mobile.PlatformSpecific.iOS.UI.KeyboardAdjustManager( View ); // setup the First Name field FirstName = new StyledTextField(); ScrollView.AddSubview( FirstName.Background ); ControlStyling.StyleTextField( FirstName.Field, PrayerStrings.CreatePrayer_FirstNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( FirstName.Background ); LastName = new StyledTextField(); ScrollView.AddSubview( LastName.Background ); ControlStyling.StyleTextField( LastName.Field, PrayerStrings.CreatePrayer_LastNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ControlStyling.StyleBGLayer( LastName.Background ); PrayerRequestLayer = new UIView(); ScrollView.AddSubview( PrayerRequestLayer ); PrayerRequestPlaceholder = new UILabel(); PrayerRequestLayer.AddSubview( PrayerRequestPlaceholder ); PrayerRequest = new UITextView(); PrayerRequestLayer.AddSubview( PrayerRequest ); // setup the prayer request field, which requires a fake "placeholder" text field PrayerRequest.Delegate = new KeyboardAdjustManager.TextViewDelegate( ); PrayerRequest.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); PrayerRequest.TextContainerInset = UIEdgeInsets.Zero; PrayerRequest.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); PrayerRequest.TextContainer.LineFragmentPadding = 0; PrayerRequest.BackgroundColor = UIColor.Clear; PrayerRequest.Editable = true; PrayerRequest.KeyboardAppearance = UIKeyboardAppearance.Dark; PrayerRequestPlaceholder.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ); PrayerRequestPlaceholder.BackgroundColor = UIColor.Clear; PrayerRequestPlaceholder.Text = PrayerStrings.CreatePrayer_PrayerRequest; PrayerRequestPlaceholder.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); //PrayerRequestPlaceholder.SizeToFit( ); ControlStyling.StyleBGLayer( PrayerRequestLayer ); // category layer CategoryLayer = new UIView(); ScrollView.AddSubview( CategoryLayer ); CategoryButton = new UIButton(); CategoryLayer.AddSubview( CategoryButton ); // setup the category picker and selector button UILabel categoryLabel = new UILabel( ); ControlStyling.StyleUILabel( categoryLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); categoryLabel.Text = PrayerStrings.CreatePrayer_SelectCategoryLabel; PickerAdjustManager = new PickerAdjustManager( View, ScrollView, categoryLabel, CategoryLayer ); UIPickerView pickerView = new UIPickerView(); pickerView.Model = new CategoryPickerModel() { Parent = this }; pickerView.UserInteractionEnabled = true; PickerAdjustManager.SetPicker( pickerView ); // setup a tap gesture for the picker Action action = ( ) => { OnToggleCategoryPicker( false ); }; UITapGestureRecognizer uiTap = new UITapGestureRecognizer( action ); uiTap.NumberOfTapsRequired = 1; pickerView.AddGestureRecognizer( uiTap ); uiTap.Delegate = this; CategoryButton.TouchUpInside += (object sender, EventArgs e ) => { OnToggleCategoryPicker( true ); }; CategoryButton.SetTitle( PrayerStrings.CreatePrayer_CategoryButtonText, UIControlState.Normal ); CategoryButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ), UIControlState.Normal ); CategoryButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CategoryButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; ControlStyling.StyleBGLayer( CategoryLayer ); // preference switches SwitchBackground = new UIView(); ScrollView.AddSubview( SwitchBackground ); ControlStyling.StyleBGLayer( SwitchBackground ); UIPublicSwitch = new UISwitch(); SwitchBackground.AddSubview( UIPublicSwitch ); MakePublicLabel = new UILabel(); SwitchBackground.AddSubview( MakePublicLabel ); //MakePublicLabel.TextColor = UIColor.White; UISwitchAnonymous = new UISwitch(); SwitchBackground.AddSubview( UISwitchAnonymous ); PostAnonymouslyLabel = new UILabel(); SwitchBackground.AddSubview( PostAnonymouslyLabel ); //PostAnonymouslyLabel.TextColor = UIColor.White; // Setup the anonymous switch PostAnonymouslyLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); PostAnonymouslyLabel.Text = PrayerStrings.CreatePrayer_PostAnonymously; PostAnonymouslyLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); UISwitchAnonymous.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor ); UISwitchAnonymous.TouchUpInside += (object sender, EventArgs e ) => { OnToggleCategoryPicker( false ); if( UISwitchAnonymous.On == true ) { FirstName.Field.Enabled = false; FirstName.Field.Text = PrayerStrings.CreatePrayer_Anonymous; LastName.Field.Enabled = false; LastName.Field.Text = PrayerStrings.CreatePrayer_Anonymous; } else { FirstName.Field.Enabled = true; FirstName.Field.Text = string.Empty; LastName.Field.Enabled = true; LastName.Field.Text = string.Empty; } // reset the background colors Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, FirstName.Background ); Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, LastName.Background ); }; // setup the public switch MakePublicLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); MakePublicLabel.Text = PrayerStrings.CreatePrayer_MakePublic; MakePublicLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); UIPublicSwitch.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor ); //UIPublicSwitch.ThumbTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); // setup the submit button SubmitButton = UIButton.FromType( UIButtonType.Custom ); ScrollView.AddSubview( SubmitButton ); ControlStyling.StyleButton( SubmitButton, PrayerStrings.CreatePrayer_SubmitButtonText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); SubmitButton.SizeToFit( ); SubmitButton.TouchUpInside += SubmitPrayerRequest; }
public override void ViewDidLoad() { base.ViewDidLoad(); // set the background view to black so we don't get white aliasing flicker during // the pan View.BackgroundColor = UIColor.Black; View.Layer.AnchorPoint = CGPoint.Empty; // scroll view ScrollView = new UIScrollViewWrapper( ); ScrollView.Layer.AnchorPoint = CGPoint.Empty; ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor); ScrollView.Parent = this; View.AddSubview(ScrollView); // create our keyboard adjustment manager, which works to make sure text fields scroll into visible // range when a keyboard appears KeyboardAdjustManager = new Rock.Mobile.PlatformSpecific.iOS.UI.KeyboardAdjustManager(View); // setup the First Name field FirstName = new StyledTextField(); ScrollView.AddSubview(FirstName.Background); ControlStyling.StyleTextField(FirstName.Field, PrayerStrings.CreatePrayer_FirstNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(FirstName.Background); LastName = new StyledTextField(); ScrollView.AddSubview(LastName.Background); ControlStyling.StyleTextField(LastName.Field, PrayerStrings.CreatePrayer_LastNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(LastName.Background); Email = new StyledTextField(); ScrollView.AddSubview(Email.Background); Email.Field.AutocapitalizationType = UITextAutocapitalizationType.None; Email.Field.AutocorrectionType = UITextAutocorrectionType.No; ControlStyling.StyleTextField(Email.Field, PrayerStrings.CreatePrayer_EmailPlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ControlStyling.StyleBGLayer(Email.Background); PrayerRequestLayer = new UIView(); ScrollView.AddSubview(PrayerRequestLayer); PrayerRequestPlaceholder = new UILabel(); PrayerRequestLayer.AddSubview(PrayerRequestPlaceholder); PrayerRequest = new UITextView(); PrayerRequestLayer.AddSubview(PrayerRequest); // setup the prayer request field, which requires a fake "placeholder" text field PrayerRequest.Delegate = new KeyboardAdjustManager.TextViewDelegate( ); PrayerRequest.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor); PrayerRequest.TextContainerInset = UIEdgeInsets.Zero; PrayerRequest.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); PrayerRequest.TextContainer.LineFragmentPadding = 0; PrayerRequest.BackgroundColor = UIColor.Clear; PrayerRequest.Editable = true; PrayerRequest.KeyboardAppearance = UIKeyboardAppearance.Dark; PrayerRequestPlaceholder.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor); PrayerRequestPlaceholder.BackgroundColor = UIColor.Clear; PrayerRequestPlaceholder.Text = PrayerStrings.CreatePrayer_PrayerRequest; PrayerRequestPlaceholder.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); //PrayerRequestPlaceholder.SizeToFit( ); ControlStyling.StyleBGLayer(PrayerRequestLayer); // category layer CategoryLayer = new UIView(); ScrollView.AddSubview(CategoryLayer); CategoryButton = new UIButton(); CategoryLayer.AddSubview(CategoryButton); // setup the category picker and selector button UILabel categoryLabel = new UILabel( ); ControlStyling.StyleUILabel(categoryLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); categoryLabel.Text = PrayerStrings.CreatePrayer_SelectCategoryLabel; PickerAdjustManager = new PickerAdjustManager(View, ScrollView, categoryLabel, CategoryLayer); UIPickerView pickerView = new UIPickerView(); pickerView.Model = new CategoryPickerModel() { Parent = this }; pickerView.UserInteractionEnabled = true; PickerAdjustManager.SetPicker(pickerView); // setup a tap gesture for the picker Action action = () => { OnToggleCategoryPicker(false); }; UITapGestureRecognizer uiTap = new UITapGestureRecognizer(action); uiTap.NumberOfTapsRequired = 1; pickerView.AddGestureRecognizer(uiTap); uiTap.Delegate = this; CategoryButton.TouchUpInside += (object sender, EventArgs e) => { OnToggleCategoryPicker(true); }; CategoryButton.SetTitle(PrayerStrings.CreatePrayer_CategoryButtonText, UIControlState.Normal); CategoryButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal); CategoryButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); CategoryButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; ControlStyling.StyleBGLayer(CategoryLayer); // preference switches SwitchBackground = new UIView(); ScrollView.AddSubview(SwitchBackground); ControlStyling.StyleBGLayer(SwitchBackground); UIPublicSwitch = new UISwitch(); SwitchBackground.AddSubview(UIPublicSwitch); MakePublicLabel = new UILabel(); SwitchBackground.AddSubview(MakePublicLabel); //MakePublicLabel.TextColor = UIColor.White; UISwitchAnonymous = new UISwitch(); SwitchBackground.AddSubview(UISwitchAnonymous); //PostAnonymouslyLabel = new UILabel(); //SwitchBackground.AddSubview( PostAnonymouslyLabel ); //PostAnonymouslyLabel.TextColor = UIColor.White; // Setup the anonymous switch /*PostAnonymouslyLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); * PostAnonymouslyLabel.Text = PrayerStrings.CreatePrayer_PostAnonymously; * PostAnonymouslyLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); * UISwitchAnonymous.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor ); * UISwitchAnonymous.TouchUpInside += (object sender, EventArgs e ) => * { * OnToggleCategoryPicker( false ); * * if( UISwitchAnonymous.On == true ) * { * FirstName.Field.Enabled = false; * FirstName.Field.Text = PrayerStrings.CreatePrayer_Anonymous; * * LastName.Field.Enabled = false; * LastName.Field.Text = PrayerStrings.CreatePrayer_Anonymous; * } * else * { * FirstName.Field.Enabled = true; * FirstName.Field.Text = string.Empty; * * LastName.Field.Enabled = true; * LastName.Field.Text = string.Empty; * } * * // reset the background colors * Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, FirstName.Background ); * Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, LastName.Background ); * };*/ // setup the public switch MakePublicLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); MakePublicLabel.Text = PrayerStrings.CreatePrayer_MakePublic; MakePublicLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor); UIPublicSwitch.OnTintColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Switch_OnColor); //UIPublicSwitch.ThumbTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); // setup the submit button SubmitButton = UIButton.FromType(UIButtonType.Custom); ScrollView.AddSubview(SubmitButton); ControlStyling.StyleButton(SubmitButton, PrayerStrings.CreatePrayer_SubmitButtonText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); SubmitButton.SizeToFit( ); SubmitButton.TouchUpInside += SubmitPrayerRequest; }