Ejemplo n.º 1
0
        public ExhibitCard(string name)
        {
            _iconCache = DependencyService.Get <IIconCache>();

            _mainLayout = new Grid
            {
                RowSpacing = 4,
                Padding    = new Thickness(16, 8),

                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(5, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                },
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = 44
                    }
                },

                BackgroundColor = Color.Transparent
            };

            _name = new Label
            {
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Start,
                VerticalTextAlignment   = Xamarin.Forms.TextAlignment.Center,
                FontSize       = 18,
                TextColor      = Colors.NearWhite,
                FontAttributes = FontAttributes.Bold,
                LineBreakMode  = LineBreakMode.NoWrap,
                Text           = name
            };

            _percentCompleteChart = new DonutChart
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                ProgressColor           = Colors.NearWhite,
                ProgressBackgroundColor = Colors.LightBlue,
                StartingDegree          = 0d,
                EndingDegree            = 0d,
                RingThickness           = 8d,
                Opacity = 0d
            };

            _percentComplete = new Label
            {
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                VerticalTextAlignment   = Xamarin.Forms.TextAlignment.Center,
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Center,
                FontSize     = 12d,
                TextColor    = Colors.NearWhite,
                Opacity      = 0,
                TranslationX = 2
            };

            _syncStatusIcon = new Image
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Source            = _iconCache.FileImageSourceFromSvg("ok.svg", 42d, colorOverride: Colors.NearWhite).AsAsyncFileImageSource()
            };

            _mainLayout.Children.Add(_name, 0, 0);
            _mainLayout.Children.Add(_percentCompleteChart, 2, 0);
            _mainLayout.Children.Add(_percentComplete, 2, 0);
            _mainLayout.Children.Add(_syncStatusIcon, 2, 0);

            _cardViewLayout = new CardViewLayout
            {
                Margin          = new Thickness(8, 0d),
                CornerRadius    = 18d,
                BackgroundColor = Colors.Blue,
                Content         = _mainLayout
            };

            Content = _cardViewLayout;

            _cardViewLayout.GestureRecognizers.Add(TapGestureRecognizer);

            ClearDonut();
            AnimateDonut();
        }