Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NameTextField.Enabled = Editable;
            NameTextField.AttributedPlaceholder = new NSAttributedString(Strings.Basic.new_card, new UIStringAttributes { ForegroundColor = UIColor.Gray });
            NameTextField.EditingChanged += (sender, e) =>
            {
                SelectedCard.UpdateStringProperty(() => SelectedCard.Name, NameTextField.Text.Trim());
            };
            NameTextField.Hidden = HideTitle;

            var cardBack = CardBack.Create(); 
            cardBack.Hidden = true;
            cardBack.Frame = ContainerView.Bounds;
            cardBack.LogoImageButtonAction += () =>
            {
                var isTablet = CrossDeviceInfo.Current.Idiom == Idiom.Tablet;
                var alertStyle = isTablet ? UIAlertControllerStyle.Alert : UIAlertControllerStyle.ActionSheet;

                UIAlertController AlertController = UIAlertController.Create(Strings.Alerts.select_image_source, null, alertStyle);
                AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.user_facebook_image, UIAlertActionStyle.Default, (obj) =>
                {
                    DownloadFacebookImage(cardBack, SelectedCard.LocalLogoURL, SelectedCard.RemoteLogoURL, "Logo.png", SelectedCard.RemoteLogoURL);
                }));
                AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.select_from_gallery, UIAlertActionStyle.Default, (obj) =>
                {
                    SelectImageFromGallery(cardBack, SelectedCard.LocalLogoURL, SelectedCard.RemoteLogoURL, "Logo.png",SelectedCard.RemoteLogoURL);
                }));
                AlertController.AddAction(UIAlertAction.Create(Strings.Basic.cancel, UIAlertActionStyle.Cancel, null));
                PresentViewController(AlertController, true, null);
            };
            ContainerView.AddSubview(cardBack);
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            var cardFront = CardFront.Create();
            cardFront.Hidden = true;
            cardFront.Frame = ContainerView.Bounds;
            cardFront.HeaderImageButtonAction += () =>
            {
                var isTablet = CrossDeviceInfo.Current.Idiom == Idiom.Tablet;
                var alertStyle = isTablet ? UIAlertControllerStyle.Alert : UIAlertControllerStyle.ActionSheet;

                UIAlertController AlertController = UIAlertController.Create(Strings.Alerts.select_image_source, null, alertStyle);
                AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.user_facebook_image, UIAlertActionStyle.Default, (obj) =>
                {
                    DownloadFacebookImage(cardFront, SelectedCard.LocalHeaderURL, SelectedCard.RemoteHeaderURL, "Header.png", SelectedCard.RemoteHeaderURL);
                }));
                AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.select_from_gallery, UIAlertActionStyle.Default, (obj) =>
                {
                    SelectImageFromGallery(cardFront, SelectedCard.LocalHeaderURL, SelectedCard.RemoteHeaderURL, "Header.png", SelectedCard.RemoteHeaderURL);
                }));
                AlertController.AddAction(UIAlertAction.Create(Strings.Basic.cancel, UIAlertActionStyle.Cancel, null));
                PresentViewController(AlertController, true, null);
            };
            ContainerView.AddSubview(cardFront);
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            if (SelectedCard.IsFlipped)
            {
                cardBack.Hidden = false;
            }
            else
            {
                cardFront.Hidden = false;
            }


            var SwipeGestureRecognizer = new UISwipeGestureRecognizer((UISwipeGestureRecognizer obj) =>
            {
                Flip();
            });
            SwipeGestureRecognizer.Direction = UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
            ContainerView.AddGestureRecognizer(SwipeGestureRecognizer);


        }

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            Update(true);

            CABasicAnimation grow = CABasicAnimation.FromKeyPath("transform.scale");
            grow.From = NSObject.FromObject(0);
            grow.Duration = .5;
            grow.RemovedOnCompletion = true;
            ContainerView.Layer.AddAnimation(grow, "grow");
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            TableViewRowEditingChangedNotification = NSNotificationCenter.DefaultCenter.AddObserver(new NSString(Strings.InternalNotifications.notification_table_row_editing_changed), (obj) =>
            {
                InvokeOnMainThread(() =>
                {
                    Update(false);
                });
            });
        }
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            TableViewRowEditingChangedNotification?.Dispose();
            TableViewRowEditingChangedNotification = null;
        }
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();

            if (ContainerView != null)
            {
                ContainerView.Frame = new CGRect(8, 8, View.Bounds.Width - 16, GetCalculatedHeight() + 33); //40 is the total insets that appear in a tableviewcell

                var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).FirstOrDefault() as CardFront;
                if (cardFront != null)
                    cardFront.Frame = ContainerView.Bounds;

                var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).FirstOrDefault() as CardBack;
                if (cardBack != null) 
                    cardBack.Frame = ContainerView.Bounds;
            }
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                ContainerView.Subviews.ToList().ForEach(v => v.RemoveFromSuperview());
                ContainerView?.RemoveFromSuperview();
                ContainerView?.Dispose();
                ContainerView = null;

                TableViewRowEditingChangedNotification?.Dispose();
                TableViewRowEditingChangedNotification = null;
            }
        }
        public void FocusOnName()
        {
            NameTextField.BecomeFirstResponder();
        }
        public void Update(bool reloadImages)
        {
            if (SelectedCard == null) return;

            NameTextField.Text = (SelectedCard.Name.Equals(Strings.Basic.new_card, StringComparison.InvariantCultureIgnoreCase) && Editable) ? null : SelectedCard.Name;

            var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).FirstOrDefault() as CardFront;
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (ContainerView == null)
            {
                ContainerView = InitializeContainerView();
            }

            if (ContainerView.Superview == null)
            {
                View.AddSubview(ContainerView);
            }

            ContainerView.Bounces = true;
            ContainerView.AlwaysBounceHorizontal = true;
            ContainerView.AlwaysBounceVertical   = false;
            ContainerView.ScrollsToTop           = false;
            ContainerView.Delegate = this;
            ContainerView.ShowsVerticalScrollIndicator   = false;
            ContainerView.ShowsHorizontalScrollIndicator = false;
            ContainerView.PagingEnabled = true;
            ReloadViewControllers();

            var childController = ViewControllers?[CurrentIndex];

            this.AddChildViewController(childController);
            childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            ContainerView.AddSubview(childController.View);
            childController.DidMoveToParentViewController(this);
        }
