Esempio n. 1
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);
        }
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                CachedImageRenderer.Init();
                SvgCachedImage.Init();

                Xamarin.Forms.Forms.Init(e, rendererAssemblies: new[]
                {
                    typeof(CachedImage).GetTypeInfo().Assembly,
                    typeof(CachedImageRenderer).GetTypeInfo().Assembly
                });

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                }

                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }

            Window.Current.Activate();
        }
        public SvgBasicTestPage()
        {
            Title = "SVG Basic Test";
            var img = new SvgCachedImage
            {
                Source = "sample.svg",
            };

            img.Success += OnSuccess;
            img.Finish  += OnFinish;
            img.Error   += OnError;

            _label = new Label();

            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    img,
                    _label,
                }
            };
        }
Esempio n. 4
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            App.ScreenWidth  = UIScreen.MainScreen.Bounds.Width;
            App.ScreenHeight = UIScreen.MainScreen.Bounds.Height;

            app.StatusBarStyle = UIStatusBarStyle.LightContent;

            LoadApplication(new App());

            ImageCircleRenderer.Init();
            SvgCachedImage.Init();

            CachedImageRenderer.Init();
            var ignore = typeof(SvgCachedImage);

            var statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;

            if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
            {
                statusBar.BackgroundColor = UIColor.Black;
            }

            return(base.FinishedLaunching(app, options));
        }
Esempio n. 5
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);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Instance = this;

            var preferences = PreferenceManager.GetDefaultSharedPreferences(this);
            var styleTheme  = (StyleTheme)preferences.GetInt(nameof(StyleTheme), 0);

            if (styleTheme == StyleTheme.Light)
            {
                SetTheme(Resource.Style.MainLightTheme);
            }
            else
            {
                SetTheme(Resource.Style.MainDarkTheme);
            }

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
            CrossCurrentActivity.Current.Init(this, savedInstanceState);

            base.OnCreate(savedInstanceState);
            SvgCachedImage.Init();
            CachedImageRenderer.Init(false);
            Forms9Patch.Droid.Settings.Initialize(this);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
Esempio n. 7
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. 8
0
        public override IEnumerable <CommandItem> GetToolBarItemDescriptions()
        {
            var image1 = SvgIconTarget.AddBox.ResourceFile;
            var image2 = new SvgCachedImage
            {
                Source                = SvgIconTarget.AddBox.ResourceFile,
                HorizontalOptions     = LayoutOptions.FillAndExpand,
                HeightRequest         = 100,
                DownsampleToViewSize  = true,
                Aspect                = Aspect.AspectFill,
                TransformPlaceholders = false,
                LoadingPlaceholder    = "loading.png",
                ErrorPlaceholder      = "error.png"
            };


            var image3 = new FileImageSource();

            image3.File = image1;

            yield return(new CommandItem(CommandId.AnalyseThematique)
            {
                Text = openmediavault.Create,
                IsPrimary = true,
                Command = AddItemCommand,
                Icon = image3
            });
        }
Esempio n. 9
0
        protected override void OnInitialized()
        {
            InitializeComponent();

            var ignore = new SvgCachedImage();

            NavigationService.NavigateAsync("InicialPage");
        }
Esempio n. 10
0
 /// <summary>
 /// Changes color in svg by replacing strings.
 /// </summary>
 public static SvgCachedImage ReplaceColor(this SvgCachedImage svg, Color color, string replaceTitle = "fill", string replaceText = "\"#000000\"")
 {
     svg.ReplaceStringMap = new Dictionary <string, string>
     {
         {
             $"{replaceTitle}={replaceText}",
             $"{replaceTitle}=\"{color.ToHex()}\""
         }
     };
     return(svg);
 }
Esempio n. 11
0
        public MainPage()
        {
            InitializeComponent();
            CachedImageRenderer.Init();
            var ignore = typeof(SvgCachedImage);

            SvgCachedImage.Init();


            LoadApplication(new ExchangeApp.App(new UwpInitializer()));
        }
