Beispiel #1
0
        public MaterialTabViewItemTemplate()
        {
            visualFeedback = new VisualFeedbackEffect();
            Effects.Add(visualFeedback);

            RowSpacing = 0;

            HorizontalOptions = LayoutOptions.FillAndExpand;
            VerticalOptions   = LayoutOptions.FillAndExpand;

            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Star
            });
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            icon = new Image
            {
                Aspect            = Aspect.AspectFit,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6)
            };

            text = new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6)
            };

            badge = new TabBadgeView
            {
                PlacementTarget = icon,
                Margin          = new Thickness(0)
            };

            Children.Add(icon);
            Children.Add(text);
            Children.Add(badge);

            SetRow(icon, 0);
            SetRow(text, 1);
            SetRow(badge, 0);
            SetRowSpan(badge, 2);
        }
Beispiel #2
0
        public CupertinoTabViewItemTemplate()
        {
            visualFeedback = new VisualFeedbackEffect();
            Effects.Add(visualFeedback);

            RowSpacing = 0;

            HorizontalOptions = LayoutOptions.FillAndExpand;
            VerticalOptions   = LayoutOptions.FillAndExpand;

            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Star
            });
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            icon = new Image
            {
                Aspect            = Aspect.AspectFit,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6)
            };

            text = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6)
            };

            badge = new TabBadgeView
            {
                PlacementTarget = icon,
                Margin          = new Thickness(0)
            };

            Children.Add(icon);
            Children.Add(text);
            Children.Add(badge);

            SetRow(icon, 0);
            SetRow(text, 1);
            SetRow(badge, 0);
            SetRowSpan(badge, 2);
        }
        public WindowsTabViewItemTemplate()
        {
            RowSpacing = 0;

            HorizontalOptions = LayoutOptions.FillAndExpand;
            VerticalOptions   = LayoutOptions.FillAndExpand;

            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Star
            });
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            icon = new Image
            {
                Aspect            = Aspect.AspectFit,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6, 0, 0)
            };

            text = new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 6)
            };

            badge = new TabBadgeView
            {
                PlacementTarget = icon,
                Margin          = new Thickness(0)
            };

            Children.Add(icon);
            Children.Add(text);
            Children.Add(badge);

            SetRow(icon, 0);
            SetRow(text, 1);
            SetRow(badge, 0);
            SetRowSpan(badge, 2);
        }
        public Task OnDisappering(TabBadgeView badgeView)
        {
            if (translationY == null)
            {
                translationY = badgeView.TranslationY;
            }

            var tcs = new TaskCompletionSource <bool>();

            var disapperingAnimation = new Animation();

            disapperingAnimation.WithConcurrent(
                (f) => badgeView.Opacity = f,
                1, 0);

            disapperingAnimation.WithConcurrent(
                (f) => badgeView.TranslationY = f,
                translationY.Value, translationY.Value + Offset);

            disapperingAnimation.Commit(badgeView, nameof(OnAppearing), length: AnimationLength,
                                        finished: (v, t) => tcs.SetResult(true));

            return(tcs.Task);
        }