Exemple #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var me = RealmUserServices.GetMe(true);

            var initials = (me.FirstName?.FirstOrDefault() + " " + me.LastName?.FirstOrDefault()).Trim();
            CTStringAttributes attributes = new CTStringAttributes();

            attributes.KerningAdjustment = -2;
            NSAttributedString attributedString = new NSAttributedString(initials, attributes);

            InititalsLabel.AttributedText      = attributedString;
            InititalsLabel.BackgroundColor     = UIColor.FromWhiteAlpha(0.9f, 1);
            InititalsLabel.TextColor           = UIColor.Gray;
            InititalsLabel.Layer.MasksToBounds = true;
            InititalsLabel.Layer.CornerRadius  = InititalsLabel.Frame.Size.Width / 2;

            NameLabel.Text   = me.FirstName + " " + me.LastName;
            HandleLabel.Text = me.Handle;


            AddChildViewController(TableViewController);
            ContainerView.AddSubview(TableViewController.View);
            View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            FooterLabel.Text = DrawerShared.GetFooterText();
        }
Exemple #4
0
        public void ProcessContentSearchRequest(NSNotification obj)
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);

            string       keyword = SearchBar.Text;
            SearchResult res     = SearchUtil.Search(AppDataUtil.Instance.GetCurrentPublication().BookId, AppDataUtil.Instance.GetOpendTOC().ID, keyword);

            if (AppDisplayUtil.Instance.ContentSearchResController != null)
            {
                AppDisplayUtil.Instance.ContentSearchResController.View.RemoveFromSuperview();
            }
            AppDisplayUtil.Instance.ContentSearchResController = new ResultViewController(res);
            AppDisplayUtil.Instance.ContentSearchResController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            ContainerView.AddSubview(AppDisplayUtil.Instance.ContentSearchResController.View);
            ContainerView.AddConstraints(new NSLayoutConstraint[] {
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Leading, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Trailing, 1, 0)
            });

            hud.Hide(animated: true, delay: 0.2);
        }