Esempio n. 12
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            new Syncfusion.SfNavigationDrawer.XForms.iOS.SfNavigationDrawerRenderer();
            SvgCachedImage.Init();

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App(new iOSInitializer()));
            AnimationViewRenderer.Init();

            return(base.FinishedLaunching(app, options));
        }
Esempio n. 13
0
        public MenuCell() : base()
        {
            ContentView cellContent = new ContentView
            {
                Style   = Application.Current.Resources["MasterDetailMenuCell"] as Style,
                Padding = 8
            };

            StackLayout cellContentLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
            };

            StackLayout imageLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(15, 5, 0, 3)
            };

            SvgCachedImage image = new SvgCachedImage
            {
                WidthRequest  = 30,
                HeightRequest = 30
            };

            image.SetBinding(FFImageLoading.Forms.CachedImage.SourceProperty, "IconSource");

            StackLayout textLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(25, 5, 0, 3)
            };

            Label text = new Label
            {
                Style             = Application.Current.Resources["MasterDetailMenuLabelCell"] as Style,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start
            };

            text.SetBinding(Label.TextProperty, "Title");

            imageLayout.Children.Add(image);
            textLayout.Children.Add(text);

            cellContentLayout.Children.Add(imageLayout);
            cellContentLayout.Children.Add(textLayout);

            cellContent.Content = cellContentLayout;

            this.View = cellContent;
        }
Esempio n. 14
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            SvgCachedImage.Init();

            global::Xamarin.Forms.Forms.Init(this, bundle);
            AnimationViewRenderer.Init();

            LoadApplication(new App(new AndroidInitializer()));
        }
Esempio n. 15
0
        public OptionImageButton(double contentHeight)
        {
            _icon = new SvgCachedImage()
            {
                Source            = ImageSource,
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill,
                Aspect            = Aspect.AspectFit
            };
            _lbl = new Label()
            {
                HorizontalOptions       = LayoutOptions.Center,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Start,
                Text      = Text,
                TextColor = TextColor,
                FontSize  = Sizes.TextSmall - 1,
            };

            Content = new Grid()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                RowSpacing        = 4,
                HeightRequest     = contentHeight,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Auto
                    },
                },
                Children =
                {
                    { _icon, 0, 0 },
                    { _lbl,  0, 1 },
                }
            };
            this.AddTouch(async(sender, args) =>
            {
                Command?.Execute(this);
                await _icon.ScaleTo(0.85, 100u, Easing.SpringOut);
                await _icon.ScaleTo(1, 150u, Easing.SpringOut);
                Tapped?.Invoke(this, null);
            });
        }
Esempio n. 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: true);
            SvgCachedImage v = new SvgCachedImage();

            LoadApplication(new App());
        }
Esempio n. 17
0
        public HeartIconView()
        {
            // add larger touch-area
            Margin  = new Thickness(-10);
            Padding = new Thickness(10);

            _icon = new SvgCachedImage()
            {
                HeightRequest                = 25,
                WidthRequest                 = 25,
                Aspect                       = Aspect.AspectFit,
                Source                       = IsActive ? Images.FavoriteFill : Images.Favorite,
                FadeAnimationEnabled         = true,
                FadeAnimationForCachedImages = true,
                FadeAnimationDuration        = 150,
            };

            Content = new Grid()
            {
                Children =
                {
                    _icon,
                }
            };

            this.AddTouch(async(sender, args) =>
            {
                if (_isAnimating)
                {
                    return;
                }

                _isAnimating = true;

                if (!IsActive)
                {
                    IsActive = true;
                    await _icon.ScaleTo(.7f, 100u, Easing.SinInOut);
                    await _icon.ScaleTo(1f, 150u, Easing.SpringOut);
                }
                else
                {
                    IsActive = false;
                    await _icon.ScaleTo(.7f, 100u, Easing.SinOut);
                    await _icon.ScaleTo(1f, 150u, Easing.SpringOut);
                    _isAnimating = false;
                }
                ClickedCommand?.Execute(null);
            });
        }
