Esempio n. 1
0
        public View Share()
        {
            var imgShare = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = 24f,
                Aspect            = Aspect.AspectFit,
                Source            = Images.ToolbarShare,
            };

            imgShare.ReplaceColor(Colors.Text);

            var layout = new FadeView()
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Fill,
                AnimationTime     = 100,
                IsVisible         = false,
                Padding           = new Thickness(4, 0, 0, 0),
                Content           = imgShare,
            };

            layout.SetBinding(BaseAnimatedView.AnimateProperty, nameof(Toolbar.ShowShareButton));
            layout.AddTouchCommand(new Binding(nameof(Toolbar.ShareButtonClicked)), tappedEvent: async() =>
            {
                imgShare.ReplaceColor(Colors.TextSpecial);
                await Task.Delay(1000);
                imgShare.ReplaceColor(Colors.Text);
            }
                                   );

            return(layout);
        }
Esempio n. 2
0
        public View Back()
        {
            var imgArrow = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill,
                WidthRequest      = 30f,
                Aspect            = Aspect.AspectFit,
                Source            = Images.ToolbarArrow,
                ScaleX            = -1,
            };

            imgArrow.ReplaceColor(Colors.Text);

            var layout = new FadeView()
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill,
                Padding           = new Thickness(0, 4, 4, 4),
                AnimationTime     = 100,
                IsVisible         = false,
                Content           = imgArrow,
            };

            layout.AddTouchCommand(new Binding(nameof(Toolbar.BackButtonClicked)));
            layout.SetBinding(BaseAnimatedView.AnimateProperty, nameof(Toolbar.ShowBackButton));

            return(layout);
        }
Esempio n. 3
0
        private View Icon()
        {
            var icon = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 22,
                Aspect            = Aspect.AspectFit,
                Source            = Images.ToolbarIcon,
            };

            icon.ReplaceColor(Colors.TextSpecial);
#if DEBUG
            icon.AddTouchCommand(new Binding(nameof(Toolbar.ShowDebugPopup)));
#endif

            //var layout = new FadeView()
            //{
            //    HorizontalOptions = LayoutOptions.Center,
            //    VerticalOptions = LayoutOptions.Fill,
            //    AnimationTime = 100,
            //    IsVisible = false,
            //    Content = icon,
            //};
            icon.SetBinding(OpacityProperty, nameof(Toolbar.ShowIcon), converter: new BooleanToDoubleConverter(1, 0));

            return(icon);
        }
Esempio n. 4
0
        public static View CloseButton()
        {
            var btnClose = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Aspect            = Aspect.AspectFit,
                HeightRequest     = 40,
                WidthRequest      = 40,
                Source            = Images.PopupClose,
            };

            btnClose.ReplaceColor(Colors.TextSpecial);

            return(btnClose);
        }
Esempio n. 5
0
        private View CreateIcon()
        {
            var svgCircle = new SvgCachedImage
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = IconSize,
                WidthRequest      = IconSize,
                Aspect            = Aspect.AspectFit,
            };

            svgCircle.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.Goal),
                                 converter: new GoalToBorderIconConverter());
            svgCircle.SetBinding(SvgCachedImage.ReplaceStringMapProperty, nameof(ViewModel.IsCurrentGoal),
                                 converter: new BooleanToReplacementStringMapConverter(Colors.GoalIconActive, Colors.GoalIconInactive));

            var svgShoe = new SvgCachedImage
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = IconSize / 3f,
                WidthRequest      = IconSize / 3f,
                Source            = Images.OnboardingShoe,
                Aspect            = Aspect.AspectFit,
            };

            svgShoe.ReplaceColor(Colors.GoalTextInactive, replaceText: "\"#fff\"");

            return(new Grid()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Center,
                Children =
                {
                    svgCircle,
                    svgShoe,
                }
            });
        }