Exemple #5
0
            public override void LoadView()
            {
                View = new ContainerView(this);

                string appearance = EffectiveAppearanceName;

                NativeChild.RemoveFromSuperview();
                View.AddSubview(NativeChild);

                if (!string.IsNullOrEmpty(appearance) && appearance.IndexOf("Dark", StringComparison.Ordinal) >= 0)
                {
                    View.Appearance = NSAppearance.GetAppearance(MacSystemInformation.OsVersion < MacSystemInformation.Mojave ? NSAppearance.NameVibrantDark : new NSString("NSAppearanceNameDarkAqua"));
                }
                else
                {
                    View.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua);
                }

                WidgetSpacing padding = 0;

                if (Backend != null)
                {
                    padding = Backend.Frontend.Padding;
                }
                View.AddConstraints(new NSLayoutConstraint [] {
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, (nfloat)padding.Left),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Right, NSLayoutRelation.Equal, View, NSLayoutAttribute.Right, 1, -(nfloat)padding.Right),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, (nfloat)padding.Top),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1, -(nfloat)padding.Bottom),
                });
            }
Exemple #6
0
        public void SetMainViewController(UIViewController viewController, bool animated)
        {
            // This will only happen once...
            if (ContainerView.Superview == null)
            {
                var containerFrame = View.Bounds;
                containerFrame.X    = View.Bounds.Width;
                ContainerView.Frame = containerFrame;

                View.AddSubview(ContainerView);
                var updatedMenuFrame = new CGRect(View.Bounds.Location, new CGSize(MenuWidth, View.Bounds.Height));
                UIView.Animate(OpenAnimationDuration, 0, UIViewAnimationOptions.BeginFromCurrentState | AnimationOption,
                               () => MenuViewController.View.Frame = updatedMenuFrame, null);

                if (_menuViewController != null)
                {
                    _menuViewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
                }
            }

            AddChildViewController(viewController);
            viewController.View.Frame = ContainerView.Bounds;
            ContainerView.AddSubview(viewController.View);

            if (_mainViewController != null && viewController != _mainViewController)
            {
                _mainViewController.RemoveFromParentViewController();
                _mainViewController.View.RemoveFromSuperview();
                _mainViewController.DidMoveToParentViewController(null);
            }

            Close(animated);
            _mainViewController = viewController;
        }
Exemple #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ExpireInfoView.AddGestureRecognizer(new UITapGestureRecognizer(AppDisplayUtil.Instance.ShowPublicationInfoView));
            ShowExpireInfoView();

            tocTableViewVC = new TableOfContentTableViewController();
            TOCNode rootNode = AppDataUtil.Instance.GetCurPublicationTocRootNode();

            if (rootNode != null && rootNode.ChildNodes != null && rootNode.ChildNodes.Count > 0)
            {
                tocTableViewSource = new TableOfContentTableViewSource(rootNode);
                tocTableViewVC.TableView.Source = tocTableViewSource;
                tocTableViewVC.TableView.TranslatesAutoresizingMaskIntoConstraints = false;
                tocTableViewVC.TableView.TableFooterView = new UIView();                 //hidden redundant line separator

                ContainerView.AddSubview(tocTableViewVC.TableView);
                ContainerView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Leading, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Trailing, 1, 0)
                });

                AppDataUtil.Instance.AddOpenedContentObserver(this);                 //Set current instance as the observer of subject OpendPublication to get notification when opend content changed
            }

            AppDisplayUtil.Instance.TOCVC = this;

            SearchBar.Delegate = new TOCSearchBarDelegate();
            //hide search bar border
            SearchBar.Layer.BorderWidth = 1;
            SearchBar.Layer.BorderColor = UIColor.FromRGB(194, 194, 194).CGColor;
        }
        public override void PresentationTransitionWillBegin()
        {
            dimmingView.Frame = ContainerView.Bounds;
            ContainerView.AddSubview(dimmingView);

            var transitionCoordinator = PresentingViewController.GetTransitionCoordinator();
            transitionCoordinator.AnimateAlongsideTransition(context => dimmingView.Alpha = 0.8f, null);
        }
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();

     FlyingObjects = new FlyingObjectsView(View.Frame);
            View.InsertSubview(FlyingObjects, 0);

     AddChildViewController(ContainerNavigationController);
     ContainerView.AddSubview(ContainerNavigationController.View);
     ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerNavigationController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
     ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerNavigationController.View, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
     ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerNavigationController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
     ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerNavigationController.View, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));
            ContainerNavigationController.View.TranslatesAutoresizingMaskIntoConstraints = false;

            ContainerViewTopMarginConstraint.Constant = UIApplication.SharedApplication.StatusBarFrame.Height;

           
        }