Esempio n. 18
0
        protected override void OnInitialized()
        {
            InitializeComponent();

            var ignore = new SvgCachedImage();

            //IsFirstLoad = true;
            if (string.IsNullOrEmpty(Settings.Token))
            {
                NavigationService.NavigateAsync("LoginPage");
            }
            else
            {
                NavigationService.NavigateAsync("RootPage/PersonPage");
            }
        }
Esempio n. 19
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. 20
0
        View GetLayout(Thickness thickness = new Thickness())
        {
            var CategoryContainer = new Grid();

            CategoryContainer.Children.Add(new BoxView
            {
                BackgroundColor = Color.White
            });

            CategoryContainer.Children.Add(new SvgCachedImage
            {
                Margin           = thickness,
                WidthRequest     = 40,
                ReplaceStringMap = new Dictionary <string, string>
                {
                    { "fill=\"currentColor\"", "fill=\"#f7f8f9\"" }
                },
                FadeAnimationEnabled = false,
                Source = "circulo.svg"
            }, 0, 0);

            var CategoryIcon = new SvgCachedImage
            {
                Margin               = thickness,
                HorizontalOptions    = LayoutOptions.Center,
                WidthRequest         = 20,
                FadeAnimationEnabled = false,
            };

            CategoryIcon.SetBinding(SvgCachedImage.SourceProperty, nameof(CategoryModel.Icon));


            //var CategoryIcon = new CachedImage
            //{
            //    HorizontalOptions = LayoutOptions.Center,
            //    WidthRequest = 20,
            //    FadeAnimationEnabled = false,
            //};
            //CategoryIcon.SetBinding(CachedImage.SourceProperty, nameof(CategoryModel.Icon));


            CategoryContainer.Children.Add(CategoryIcon, 0, 0);

            return(CategoryContainer);
        }
Esempio n. 21
0
        private View HealthBoxContainer(View content)
        {
            const int heartIconSize = 40;

            var heartIcon = new SvgCachedImage
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -heartIconSize / 2f, 0, 0),
                HeightRequest     = heartIconSize,
                WidthRequest      = heartIconSize,
                Source            = Images.HealthHeart,
            };

            heartIcon.SetBinding(IsVisibleProperty, nameof(AchievementViewModel.HasBeenAchieved));

            var roundedBottom = new ShapeView()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Color             = Colors.AchievementHealthBackground,
                CornerRadius      = Sizes.CornerRadius,
                HeightRequest     = Sizes.CornerRadius * 2f,
                Margin            = new Thickness(0, 0, 0, -Sizes.CornerRadius),
            };

            var contentContainer = new ShapeView()
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Colors.AchievementHealthBackground,
                Content           = content,
            };

            return(new Grid()
            {
                RowSpacing = 0,
                Children =
                {
                    roundedBottom,
                    contentContainer,
                    heartIcon,
                }
            });
        }
        private void Update()
        {
            root.Children.Clear();

            if (MaskColor != Color.Default)
            {
                var image = new SvgCachedImage
                {
                    Style = Resources["MaskImageStyle"] as Style
                };

                image.Transformations.Add(new TintTransformation(MaskColor.ToHex())
                {
                    EnableSolidColor = true
                });
                root.Children.Add(image);
            }
        }
Esempio n. 23
0
        protected override void OnInitialized()
        {
            InitializeComponent();
            var ignore = new SvgCachedImage();

#if DEBUG
            UserProfileInfo = new UserProfileInfoModel()
            {
                UserProfileId = "71b7c6e3-750e-4dac-8cdc-c2b159b480a0",
                FirstName     = "Victor",
                LastName      = "Ramos",
                Email         = "*****@*****.**"
            };
            NavigationService.NavigateAsync("HomePage");
#else
            NavigationService.NavigateAsync("LandingPage");
#endif
        }
 public ImageForReactive()
 {
     imgConverter = (SvgImageSourceConverterForReactive)App.Container.Resolve <ISvgImageSourceConverterForReactive>();
     ffimg        = new SvgCachedImage()
     {
         VerticalOptions   = LayoutOptions.Center,
         HorizontalOptions = LayoutOptions.Start
     };
     this
     .WhenActivated(
         disposables =>
     {
         this.OneWayBind(ViewModel, vm => vm.IconSource, view => view.ffimg.Source, vmToViewConverterOverride: imgConverter)
         .DisposeWith(disposables);
         this.OneWayBind(ViewModel, vm => vm.FontSize, view => view.ffimg.HeightRequest, x => GetSquaredImageSize(x))
         .DisposeWith(disposables);
     });
     Content = ffimg;
 }
