/// <summary> /// Instantiate a new <see cref="PopupTappedEventArgs"/> /// </summary> /// <param name="popup">The popup that was tapped</param> /// <param name="view">The view that was tapped</param> /// <returns></returns> public static PopupTappedEventArgs Create(Popup popup, View view) { PopupSectionType housingSectionType; var parentView = view.FindParent(ve => { var parentSectionType = ve.GetValue(Popup.SectionTypeProperty); var currentSection = (PopupSectionType)parentSectionType; return currentSection == PopupSectionType.Body || currentSection == PopupSectionType.Footer || currentSection == PopupSectionType.Header; }); if (parentView == null) { housingSectionType = PopupSectionType.Backdrop; } else { housingSectionType = (PopupSectionType)parentView.GetValue(Popup.SectionTypeProperty); } var controlType = (PopupSectionType)view.GetValue(Popup.SectionTypeProperty); var evt = new PopupTappedEventArgs { Popup = popup, ControlTapped = view, IsUserControl = controlType == PopupSectionType.NotSet, Section = housingSectionType }; return evt; }
public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty); if (render == null) { render = Platform.CreateRenderer(source); source.SetValue(RendererProperty, render); var p = PlatformProperty.GetValue(valid); PlatformProperty.SetValue(source, p); IsPlatformEnabledProperty.SetValue(source, true); } return(render); }
public IXFPopupCtrl CreateDropDown(Xamarin.Forms.View anchor, Xamarin.Forms.View drop) { CustomPopup dlg = null; //first try to get the PopupHolderRenderer //first try to get the PopupHolderRenderer if (anchor == null || drop == null) { return(null); } var anchorRender = anchor.GetValue(RendererProperty) as UIView; if (anchorRender == null) { return(null); } var render = Convert(drop, anchor); if (render == null) { return(null); } if (render != null) { var size = drop.GetSizeRequest(anchorRender.Bounds.Width, XFPopupConst.SCREEN_HEIGHT); var width = anchorRender.Bounds.Width; var height = (int)size.Request.Height; if (height > (XFPopupConst.SCREEN_HEIGHT * 3 / 4)) { height = (int)(XFPopupConst.SCREEN_HEIGHT * 3 / 4); } //important drop.Layout(new Xamarin.Forms.Rectangle(0, 0, width - 2 * padding, height)); var native = render as UIKit.UIView; native.Frame = new CoreGraphics.CGRect(padding, padding, width - 2 * padding, height); dlg = new CustomPopup(native, true, width, height + 2 * padding, ShowType.DropDown, anchorRender); } return(dlg); }
public IXFPopupCtrl CreateDropDown(Xamarin.Forms.View anchor, Xamarin.Forms.View drop) { CustomDropDown dropctr = null; //get the renderer of anchor if (anchor != null) { var ar = anchor.GetValue(RendererProperty); if (ar != null) { var dropView = Convert(drop, anchor); if (dropView == null) { return(null); } double w = (int)anchor.Width; double h = XFPopupConst.SCREEN_HEIGHT / 2; drop.WidthRequest = w; var size = drop.GetSizeRequest(w, XFPopupConst.SCREEN_HEIGHT / 2); if (size.Request.Height < h) { h = size.Request.Height; } drop.Layout(new Rectangle(0, 0, w, h)); float density = Forms.Context.Resources.DisplayMetrics.Density; w = w * density; h = h * density; var native = dropView as Android.Views.View; native.LayoutParameters = new ViewGroup.LayoutParams((int)w, (int)h); dropctr = new CustomDropDown(ar as Android.Views.View, native, (int)w + 4, (int)h + 10); } } return(dropctr); }
public IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid) { IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty); if (render == null) { render = RendererFactory.GetRenderer(source); source.SetValue(RendererProperty, render); if (valid != null) { var p = PlatformProperty.GetValue(valid); if (p != null) { //PlatformProperty.SetValue(source, p); //IsPlatformEnabledProperty.SetValue(source, true); } } } return(render); }