public override void DidEnterBackground(UIApplication application) { // Use this method to release shared resources, save user data, invalidate timers and store the application state. // If your application supports background exection this method is called instead of WillTerminate when the user quits. // Blur screen using (var blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark)) { blurView = new UIVisualEffectView(blurEffect); blurView.Frame = Window.RootViewController.View.Bounds; blurView.AddGestureRecognizer(new UITapGestureRecognizer((UITapGestureRecognizer obj) => { obj.View.RemoveFromSuperview(); blurView = null; })); Window.AddSubview(blurView); } }
public void ShowPopUp(bool animated = true, Action popAnimationFinish = null) { UIWindow window = UIApplication.SharedApplication.KeyWindow; _effectView.Frame = window.Bounds; UITapGestureRecognizer tapGesture = null; Action action = () => { NoButtonClicked?.Invoke(); Close(); }; tapGesture = new UITapGestureRecognizer(action) { NumberOfTapsRequired = 1 }; _effectView.AddGestureRecognizer(tapGesture); window.EndEditing(true); window.AddSubview(_effectView); window.AddSubview(this); if (animated) { Transform = CGAffineTransform.MakeScale(0.1f, 0.1f); UIView.Animate(0.15, delegate { Transform = CGAffineTransform.MakeScale(1, 1); _effectView.Alpha = 0.8f; }, delegate { popAnimationFinish?.Invoke(); }); } else { _effectView.Alpha = 0.8f; } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Skip if already initialized if (_initialized) { return; } if (AllowsManualResize) { _handlebar = new UIView { TranslatesAutoresizingMaskIntoConstraints = false }; _handlebar.Layer.CornerRadius = ApplicationTheme.HandlebarCornerRadius; _handlebar.BackgroundColor = ApplicationTheme.SeparatorColor; _blurView.ContentView.AddSubview(_handlebar); _handlebarSeparator = new UIView { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = ApplicationTheme.SeparatorColor }; _blurView.ContentView.AddSubview(_handlebarSeparator); NSLayoutConstraint.ActivateConstraints(new[] { _handlebar.CenterXAnchor.ConstraintEqualTo(_blurView.CenterXAnchor), _handlebar.HeightAnchor.ConstraintEqualTo(ApplicationTheme.HandlebarThickness), _handlebar.WidthAnchor.ConstraintEqualTo(ApplicationTheme.HandlebarLength), _handlebarSeparator.HeightAnchor.ConstraintEqualTo(0.5f), _handlebarSeparator.LeadingAnchor.ConstraintEqualTo(_blurView.LeadingAnchor), _handlebarSeparator.TrailingAnchor.ConstraintEqualTo(_blurView.TrailingAnchor) }); _blurView.AddGestureRecognizer(_gesture); } NSLayoutConstraint.ActivateConstraints(new[] { DisplayedContentView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor), DisplayedContentView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor), _blurView.TopAnchor.ConstraintGreaterThanOrEqualTo(View.Superview.SafeAreaLayoutGuide.TopAnchor) }); var regularWidthConstraints = new List <NSLayoutConstraint>() { View.LeadingAnchor.ConstraintEqualTo(View.Superview.SafeAreaLayoutGuide.LeadingAnchor, ApplicationTheme.Margin), View.WidthAnchor.ConstraintEqualTo(320), View.TopAnchor.ConstraintEqualTo(View.Superview.SafeAreaLayoutGuide.TopAnchor, ApplicationTheme.Margin), View.BottomAnchor.ConstraintGreaterThanOrEqualTo(View.TopAnchor, MinimumHeight - (2 * ApplicationTheme.Margin)), View.BottomAnchor.ConstraintLessThanOrEqualTo(View.Superview.SafeAreaLayoutGuide.BottomAnchor), DisplayedContentView.TopAnchor.ConstraintEqualTo(View.TopAnchor), }; if (AllowsManualResize) { regularWidthConstraints.Add(_handlebar.BottomAnchor.ConstraintEqualTo(View.BottomAnchor, -(0.5f * ApplicationTheme.Margin))); regularWidthConstraints.Add(DisplayedContentView.BottomAnchor.ConstraintEqualTo(_handlebarSeparator.TopAnchor, -ApplicationTheme.Margin)); regularWidthConstraints.Add(_handlebarSeparator.BottomAnchor.ConstraintEqualTo(_handlebar.TopAnchor, -(0.5f * ApplicationTheme.Margin))); } else { regularWidthConstraints.Add(DisplayedContentView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)); } _regularWidthConstraints = regularWidthConstraints.ToArray(); var compactWidthConstraints = new List <NSLayoutConstraint> { View.LeadingAnchor.ConstraintEqualTo(View.Superview.LeadingAnchor), View.TrailingAnchor.ConstraintEqualTo(View.Superview.TrailingAnchor), View.BottomAnchor.ConstraintEqualTo(View.Superview.BottomAnchor, ApplicationTheme.Margin), DisplayedContentView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor) }; if (AllowsManualResize) { compactWidthConstraints.Add(_handlebarSeparator.TopAnchor.ConstraintEqualTo(_handlebar.BottomAnchor, (0.5f * ApplicationTheme.Margin))); compactWidthConstraints.Add(_handlebar.TopAnchor.ConstraintEqualTo(View.TopAnchor, ApplicationTheme.Margin)); compactWidthConstraints.Add(DisplayedContentView.TopAnchor.ConstraintEqualTo(_handlebar.BottomAnchor)); } else { compactWidthConstraints.Add(DisplayedContentView.TopAnchor.ConstraintEqualTo(View.TopAnchor)); } _compactWidthConstraints = compactWidthConstraints.ToArray(); _heightConstraint = View.HeightAnchor.ConstraintEqualTo(DefaultPartialHeight); _heightConstraint.Active = true; UpdateInterfaceForCurrentTraits(); _initialized = true; }
public CustomPopup(CGSize size, UserBubbles selected_bubble) { this.bubble_name = selected_bubble.name; nfloat lx = (UIScreen.MainScreen.Bounds.Width - size.Width) / 2; nfloat ly = (UIScreen.MainScreen.Bounds.Height - size.Height) / 2; this.Frame = new CGRect(new CGPoint(lx, ly), size); effectView.Alpha = 0; UIImageView background_image = new UIImageView(this.Bounds); background_image.Image = UIImage.FromBundle("bubble_background.png"); background_image.ContentMode = UIViewContentMode.ScaleAspectFit; this.AddSubview(background_image); this.BackgroundColor = UIColor.White; nfloat bubble_title_height = 50; if (selected_bubble.name.Equals("Instagram")) { bublle_title.Text = "Visit Instagram profile"; } else if (selected_bubble.name.Equals("Facebook")) { bublle_title.Text = "Visit Facebook profile"; } else if (selected_bubble.name.Equals("My resume")) { url_resume = selected_bubble.bubble_details[0].file_url; bublle_title.Text = selected_bubble.name + " :"; Resume.Frame = new CGRect((this.Frame.Width / 2 - 45), this.Frame.Height / 2 - 50, 90, 100); Resume.SetBackgroundImage(UIImage.FromBundle("Icon awesome-file-pdf.png"), UIControlState.Normal); this.AddSubview(Resume); } else if (selected_bubble.name.Equals("My Pets")) { bublle_title.Text = selected_bubble.name + " :"; pet_name.TextColor = UIColor.FromRGB(75, 171, 229); next_pet.Frame = new CGRect(this.Frame.Width / 2 + 8, this.Frame.Height / 2 + 120, 16, 20); next_pet.SetImage(UIImage.FromBundle("Icon ionic-ios-arrow-forward.png"), UIControlState.Normal); back_pet.Frame = new CGRect(this.Frame.Width / 2 - 16, this.Frame.Height / 2 + 120, 16, 20); back_pet.SetImage(UIImage.FromBundle("Icon ionic-ios-arrow-back_blue.png"), UIControlState.Normal); this.AddSubview(next_pet); this.AddSubview(back_pet); back_pet.Hidden = true; next_pet.Hidden = true; try { if (!string.IsNullOrEmpty(selected_bubble.bubble_details[0].file_url)) { Profile_pet.Image = FromUrl(selected_bubble.bubble_details[0].file_url); } else { Profile_pet.Image = FromUrl("https://srendip-dev.s3.amazonaws.com/no-image-icon.png"); } Profile_pet.Frame = new CGRect((this.Frame.Width / 2 - 70), this.Frame.Height / 2 - 80, 140, 160); pet_name.Text = selected_bubble.bubble_details[0].detail; pet_name.Frame = new CGRect(0, this.Frame.Height / 2 + 90, this.Frame.Width, 20); pet_name.TextAlignment = UITextAlignment.Center; Profile_pet.Layer.BorderColor = UIColor.FromRGB(75, 171, 229).CGColor; Profile_pet.Layer.BorderWidth = 3f; this.AddSubview(Profile_pet); this.AddSubview(pet_name); if (selected_bubble.bubble_details.Count > 1) { next_pet.Hidden = false; } } catch (Exception ex) { } } else { bublle_title.Text = selected_bubble.name + " :"; bublle_description.Text = selected_bubble.description; } bublle_title.TextColor = UIColor.FromRGB(75, 171, 229); bublle_description.TextColor = UIColor.FromRGB(75, 171, 229); bublle_description.TextAlignment = UITextAlignment.Center; bublle_title.TextAlignment = UITextAlignment.Center; bubble_icon.Image = FromUrl(selected_bubble.icon); bubble_icon.Frame = new CGRect(this.Frame.Width / 2 - 45, 0 - 45, 90, 90); bublle_title.Frame = new CGRect(0, bubble_icon.Frame.Height / 2 - 15, this.Frame.Width, bubble_title_height); bublle_description.Frame = new CGRect((this.Frame.Width / 2 - this.Frame.Width / 4), this.Frame.Height / 2 - 20, this.Frame.Width / 2, this.Frame.Height / 3); this.Layer.CornerRadius = 25; this.AddSubview(bubble_icon); this.AddSubview(bublle_title); this.AddSubview(bublle_description); var CloseView = new UITapGestureRecognizer(() => { Close(); }); effectView.AddGestureRecognizer(CloseView); effectView.UserInteractionEnabled = true; Resume.TouchUpInside += delegate { UIApplication.SharedApplication.OpenUrl(new NSUrl(url_resume)); }; next_pet.TouchUpInside += delegate { Profile_pet.Image = null; pet_count++; back_pet.Hidden = false; if (selected_bubble.bubble_details.Count.Equals(pet_count + 1)) { next_pet.Hidden = true; } try { if (selected_bubble.bubble_details.Count > pet_count) { if (!string.IsNullOrEmpty(selected_bubble.bubble_details[pet_count].file_url)) { Profile_pet.Image = FromUrl(selected_bubble.bubble_details[pet_count].file_url); } else { Profile_pet.Image = FromUrl("https://srendip-dev.s3.amazonaws.com/no-image-icon.png"); } Profile_pet.Frame = new CGRect((this.Frame.Width / 2 - 70), this.Frame.Height / 2 - 80, 140, 160); pet_name.Text = selected_bubble.bubble_details[pet_count].detail; pet_name.Frame = new CGRect(0, this.Frame.Height / 2 + 90, this.Frame.Width, 20); pet_name.TextAlignment = UITextAlignment.Center; Profile_pet.Layer.BorderColor = UIColor.FromRGB(75, 171, 229).CGColor; Profile_pet.Layer.BorderWidth = 3f; this.AddSubview(Profile_pet); this.AddSubview(pet_name); } } catch (Exception ex) { } }; back_pet.TouchUpInside += delegate { Profile_pet.Image = null; pet_count--; next_pet.Hidden = false; try { if (pet_count >= 0) { if (!string.IsNullOrEmpty(selected_bubble.bubble_details[pet_count].file_url)) { Profile_pet.Image = FromUrl(selected_bubble.bubble_details[pet_count].file_url); } else { Profile_pet.Image = FromUrl("https://srendip-dev.s3.amazonaws.com/no-image-icon.png"); } Profile_pet.Frame = new CGRect((this.Frame.Width / 2 - 70), this.Frame.Height / 2 - 80, 140, 160); pet_name.Text = selected_bubble.bubble_details[pet_count].detail; pet_name.Frame = new CGRect(0, this.Frame.Height / 2 + 90, this.Frame.Width, 20); pet_name.TextAlignment = UITextAlignment.Center; Profile_pet.Layer.BorderColor = UIColor.FromRGB(75, 171, 229).CGColor; Profile_pet.Layer.BorderWidth = 3f; this.AddSubview(Profile_pet); this.AddSubview(pet_name); } if (pet_count.Equals(0)) { back_pet.Hidden = true; } } catch (Exception ex) { } }; }