Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NControl.Controls.CardPage"/> class.
        /// </summary>
        public CardPage()
        {
            // Get helper
            _platformHelper = DependencyService.Get <ICardPageHelper> ();
            if (_platformHelper == null)
            {
                throw new InvalidOperationException("Error loading NControls - did you remember to call " +
                                                    "NControls.Init() in your platform startup code?");
            }

            CardPadding     = new Thickness(40, 100, 40, 200);
            BackgroundColor = Color.Transparent;

            NavigationPage.SetHasNavigationBar(this, false);
            NavigationPage.SetHasBackButton(this, false);

            _layout = new RelativeLayout();

            base.Content = _layout;

            // Card
            _contentView = new RoundCornerView {
                BackgroundColor = Color.White,
                CornerRadius    = 4,
            };

            _overlay = new BoxView {
                BackgroundColor = Color.Black,
                Opacity         = 0.0F,
            };

            _layout.Children.Add(_overlay, () => _layout.Bounds);
            _layout.Children.Add(_contentView, () => new Rectangle(
                                     (_platformHelper.ControlAnimatesItself ? CardPadding.Left : 0),
                                     (_platformHelper.ControlAnimatesItself ? CardPadding.Top :0),
                                     _layout.Width - (_platformHelper.ControlAnimatesItself ? (CardPadding.Right + CardPadding.Left) : 0),
                                     _layout.Height - (_platformHelper.ControlAnimatesItself ? (CardPadding.Bottom + CardPadding.Top) : 0)));

            if (_platformHelper.ControlAnimatesItself)
            {
                _contentView.TranslationY = _platformHelper.GetScreenSize().Height - (CardPadding.Top);
            }

            // Add tap
            _overlay.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(async() => await CloseAsync())
            });
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NControl.Controls.CardPage"/> class.
		/// </summary>
		public CardPage()
		{					
			// Get helper
			_platformHelper = DependencyService.Get<ICardPageHelper> ();
            if(_platformHelper == null)
                throw new InvalidOperationException("Error loading NControls - did you remember to call " + 
                    "NControls.Init() in your platform startup code?");

			CardPadding = new Thickness (40, 100, 40, 200);
			BackgroundColor = Color.Transparent;

			NavigationPage.SetHasNavigationBar (this, false);
			NavigationPage.SetHasBackButton (this, false);

			_layout = new RelativeLayout ();

			base.Content = _layout;

			// Card 
			_contentView = new RoundCornerView {				
				BackgroundColor = Color.White,
				CornerRadius = 4,
			};

			_overlay = new BoxView {
				BackgroundColor = Color.Black,
				Opacity = 0.0F,
			};

			_layout.Children.Add (_overlay, () => _layout.Bounds);
			_layout.Children.Add(_contentView, ()=> new Rectangle (
				(_platformHelper.ControlAnimatesItself ? CardPadding.Left : 0),
				(_platformHelper.ControlAnimatesItself ? CardPadding.Top :0),  
				_layout.Width - (_platformHelper.ControlAnimatesItself ? (CardPadding.Right + CardPadding.Left) : 0), 
				_layout.Height - (_platformHelper.ControlAnimatesItself ? (CardPadding.Bottom + CardPadding.Top) : 0)));

			if(_platformHelper.ControlAnimatesItself)
				_contentView.TranslationY = _platformHelper.GetScreenSize().Height - (CardPadding.Top);

			// Add tap
			_overlay.GestureRecognizers.Add (new TapGestureRecognizer {
				Command = new Command(async () => await CloseAsync())
			});
		}