Exemple #10
0
        public override void PresentationTransitionWillBegin()
        {
            base.PresentationTransitionWillBegin();

            ContainerView.AddSubview(DimmedBackgroundView);
            DimmedBackgroundView.Alpha = 0;

            var coordinator = PresentingViewController.GetTransitionCoordinator();

            coordinator.AnimateAlongsideTransition(_ => DimmedBackgroundView.Alpha = DimmedBackgroundTranslucentAlpha, null);
        }
        void AddViewsToDimmingView()
        {
            if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular &&
                TraitCollection.VerticalSizeClass == UIUserInterfaceSizeClass.Regular)
            {
                dimmingView.AddSubviews(bigFlowerImageView, carlImageView);
            }

            dimmingView.AddSubviews(topJaguarPrintImageView,
                                    bottomJaguarPrintImageView, leftJaguarPrintImageView, rightJaguarPrintImageView);

            ContainerView.AddSubview(dimmingView);
        }
        public override void PresentationTransitionWillBegin()
        {
            UIView presentedViewControllerView = base.PresentedView;

            presentationWrapperView = new UIView(FrameOfPresentedViewInContainerView);
            presentationWrapperView.Layer.ShadowOpacity = .44f;
            presentationWrapperView.Layer.ShadowRadius  = 13f;
            presentationWrapperView.Layer.ShadowOffset  = new CGSize(0f, -6f);

            var presentationRoundedCornerView = new UIView(UIEdgeInsetsInsetRect(presentationWrapperView.Bounds, new UIEdgeInsets(0F, 0F, -cornerRadius, 0)));

            presentationRoundedCornerView.AutoresizingMask    = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            presentationRoundedCornerView.Layer.CornerRadius  = cornerRadius;
            presentationRoundedCornerView.Layer.MasksToBounds = true;

            var presentedViewControllerWrapperView = new UIView(UIEdgeInsetsInsetRect(presentationRoundedCornerView.Bounds, new UIEdgeInsets(0F, 0F, cornerRadius, 0F)));

            presentedViewControllerWrapperView.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight);

            presentedViewControllerView.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight);
            presentedViewControllerView.Frame            = presentedViewControllerWrapperView.Bounds;
            presentedViewControllerWrapperView.AddSubview(presentedViewControllerView);

            presentationRoundedCornerView.AddSubview(presentedViewControllerWrapperView);
            presentationWrapperView.AddSubview(presentationRoundedCornerView);

            var dimmingViewAux = new UIView(ContainerView.Frame)
            {
                BackgroundColor  = UIColor.Black,
                Opaque           = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };

            dimmingView = dimmingViewAux;

            var tapGesture = new UITapGestureRecognizer();

            tapGesture.AddTarget(() => DimmingViewTapped(tapGesture));
            dimmingView.AddGestureRecognizer(tapGesture);

            ContainerView.AddSubview(dimmingView);

            var transitionCoordinator = PresentingViewController.GetTransitionCoordinator();

            dimmingView.Alpha = 0f;
            transitionCoordinator.AnimateAlongsideTransition((obj) => dimmingView.Alpha = .5f, (obj) => {});
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AutomaticallyAdjustsScrollViewInsets = false;
            TableViewController.AutomaticallyAdjustsScrollViewInsets = false;

            TableViewController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            AddChildViewController(TableViewController);
            ContainerView.AddSubview(TableViewController.View);
            ContainerView.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            RemoveBackBarButtonTitle();
        }