Esempio n. 6
0
        private View MessageView()
        {
            var loadingIndicator = new ActivityIndicator()
            {
                Color         = Colors.Text,
                IsRunning     = true,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            loadingIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                        converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Loading));

            var infoIndicator = new SvgCachedImage()
            {
                IsVisible     = false,
                Source        = Images.HistoryInfo,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            infoIndicator.ReplaceColor(Colors.Text);
            infoIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                     converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Info));

            var errorIndicator = new SvgCachedImage()
            {
                IsVisible     = false,
                Source        = Images.PopupCloseSmall,
                HeightRequest = Sizes.TextSmall,
                WidthRequest  = Sizes.TextSmall,
            };

            errorIndicator.ReplaceColor(Colors.Text);
            errorIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                      converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Error));

            var warningIndicator = new Label()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                IsVisible         = false,
                Text     = "\u26A0",
                FontSize = Sizes.TextMicro + 1,
            };

            warningIndicator.SetBinding(IsVisibleProperty, nameof(NotifyCenter.MessageDetails.Type),
                                        converter: new ObjectToBooleanConverter(NotifyCenter.InfoType.Warning));

            var lbl = new Label()
            {
                VerticalOptions         = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor = Colors.Text,
                FontSize  = Sizes.TextMicro + 1,
            };

            lbl.SetBinding(Label.TextProperty, nameof(NotifyCenter.MessageDetails.Text));

            var layout = new ContentView()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Content           = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Fill,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(0, 12),
                    Spacing           = 10,
                    Children          =
                    {
                        loadingIndicator,
                        infoIndicator,
                        errorIndicator,
                        warningIndicator,
                        lbl,
                    }
                }
            };

            layout.AddTouchCommand(new Binding(nameof(NotifyCenter.MessageDetails.ClickedCommand)));
            layout.SetBinding(BackgroundColorProperty, nameof(NotifyCenter.MessageDetails.Type),
                              converter: new InfoLevelToColorConverter());

            return(layout);
        }
Esempio n. 7
0
        public OnboardingWelcomeView()
        {
            ScreenHeight = App.ScreenHeight;

            var icShoe = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
                Aspect            = Aspect.AspectFit,
                HeightRequest     = 64,
                Source            = Images.OnboardingShoe,
            };

            var lblWelcomeText = new Label()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center, FontSize = Sizes.Title,
                FormattedText     = new FormattedString()
                {
                    Spans =
                    {
                        new Span()
                        {
                            Text     = AppText.onboarding_first_title + "\n",
                            FontSize = Sizes.Title,
                        },
                        new Span()
                        {
                            Text           = AppText.onboarding_first_text,
                            FontAttributes = FontAttributes.Bold,
                            FontSize       = Sizes.TextLarge,
                        },
                    }
                },
            };

            var lblNameTitle = new Label()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center,
                FontAttributes    = FontAttributes.Bold,
                Text     = AppText.onboarding_entry_title,
                FontSize = Sizes.Title,
            };

            var entry = new Entry()
            {
                HorizontalOptions       = LayoutOptions.Fill,
                VerticalOptions         = LayoutOptions.Center,
                TextColor               = Colors.TextSpecial,
                FontAttributes          = FontAttributes.Bold,
                FontSize                = Sizes.TextLarge,
                Keyboard                = Keyboard.Text,
                IsTextPredictionEnabled = false,
                Margin = 0,
            };

            entry.SetBinding(Entry.TextProperty, nameof(ViewModel.UserName));
            entry.SetBinding(Entry.ReturnCommandProperty, nameof(ViewModel.NextClickedCommand));

            var nextArrow = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = Sizes.TextSmall - 2,
                Aspect            = Aspect.AspectFit,
                Source            = Images.ToolbarArrow,
                Margin            = new Thickness(-10f, -10f, 0, -10f),
            };

            nextArrow.ReplaceColor(Colors.TextSpecial);
            nextArrow.SetBinding(IsVisibleProperty, nameof(ViewModel.IsValid));
            nextArrow.AddTouchCommand(new Binding(nameof(ViewModel.NextClickedCommand)));

            var line = new BorderCanvasView()
            {
                Border           = new Thickness(0, 0, 0, 1),
                BorderColor      = Colors.LightBorderColor.MultiplyAlpha(0.5),
                InputTransparent = true,
            };

            var entryContainer = new Grid()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center,
                Margin            = new Thickness(0, 20),
                RowSpacing        = 10,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = GridLength.Auto
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Auto
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = GridLength.Star
                    },
                    new ColumnDefinition()
                    {
                        Width = 40
                    },
                },
                Children =
                {
                    { line,         0, 2, 1, 2 },
                    { lblNameTitle, 0,0 },
                    { entry,        0,1 },
                    { nextArrow,    1,1 },
                }
            };

            entry.Focused += (sender, args) =>
            {
                icShoe.FadeTo(0);
                lblWelcomeText.FadeTo(0);
                entryContainer.TranslateTo(0, -120);
                entryContainer.RowSpacing = 40;
            };

            entry.Unfocused += (sender, args) =>
            {
                icShoe.FadeTo(1, 400, Easing.CubicIn);
                lblWelcomeText.FadeTo(1, 400, Easing.CubicIn);
                entryContainer.TranslateTo(0, 0);
                entryContainer.RowSpacing = 10;
            };

            Content.Spacing = 20;

            AddAnimatedView(icShoe);
            AddAnimatedView(lblWelcomeText);
            AddAnimatedView(entryContainer);
        }