Esempio n. 25
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. 26
0
        private View CreateAchievementIcon()
        {
            var iconIncomplete = new SvgCachedImage
            {
                HorizontalOptions            = LayoutOptions.Center,
                BackgroundColor              = Colors.Background,
                Aspect                       = Aspect.AspectFit,
                FadeAnimationForCachedImages = false,
            };

            iconIncomplete.SetBinding(CachedImage.SourceProperty, nameof(AchievementViewModel.IconIncomplete));
            iconIncomplete.SetBinding(IsVisibleProperty, nameof(AchievementViewModel.HasBeenAchieved), converter: new InvertedBooleanConverter());

            var iconComplete = new SvgCachedImage()
            {
                HorizontalOptions            = LayoutOptions.Center,
                Aspect                       = Aspect.AspectFit,
                FadeAnimationForCachedImages = false,
            };

            iconComplete.SetBinding(CachedImage.SourceProperty, nameof(AchievementViewModel.IconComplete));
            iconComplete.SetBinding(IsVisibleProperty, nameof(AchievementViewModel.HasBeenAchieved));

            return(new Grid()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Start,
                BackgroundColor = Device.RuntimePlatform == Device.Android ? Colors.Background : Color.Transparent,
                HeightRequest = IconSize,
                Children =
                {
                    iconIncomplete,
                    iconComplete,
                }
            });
        }
Esempio n. 27
0
        public void RegisterRotation(SvgCachedImage image)
        {
            Device.StartTimer(TimeSpan.FromMilliseconds(2), () =>
            {
                Console.WriteLine("RegisterScroll1 RegisterScroll");
                if (!IsPlaying)
                {
                    return(true);
                }

                Task.Run(async() =>
                {
                    if (rotation < 360)
                    {
                        image.Rotation = rotation++;
                    }
                    else
                    {
                        rotation = 0;
                    }
                });
                return(true);
            });
        }
Esempio n. 28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            SetTheme(Resource.Style.MainTheme);

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            Xamarin.Forms.Forms.Init(this, savedInstanceState);

            // https://www.xamboy.com/2018/03/29/sharing-svg-icons-across-platforms-in-xamarin-forms/
            {
                CachedImageRenderer.Init(true);
                SvgCachedImage.Init();
                // ReSharper disable once AssignmentIsFullyDiscarded
                _ = typeof(SvgCachedImage);
            }

            LoadApplication(new App());
            Window.SetSoftInputMode(SoftInput.AdjustResize);
            Window.SetStatusBarColor(Android.Graphics.Color.Argb(255, 0, 0, 0));
        }