Exemple #14
0
        void PresentAnimateTransition(IUIViewControllerContextTransitioning context)
        {
            var toViewController = context.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var contentView      = context.ContainerView;

            ContainerView.AddSubview(toViewController.View);

            toViewController.View.Alpha = 0;

            UIView.Animate(TransitionDuration(context), 0, UIViewAnimationOptions.CurveLinear, () =>
            {
                toViewController.View.Alpha = 1;
            }, () =>
            {
                context.CompleteTransition(true);
            });
        }
        public override void PresentationTransitionWillBegin()
        {
            dimmingView.Frame                      = ContainerView.Bounds;
            AdditionalContentView.Frame            = ContainerView.Bounds;
            AdditionalContentView.Layer.ZPosition += 1;

            ContainerView.AddSubview(dimmingView);
            ContainerView.AddSubview(AdditionalContentView);

            var coordinator = PresentedViewController.GetTransitionCoordinator();

            if (coordinator == null)
            {
                dimmingView.Alpha = 0.8f;
                return;
            }

            coordinator.AnimateAlongsideTransition(_ => dimmingView.Alpha = 0.8f, null);
        }
        public void ProcessContentSearchRequest(NSNotification obj)
        {
            string       keyword = SearchBar.Text;
            SearchResult res     = SearchUtil.Search(AppDataUtil.Instance.GetCurrentPublication().BookId, AppDataUtil.Instance.GetOpendTOC().ID, keyword);

            if (AppDisplayUtil.Instance.ContentSearchResController != null)
            {
                AppDisplayUtil.Instance.ContentSearchResController.View.RemoveFromSuperview();
            }
            AppDisplayUtil.Instance.ContentSearchResController = new ResultViewController(res);
            AppDisplayUtil.Instance.ContentSearchResController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            ContainerView.AddSubview(AppDisplayUtil.Instance.ContentSearchResController.View);
            ContainerView.AddConstraints(new NSLayoutConstraint[] {
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Leading, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Trailing, 1, 0)
            });
        }
        public void BindDataToView(Card card, bool showNameLabel, NSIndexPath indexPath)
        {
            Reset();

            if (card == null)
            {
                return;
            }

            NameLabelHeightConstraint.Constant = (showNameLabel) ? 24 : 0;
            NameLabel.Text = card.Name;

            var cardBack = CardBack.Create();

            cardBack.BindDataToView(card, false);
            cardBack.Hidden = true;
            cardBack.Frame  = ContainerView.Bounds;
            ContainerView.AddSubview(cardBack);
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardBack, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            var cardFront = CardFront.Create();

            cardFront.BindDataToView(card, false, indexPath, true);
            cardFront.Hidden = true;
            cardFront.Frame  = ContainerView.Bounds;
            ContainerView.AddSubview(cardFront);
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0));
            ContainerView.AddConstraint(NSLayoutConstraint.Create(cardFront, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0));

            if (card.IsFlipped)
            {
                cardBack.Hidden = false;
            }
            else
            {
                cardFront.Hidden = false;
            }
        }
Exemple #18
0
            public override void LoadView()
            {
                View = new ContainerView(this);
                NativeChild.RemoveFromSuperview();
                View.AddSubview(NativeChild);

                WidgetSpacing padding = 0;

                if (Backend != null)
                {
                    padding = Backend.Frontend.Padding;
                }
                View.AddConstraints(new NSLayoutConstraint [] {
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, (nfloat)padding.Left),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Right, NSLayoutRelation.Equal, View, NSLayoutAttribute.Right, 1, -(nfloat)padding.Right),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, (nfloat)padding.Top),
                    NSLayoutConstraint.Create(NativeChild, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1, -(nfloat)padding.Bottom),
                });
            }
        /// <inheritdoc />
        public override void ViewWillAppear(bool animated)
        {
            SetupBackground();
            PrepareCustomAnimation();
            SetupLayout();

            AddChildViewController(_childDialog);
            _childDialog.View.TranslatesAutoresizingMaskIntoConstraints = false;
            ContainerView.AddSubview(_childDialog.View);
            ContainerView.UserInteractionEnabled = true;
            ContainerView.AddGestureRecognizer(new UITapGestureRecognizer(() => { }));

            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _childDialog.View.LeadingAnchor.ConstraintEqualTo(ContainerView.LeadingAnchor),
                _childDialog.View.TrailingAnchor.ConstraintEqualTo(ContainerView.TrailingAnchor),
                _childDialog.View.TopAnchor.ConstraintEqualTo(ContainerView.TopAnchor),
                _childDialog.View.BottomAnchor.ConstraintEqualTo(ContainerView.BottomAnchor),
            });

            _childDialog.DidMoveToParentViewController(this);

            RootView.AddGestureRecognizer(GetTappedOutsideGestureRecognizer());
        }