Esempio n. 8
0
        private static View ProgressOverviewElement(string title, BindingBase countBinding, Color color,
                                                    LayoutOptions alignment, string parameter)
        {
            var lblTitle = new Label()
            {
                HorizontalOptions = alignment,
                Text      = title.ToUpper(),
                TextColor = Colors.TextFaded,
                FontSize  = Sizes.TextMicro,
            };

            var infoSize = (int)Sizes.TextMicro - 1;
            var info     = new SvgCachedImage()
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Start,
                WidthRequest      = infoSize,
                HeightRequest     = infoSize,
                Source            = Images.HistoryInfo,
            };

            info.ReplaceColor(Colors.TextFaded);

            var titleLayout = new StackLayout()
            {
                VerticalOptions = LayoutOptions.Center,
                Orientation     = StackOrientation.Horizontal,
                Children        =
                {
                    lblTitle,
                    info,
                }
            };

            var line = DefaultView.UnderLine;

            line.BackgroundColor = color;
            line.Margin          = new Thickness(0, 0, infoSize, 0);

            var spanMinutes = new Span()
            {
                TextColor      = color,
                FontAttributes = FontAttributes.Bold,
                FontSize       = Sizes.TextLarge,
            };

            countBinding.Mode = BindingMode.OneWay; //Span default is OneTime: https://github.com/xamarin/Xamarin.Forms/issues/2177
            spanMinutes.SetBinding(Span.TextProperty, countBinding);

            var lblCounter = new Label()
            {
                HorizontalOptions = LayoutOptions.Start,
                Margin            = new Thickness(0, 0, infoSize, 0),
                FormattedText     = new FormattedString()
                {
                    Spans =
                    {
                        spanMinutes,
                        new Span()
                        {
                            Text      = " min",
                            TextColor = color,
                            FontSize  = Sizes.TextLarge,
                        }
                    }
                }
            };
            //lblCounter.SetBinding(IsVisibleProperty, nameof(HistoryViewModel.IsLoadingWalkingData));

            var layout = new StackLayout()
            {
                HorizontalOptions = alignment,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    titleLayout,
                    line,
                    lblCounter
                }
            };

            layout.AddTouchCommand(new Binding(nameof(HistoryViewModel.OpenInfo)), parameter);

            return(layout);
        }