Ejemplo n.º 1
0
 private static void RecycleSubviews(this ShowCase materialShowcase)
 {
     foreach (var subview in materialShowcase.Subviews)
     {
         subview.RemoveFromSuperview();
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public void AddOverlay(View onView, ShowCaseConfig config)
 {
     _showCase = new ShowCase();
     _showCase.SetTargetView(GetOrCreateRenderer(onView).NativeView);
     _showCase.InitConfig(config);
     _showCase.Show();
 }
Ejemplo n.º 4
0
 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)));
 }
Ejemplo n.º 5
0
        public void HideOverlay()
        {
            if (_showCase != null)
            {
                _showCase.Hide();
            }

            _showCase = null;
        }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
        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();
            }
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
0
        /// 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);
        }
Ejemplo n.º 10
0
        // 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());
        }
Ejemplo n.º 11
0
 public static void Hide(this ShowCase showCase)
 {
     showCase.RecycleSubviews();
     showCase.RemoveFromSuperview();
 }
Ejemplo n.º 12
0
 public static void InitConfig(this ShowCase materialShowcase, ShowCaseConfig showCaseConfig)
 {
     materialShowcase.config = showCaseConfig;
 }
Ejemplo n.º 13
0
 /// Sets a general UIView as target
 public static void SetTargetView(this ShowCase materialShowcase, UIView view)
 {
     materialShowcase.targetView = view;
 }