Exemple #20
0
        public void UpdateContent()
        {
            if (LastSize.Width != ContainerView.Bounds.Size.Width)
            {
                LastSize = ContainerView.Bounds.Size;
                ContainerView.ContentOffset = new CGPoint(PageOffsetForChild(CurrentIndex), 0);
            }
            LastSize = ContainerView.Bounds.Size;

            var pagerViewControllers = PagerTabStripChildViewControllersForScrolling ?? ViewControllers;

            ContainerView.ContentSize = new CGSize(ContainerView.Bounds.Width * pagerViewControllers.Count, ContainerView.ContentSize.Height);

            for (var index = 0; index < pagerViewControllers.Count; index++)
            {
                var childController    = pagerViewControllers[index];
                var pageOffsetForChild = PageOffsetForChild(index);
                if (NMath.Abs(ContainerView.ContentOffset.X - pageOffsetForChild) < ContainerView.Bounds.Width)
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.View.Frame            = new CGRect(OffsetForChild(index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                    }
                    else
                    {
                        AddChildViewController(childController);
                        childController.BeginAppearanceTransition(true, false);
                        childController.View.Frame            = new CGRect(OffsetForChild(index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                        ContainerView.AddSubview(childController.View);
                        childController.DidMoveToParentViewController(this);
                        childController.EndAppearanceTransition();
                    }
                }
                else
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.WillMoveToParentViewController(null);
                        childController.BeginAppearanceTransition(false, false);
                        childController.View.RemoveFromSuperview();
                        childController.RemoveFromParentViewController();
                        childController.EndAppearanceTransition();
                    }
                }
            }

            var oldCurrentIndex = CurrentIndex;
            var virtualPage     = VirtualPageFor(ContainerView.ContentOffset.X);
            var newCurrentIndex = PageFor(virtualPage);

            CurrentIndex = newCurrentIndex;
            var changeCurrentIndex = newCurrentIndex != oldCurrentIndex;

            var progressiveDelegate = this as PagerTabStripIsProgressiveDelegate;

            if (progressiveDelegate != null && PagerBehaviour.ProgressiveIndicator)
            {
                var t = ProgressiveIndicatorData(virtualPage);
                progressiveDelegate.UpdateIndicator(
                    viewController: this,
                    fromIndex: t.Item1,
                    toIndex: t.Item2,
                    progressPercentage: t.Item3,
                    indexWasChanged: changeCurrentIndex);
            }
            else
            {
                if (Delegate != null)
                {
                    Delegate.UpdateIndicator(this, NMath.Min(oldCurrentIndex, pagerViewControllers.Count - 1), newCurrentIndex);
                }
            }
        }
        private void UpdateContent()
        {
            if (_lastSize != ContainerView.Bounds.Size)
            {
                _lastSize = ContainerView.Bounds.Size;
                ContainerView.SetContentOffset(new CGPoint(PageOffsetForChildIndex(CurrentIndex), 0), false);
            }
            var childViewControllers = _pagerTabStripChildViewControllers;

            ContainerView.ContentSize = new CGSize(ContainerView.Bounds.Width * childViewControllers.Count, ContainerView.ContentSize.Height);
            for (int i = 0; i < childViewControllers.Count; i++)
            {
                UIViewController childController    = childViewControllers [i] as UIViewController;
                nfloat           pageOffsenForChild = PageOffsetForChildIndex(i);
                if (NMath.Abs(ContainerView.ContentOffset.X - pageOffsenForChild) < ContainerView.Bounds.Width)
                {
                    if (childController.ParentViewController == null)
                    {
                        AddChildViewController(childController);
                        childController.DidMoveToParentViewController(this);
                        nfloat childPosition = OffsetForChildIndex(i);
                        childController.View.Frame            = new CGRect(childPosition, 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                        ContainerView.AddSubview(childController.View);
                    }
                    else
                    {
                        nfloat childPosition = OffsetForChildIndex(i);
                        childController.View.Frame            = new CGRect(childPosition, 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                    }
                }
                else
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.View.RemoveFromSuperview();
                        childController.WillMoveToParentViewController(null);
                        childController.RemoveFromParentViewController();
                    }
                }
            }


            nint oldCurrentIndex = CurrentIndex;
            nint virtualPage     = VirtualPageForContentOffset(ContainerView.ContentOffset.X);
            nint newCurrentIndex = PageForVirtualPage(virtualPage);

            CurrentIndex = newCurrentIndex;

            if (IsProgressiveIndicator)
            {
                nfloat scrollPercentage = ScrollPercentage;
                if (scrollPercentage > 0)
                {
                    nint fromIndex = CurrentIndex;
                    nint toIndex   = CurrentIndex;
                    PagerTabStripDirection scrollDirection = ScrollDirection;
                    if (scrollDirection == PagerTabStripDirection.Left)
                    {
                        if (virtualPage > _pagerTabStripChildViewControllers.Count - 1)
                        {
                            fromIndex = _pagerTabStripChildViewControllers.Count - 1;
                            toIndex   = _pagerTabStripChildViewControllers.Count;
                        }
                        else
                        {
                            if (scrollPercentage > 0.5f)
                            {
                                fromIndex = NMath.Max(toIndex - 1, 0);
                            }
                            else
                            {
                                toIndex = fromIndex + 1;
                            }
                        }
                    }
                    else if (scrollDirection == PagerTabStripDirection.Right)
                    {
                        if (virtualPage < 0)
                        {
                            fromIndex = 0;
                            toIndex   = -1;
                        }
                        else
                        {
                            if (scrollPercentage > 0.5f)
                            {
                                fromIndex = NMath.Min(toIndex + 1, _pagerTabStripChildViewControllers.Count - 1);
                            }
                            else
                            {
                                toIndex = fromIndex - 1;
                            }
                        }
                    }
                    UpdatePage(fromIndex, toIndex, IsElasticIndicatorLimit ? scrollPercentage : (toIndex < 0 || toIndex >= _pagerTabStripChildViewControllers.Count ? 0 : scrollPercentage));
                }
            }
            else
            {
                if (oldCurrentIndex != newCurrentIndex)
                {
                    UpdatePage(NMath.Max(oldCurrentIndex, _pagerTabStripChildViewControllers.Count - 1), newCurrentIndex);
                }
            }
        }
