public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            FadeView.FadeRight = true;

            this.DelayBind(() =>
            {
                var colorConverter      = new MvxRGBValueConverter();
                var durationCombiner    = new DurationValueCombiner();
                var visibilityConverter = new MvxVisibilityValueConverter();
                var bindingSet          = this.CreateBindingSet <ReportsLegendViewCell, ChartSegment>();

                ProjectLabel.SetKerning(-0.2);
                ClientLabel.SetKerning(-0.2);
                TotalTimeLabel.SetKerning(-0.2);
                PercentageLabel.SetKerning(-0.2);

                //Text
                bindingSet.Bind(ProjectLabel).To(vm => vm.ProjectName);
                bindingSet.Bind(ClientLabel).To(vm => vm.ClientName);
                bindingSet.Bind(PercentageLabel)
                .For(v => v.Text)
                .ByCombining("Format", "'{0:0.00}%'", nameof(ChartSegment.Percentage));

                bindingSet.Bind(TotalTimeLabel)
                .ByCombining(durationCombiner,
                             vm => vm.TrackedTime,
                             vm => vm.DurationFormat);

                bindingSet.Bind(ClientLabel)
                .For(v => v.BindVisibility())
                .To(vm => vm.HasClient)
                .WithConversion(visibilityConverter);

                // Color
                bindingSet.Bind(ProjectLabel)
                .For(v => v.TextColor)
                .To(vm => vm.Color)
                .WithConversion(colorConverter);

                bindingSet.Bind(CircleView)
                .For(v => v.BackgroundColor)
                .To(vm => vm.Color)
                .WithConversion(colorConverter);

                bindingSet.Apply();
            });
        }
Beispiel #2
0
        protected override void UpdateView()
        {
            ProjectLabel.SetKerning(-0.2);
            ClientLabel.SetKerning(-0.2);
            TotalTimeLabel.SetKerning(-0.2);
            PercentageLabel.SetKerning(-0.2);

            //Text
            ProjectLabel.Text    = Item.ProjectName;
            ClientLabel.Text     = Item.ClientName;
            PercentageLabel.Text = $"{Item.Percentage:F2}%";
            TotalTimeLabel.Text  = Item.TrackedTime.ToFormattedString(Item.DurationFormat);

            ClientLabel.Hidden = !Item.HasClient;

            // Color
            var color = new Color(Item.Color).ToNativeColor();

            ProjectLabel.TextColor     = color;
            CircleView.BackgroundColor = color;
        }