Esempio n. 29
0
        public Footer()
        {
            Expanded = false;

            // Outter Frame
            OutterFrame = new Frame()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = FooterExpandedHeight,
                CornerRadius      = 0,
                Margin            = 0,
                Padding           = 0,
                BackgroundColor   = ColorUtil.TileBackgroundColor
            };

            OutterFrame.SetValue(Grid.RowProperty, 1);

            var settingsButton = new SvgCachedImage()
            {
                Source            = SvgImageSource.FromFile("settings.svg"),
                HeightRequest     = SizeUtil.FooterButtonIconSize,
                WidthRequest      = SizeUtil.FooterButtonIconSize,
                Margin            = new Thickness(SizeUtil.FooterButtonLeftRightMargin, SizeUtil.FooterButtonTopBottomMargin),
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center
            };

            settingsButton.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command((Sender) =>
                {
                    if (OutterFrame.AnimationIsRunning("opening"))
                    {
                        return;
                    }

                    double startingHeight, endingHeight = 0d;

                    if (Expanded)
                    {
                        startingHeight = SizeUtil.FooterHeightExpanded;
                        endingHeight   = FooterExpandedHeight;
                    }
                    else
                    {
                        startingHeight = FooterExpandedHeight;
                        endingHeight   = SizeUtil.FooterHeightExpanded;
                    }

                    Action <double> callback = input => OutterFrame.HeightRequest = input;
                    uint rate     = 16;
                    uint length   = 500;
                    Easing easing = Easing.CubicOut;

                    OutterFrame.Animate("opening", callback, startingHeight, endingHeight, rate, length, easing);

                    Expanded = !Expanded;
                })
            });

            OutterFrame.Content = new Grid()
            {
                VerticalOptions = LayoutOptions.Start,
                HeightRequest   = FooterExpandedHeight,
                Children        =
                {
                    new Label()
                    {
                        Margin            = new Thickness(SizeUtil.FooterButtonLeftRightMargin, SizeUtil.FooterButtonTopBottomMargin),
                        Text              = TextUtil.ApplicationName,
                        FontSize          = 12,
                        TextColor         = ColorUtil.PrimaryTextColor,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    settingsButton,
                    new SvgCachedImage()
                    {
                        Source            = SvgImageSource.FromFile("info.svg"),
                        HeightRequest     = SizeUtil.FooterButtonIconSize,
                        WidthRequest      = SizeUtil.FooterButtonIconSize,
                        Margin            = new Thickness(SizeUtil.FooterButtonLeftRightMargin, 0),
                        HorizontalOptions = LayoutOptions.Start,
                        VerticalOptions   = LayoutOptions.Center
                    }
                }
            };

            Content = OutterFrame;
        }