Exemple #22
0
        public void UpdateContent()
        {
            if (lastSize.Width != ContainerView.Bounds.Size.Width)
            {
                lastSize = ContainerView.Bounds.Size;
                ContainerView.ContentOffset = new CGPoint(PageOffsetForChildIndex(CurrentIndex), 0);
            }

            lastSize = ContainerView.Bounds.Size;

            var pagerViewControllers = pagerTabStripChildViewControllersForScrolling ?? ViewControllers;

            ContainerView.ContentSize = new CGSize(ContainerView.Bounds.Width * new nfloat(pagerViewControllers.Count()), ContainerView.ContentSize.Height);

            int pagerViewControllersCount = pagerViewControllers.Count();

            for (int index = 0; index < pagerViewControllersCount; index++)
            {
                UIViewController childController = pagerViewControllers[index];
                var pageOffsetForChild           = PageOffsetForChildIndex((uint)index);

                if (Math.Abs(ContainerView.ContentOffset.X - pageOffsetForChild) < ContainerView.Bounds.Width)
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.View.Frame            = new CGRect(OffsetForChildIndex((uint)index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                    }
                    else
                    {
                        childController.BeginAppearanceTransition(true, animated: false);
                        AddChildViewController(childController);
                        childController.View.Frame            = new CGRect(OffsetForChildIndex((uint)index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                        ContainerView.AddSubview(childController.View);
                        childController.DidMoveToParentViewController(this);
                        childController.EndAppearanceTransition();
                    }
                }
                else
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.BeginAppearanceTransition(false, animated: false);
                        childController.WillMoveToParentViewController(null);
                        childController.View.RemoveFromSuperview();
                        childController.RemoveFromParentViewController();
                        childController.EndAppearanceTransition();
                    }
                }
            }

            var oldCurrentIndex = CurrentIndex;
            var virtualPage     = VirtualPageForContentOffset(ContainerView.ContentOffset.X);
            var newCurrentIndex = PageForVirtualPage(virtualPage);

            CurrentIndex = (uint)newCurrentIndex;
            var changeCurrentIndex = newCurrentIndex != oldCurrentIndex;

            IPagerTabStripIsProgressiveDelegate progressiveDelegate = this as IPagerTabStripIsProgressiveDelegate;

            if (progressiveDelegate != null && PagerBehaviour.IsProgressiveIndicator)
            {
                Tuple <int, int, nfloat> data = ProgressiveIndicatorData((uint)virtualPage);
                progressiveDelegate.PagerTabStripViewController(this, data.Item1, data.Item2, data.Item3, changeCurrentIndex);
            }
            else
            {
                Delegate?.PagerTabStripViewController(this, Math.Min((int)oldCurrentIndex, pagerViewControllers.Count() - 1), (int)newCurrentIndex);
            }
        }