void NewElement_Clicked(object sender, EventArgs e) { var d = new Dialog(Xamarin.Forms.Forms.Context); d.SetTitle((this.Element as ButtonOpenDialog).TitleModal); var renderer = RendererFactory.GetRenderer((this.Element as ButtonOpenDialog).ContentModal); // TODO : à ajuster Android.Widget.LinearLayout.LayoutParams params1 = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); params1.Height = 300; d.AddContentView(renderer.ViewGroup, params1); d.Show(); this.UpdateLayout(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return null; } View view = inflater.Inflate(Resource.Layout.Profile, container, false); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); RelativeLayout navBar = view.FindViewById<RelativeLayout>( Resource.Id.navbar_relative_layout ); navBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); // setup the name section RelativeLayout backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.name_background ); ControlStyling.StyleBGLayer( backgroundView ); NickNameField = backgroundView.FindViewById<EditText>( Resource.Id.nickNameText ); ControlStyling.StyleTextField( NickNameField, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); NickNameField.AfterTextChanged += (sender, e) => { Dirty = true; }; NickNameField.InputType |= InputTypes.TextFlagCapWords; View borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); LastNameField = backgroundView.FindViewById<EditText>( Resource.Id.lastNameText ); ControlStyling.StyleTextField( LastNameField, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); LastNameField.AfterTextChanged += (sender, e) => { Dirty = true; }; LastNameField.InputType |= InputTypes.TextFlagCapWords; // setup the contact section EmailLayer = view.FindViewById<RelativeLayout>( Resource.Id.email_background ); ControlStyling.StyleBGLayer( EmailLayer ); EmailBGColor = ControlStylingConfig.BG_Layer_Color; EmailField = EmailLayer.FindViewById<EditText>( Resource.Id.emailAddressText ); ControlStyling.StyleTextField( EmailField, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); EmailField.AfterTextChanged += (sender, e) => { Dirty = true; }; backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.cellphone_background ); ControlStyling.StyleBGLayer( backgroundView ); borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); CellPhoneField = backgroundView.FindViewById<EditText>( Resource.Id.cellPhoneText ); ControlStyling.StyleTextField( CellPhoneField, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CellPhoneField.AfterTextChanged += (sender, e) => { Dirty = true; }; CellPhoneField.AddTextChangedListener(new PhoneNumberFormattingTextWatcher()); // setup the address section backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.address_background ); ControlStyling.StyleBGLayer( backgroundView ); StreetField = backgroundView.FindViewById<EditText>( Resource.Id.streetAddressText ); ControlStyling.StyleTextField( StreetField, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); StreetField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.street_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); CityField = backgroundView.FindViewById<EditText>( Resource.Id.cityAddressText ); ControlStyling.StyleTextField( CityField, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CityField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.city_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); StateField = backgroundView.FindViewById<EditText>( Resource.Id.stateAddressText ); ControlStyling.StyleTextField( StateField, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); StateField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.state_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); ZipField = backgroundView.FindViewById<EditText>( Resource.Id.zipAddressText ); ControlStyling.StyleTextField( ZipField, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ZipField.AfterTextChanged += (sender, e) => { Dirty = true; }; // personal backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.personal_background ); ControlStyling.StyleBGLayer( backgroundView ); BirthdateField = backgroundView.FindViewById<EditText>( Resource.Id.birthdateText ); ControlStyling.StyleTextField( BirthdateField, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); BirthdateField.FocusableInTouchMode = false; BirthdateField.Focusable = false; Button birthdateButton = backgroundView.FindViewById<Button>( Resource.Id.birthdateButton ); birthdateButton.Click += (object sender, EventArgs e ) => { // setup the initial date to use ( either now, or the date in the field ) DateTime initialDateTime = DateTime.Now; if( string.IsNullOrEmpty( BirthdateField.Text ) == false ) { initialDateTime = DateTime.Parse( BirthdateField.Text ); } // build our LayoutInflater dateInflate = LayoutInflater.From( Activity ); DatePicker newPicker = (DatePicker)dateInflate.Inflate( Resource.Layout.DatePicker, null ); newPicker.Init( initialDateTime.Year, initialDateTime.Month - 1, initialDateTime.Day, this ); Dialog dialog = new Dialog( Activity ); dialog.AddContentView( newPicker, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ) ); dialog.Show( ); }; borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // Gender GenderField = view.FindViewById<EditText>( Resource.Id.genderText ); ControlStyling.StyleTextField( GenderField, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); GenderField.FocusableInTouchMode = false; GenderField.Focusable = false; Button genderButton = backgroundView.FindViewById<Button>( Resource.Id.genderButton ); genderButton.Click += (object sender, EventArgs e ) => { AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( RockGeneralData.Instance.Data.Genders[ 1 ] ), new Java.Lang.String( RockGeneralData.Instance.Data.Genders[ 2 ] ), }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { GenderField.Text = RockGeneralData.Instance.Data.Genders[ clickArgs.Which + 1 ]; Dirty = true; }); }); builder.Show( ); }; borderView = backgroundView.FindViewById<View>( Resource.Id.campus_middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // Campus CampusField = view.FindViewById<EditText>( Resource.Id.campusText ); ControlStyling.StyleTextField( CampusField, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CampusField.FocusableInTouchMode = false; CampusField.Focusable = false; Button campusButton = backgroundView.FindViewById<Button>( Resource.Id.campusButton ); campusButton.Click += (object sender, EventArgs e ) => { // build an alert dialog containing all the campus choices AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.SelectCampus_SourceTitle ); Java.Lang.ICharSequence [] campusStrings = new Java.Lang.ICharSequence[ RockGeneralData.Instance.Data.Campuses.Count ]; for( int i = 0; i < RockGeneralData.Instance.Data.Campuses.Count; i++ ) { campusStrings[ i ] = new Java.Lang.String( RockGeneralData.Instance.Data.Campuses[ i ].Name ); } // launch the dialog, and on selection, update the viewing campus text. builder.SetItems( campusStrings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { int campusIndex = clickArgs.Which; CampusField.Text = RockGeneralData.Instance.Data.Campuses[ campusIndex ].Name; Dirty = true; }); }); builder.Show( ); }; // Done buttons DoneButton = view.FindViewById<Button>( Resource.Id.doneButton ); ControlStyling.StyleButton( DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); LogoutButton = view.FindViewById<Button>( Resource.Id.logoutButton ); ControlStyling.StyleButton( LogoutButton, ProfileStrings.LogoutButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); LogoutButton.Background = null; DoneButton.Click += (object sender, EventArgs e) => { if( Dirty == true ) { if ( ValidateInput( ) ) { // Since they made changes, confirm they want to save them. AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.SubmitChangesTitle ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( GeneralStrings.Yes ), new Java.Lang.String( GeneralStrings.No ), new Java.Lang.String( GeneralStrings.Cancel ) }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { case 0: SubmitChanges( ); SpringboardParent.ModalFragmentDone( null ); break; case 1: SpringboardParent.ModalFragmentDone( null ); break; case 2: break; } }); }); builder.Show( ); } } else { SpringboardParent.ModalFragmentDone( null ); } }; LogoutButton.Click += (object sender, EventArgs e) => { // Since they made changes, confirm they want to save them. AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.LogoutTitle ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( GeneralStrings.Yes ), new Java.Lang.String( GeneralStrings.No ) }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { case 0: RockMobileUser.Instance.LogoutAndUnbind( ); SpringboardParent.ModalFragmentDone( null ); break; case 1: break; } }); }); builder.Show( ); }; return view; }