Esempio n. 30
0
        public QuestionsCell()
        {
            MaterialFrame frame = new MaterialFrame();

            frame.SetAppThemeColor(Frame.BorderColorProperty, (Color)Application.Current.Resources["MainColor"], Color.White);
            frame.HorizontalOptions = LayoutOptions.FillAndExpand;
            frame.VerticalOptions   = LayoutOptions.Start;
            frame.BackgroundColor   = Color.White;
            frame.Margin            = new Thickness(10, 0, 10, 10);
            frame.Padding           = new Thickness(18, 18, 18, 18);
            frame.CornerRadius      = 35;
            frame.SetOnAppTheme(Frame.HasShadowProperty, false, true);
            frame.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20);

            StackLayout container = new StackLayout();

            container.Orientation = StackOrientation.Vertical;

            title.TextColor      = Color.Black;
            title.FontAttributes = FontAttributes.Bold;
            title.FontSize       = 18;

            container.Children.Add(title);

            date.HorizontalOptions = LayoutOptions.Start;
            date.TextColor         = Color.Black;
            date.FontSize          = 12;
            date.IsVisible         = false;
            date.Margin            = new Thickness(0, -5, 0, 0);
            StackLayout containerCount = new StackLayout();

            containerCount.Orientation = StackOrientation.Horizontal;
            StackLayout containerOne = new StackLayout();

            containerOne.Orientation = StackOrientation.Horizontal;
            StackLayout containerTwo = new StackLayout();

            containerTwo.Orientation = StackOrientation.Horizontal;

            countQuestTitle.Text = $"{AppResources.QuestionsAmount}:";
            countQuestTitle.HorizontalOptions  = LayoutOptions.Start;
            countQuestTitle.FontSize           = 12;
            countAnsweredTitle.VerticalOptions = LayoutOptions.Center;
            countQuestTitle.TextColor          = Color.Black;

            countQuest.TextColor         = (Color)Application.Current.Resources["MainColor"];
            countQuest.HorizontalOptions = LayoutOptions.Start;
            countQuest.FontSize          = 12;
            countQuest.FontAttributes    = FontAttributes.Bold;

            containerOne.Children.Add(countQuestTitle);
            containerOne.Children.Add(countQuest);

            countAnsweredTitle.Text              = $"{AppResources.AnsweredAmount}:";
            countAnsweredTitle.TextColor         = Color.Black;
            countAnsweredTitle.HorizontalOptions = LayoutOptions.Start;
            countAnsweredTitle.VerticalOptions   = LayoutOptions.Center;
            countAnsweredTitle.FontSize          = 12;

            countAnswered.TextColor         = (Color)Application.Current.Resources["MainColor"];
            countAnswered.HorizontalOptions = LayoutOptions.Start;
            countAnswered.FontAttributes    = FontAttributes.Bold;
            countAnswered.FontSize          = 12;
            containerTwo.Children.Add(countAnsweredTitle);
            containerTwo.Children.Add(countAnswered);
            containerTwo.HorizontalOptions = LayoutOptions.End;

            Grid grid = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            // containerCount.Children.Add(containerOne);
            // containerCount.Children.Add(containerTwo);
            grid.Children.Add(containerOne, 0, 0);
            grid.Children.Add(containerTwo, 1, 0);

            container.Children.Add(date);
            container.Children.Add(grid);

            Frame frameBtn = new Frame();

            frameBtn.HorizontalOptions = LayoutOptions.FillAndExpand;
            frameBtn.VerticalOptions   = LayoutOptions.Start;
            frameBtn.BackgroundColor   = (Color)Application.Current.Resources["MainColor"];
            frameBtn.Margin            = new Thickness(0, 10, 0, 10);
            frameBtn.Padding           = 0;
            frameBtn.CornerRadius      = 10;
            frameBtn.SetOnAppTheme(Frame.HasShadowProperty, false, true);
            frameBtn.SetOnAppTheme(MaterialFrame.ElevationProperty, 0, 20);

            StackLayout containerBtn = new StackLayout();

            containerBtn.Spacing           = 0;
            containerBtn.Orientation       = StackOrientation.Horizontal;
            containerBtn.HorizontalOptions = LayoutOptions.CenterAndExpand;

            SvgCachedImage image = new SvgCachedImage();

            image.Source           = "resource://xamarinJKH.Resources.ic_questions2.svg";
            image.ReplaceStringMap = new Dictionary <string, string>
            {
                { "#000000", "#FFFFFF" }
            };
            // image.Margin = new Thickness(-40, 0, 0, 0);
            image.HeightRequest = 25;
            image.WidthRequest  = 25;

            // Label btn = new Label();
            // btn.Margin = new Thickness(-15, 0, 0, 0);
            // btn.TextColor = Color.White;
            // btn.FontAttributes = FontAttributes.Bold;
            // btn.Text = "Пройти опрос";


            // btn.Margin = new Thickness(-30, 0, 0, 0);
            btn.TextColor         = Color.White;
            btn.BackgroundColor   = Color.Transparent;
            btn.HorizontalOptions = LayoutOptions.Center;
            btn.Margin            = new Thickness(9, 13, 0, 13);
            btn.FontAttributes    = FontAttributes.Bold;
            btn.VerticalOptions   = LayoutOptions.Center;
            btn.FontSize          = 15;
            btn.Text = "Пройти опрос";

            containerBtn.Children.Add(image);
            containerBtn.Children.Add(btn);

            frameBtn.Content = containerBtn;

            container.Children.Add(frameBtn);
            Grid containerMain = new Grid();

            containerMain.Padding           = 0;
            containerMain.ColumnDefinitions = new ColumnDefinitionCollection
            {
                new ColumnDefinition {
                    Width = GridLength.Star
                },
                new ColumnDefinition {
                    Width = new GridLength(5)
                }
            };

            containerMain.RowDefinitions = new RowDefinitionCollection
            {
                new RowDefinition {
                    Height = new GridLength(5)
                },
                new RowDefinition {
                    Height = GridLength.Star
                }
            };

            containerMain.Children.Add(container);
            Grid.SetRowSpan(container, 2);
            Grid.SetColumnSpan(container, 2);

            ReadIndicator = new Frame
            {
                CornerRadius    = 5,
                BackgroundColor = Color.Red,
                IsVisible       = false
            };
            ReadIndicator.SetBinding(View.IsVisibleProperty, "Read", BindingMode.TwoWay);
            containerMain.Children.Add(ReadIndicator, 1, 0);

            frame.Content = containerMain;

            View = frame;
        }