private static void RecycleSubviews(this ShowCase materialShowcase) { foreach (var subview in materialShowcase.Subviews) { subview.RemoveFromSuperview(); } }
public static void AddInstructionView(this ShowCase materialShowcase, CGPoint atCenter) { materialShowcase.instructionView = new ShowCaseInstructionView(); materialShowcase.instructionView.text = materialShowcase.config.ViewText; // Calculate x position float xPosition = ShowCase.LabelMargin; // Calculate y position float yPosition; if (materialShowcase.config.TextVerticalPosition != VerticalPosition.Top) { yPosition = (float)atCenter.Y + ShowCase.TextCenterOffset; } else { yPosition = (float)atCenter.Y - ShowCase.TextCenterOffset - ShowCase.LabelDefaultHeight * 2; } materialShowcase.instructionView.Frame = new CGRect( xPosition, yPosition, materialShowcase.containerView.Frame.Width - (xPosition + xPosition), (materialShowcase.containerView.Frame.Height / 2)); materialShowcase.AddSubview(materialShowcase.instructionView); }
public void AddOverlay(View onView, ShowCaseConfig config) { _showCase = new ShowCase(); _showCase.SetTargetView(GetOrCreateRenderer(onView).NativeView); _showCase.InitConfig(config); _showCase.Show(); }
public static void Show(this ShowCase materialShowcase) { materialShowcase.InitViews(); materialShowcase.BackgroundColor = UIColor.Black; materialShowcase.Alpha = .2f; materialShowcase.containerView.AddSubview(materialShowcase); materialShowcase.LayoutIfNeeded(); materialShowcase.AddGestureRecognizer(new UITapGestureRecognizer(() => Hide(materialShowcase))); }
public void HideOverlay() { if (_showCase != null) { _showCase.Hide(); } _showCase = null; }
public static void SetDefaultProperties(this ShowCase materialShowcase) { // Background materialShowcase.backgroundPromptColor = ShowCase.BackgroundDefaultColor; materialShowcase.backgroundPromptColorAlpha = ShowCase.BackgroundAlpha; // Target view materialShowcase.targetTintColor = ShowCase.BackgroundDefaultColor; materialShowcase.targetHolderColor = ShowCase.TargetHolderColor; materialShowcase.targetHolderRadius = ShowCase.TargetHolderRadius; }
public static void Configure(this ShowCase materialShowcase) { materialShowcase.BackgroundColor = UIColor.Clear; var window = UIApplication.SharedApplication.Delegate?.GetWindow(); if (window != null) { materialShowcase.containerView = window; materialShowcase.SetDefaultProperties(); } }
public static void InitViews(this ShowCase materialShowcase) { var center = materialShowcase.CalculateCenter(materialShowcase.targetView, materialShowcase.containerView); materialShowcase.AddTarget(center); materialShowcase.AddInstructionView(center); materialShowcase.instructionView.LayoutIfNeeded(); foreach (var subView in materialShowcase.Subviews) { subView.UserInteractionEnabled = false; } }
/// Create a copy view of target view /// It helps us not to affect the original target view public static void AddTarget(this ShowCase materialShowcase, CGPoint atCenter) { materialShowcase.targetCopyView = materialShowcase.targetView.SnapshotView(true); var width = materialShowcase.targetCopyView.Frame.Width; var height = materialShowcase.targetCopyView.Frame.Height; materialShowcase.targetCopyView.Frame = new CGRect(0, 0, width, height); materialShowcase.targetCopyView.Center = atCenter; materialShowcase.targetCopyView.TranslatesAutoresizingMaskIntoConstraints = true; materialShowcase.targetCopyView.Frame = RectangleFExtensions.Inset(materialShowcase.targetCopyView.Frame, -5f, -5f); materialShowcase.targetCopyView.Layer.BorderColor = UIColor.White.CGColor; materialShowcase.targetCopyView.Layer.BorderWidth = 5f; materialShowcase.AddSubview(materialShowcase.targetCopyView); }
// Calculates the center point based on targetview public static CGPoint CalculateCenter(this ShowCase materialShowcase, UIView targetView, UIView containerView) { var targetRect = targetView.ConvertRectToCoordinateSpace(targetView.Bounds, containerView); return(targetRect.Center()); }
public static void Hide(this ShowCase showCase) { showCase.RecycleSubviews(); showCase.RemoveFromSuperview(); }
public static void InitConfig(this ShowCase materialShowcase, ShowCaseConfig showCaseConfig) { materialShowcase.config = showCaseConfig; }
/// Sets a general UIView as target public static void SetTargetView(this ShowCase materialShowcase, UIView view) { materialShowcase.targetView = view; }