Exemple #1
0
 public static LogItemViewModel ToViewModel(
     this IThreadSafeTimeEntry timeEntry,
     GroupId groupId,
     LogItemVisualizationIntent visualizationIntent,
     DurationFormat durationFormat,
     int indexInLog,
     int dayInLog,
     int daysInThePast)
 => new LogItemViewModel(
     groupId,
     new[] { timeEntry.Id },
     visualizationIntent,
     timeEntry.Billable,
     timeEntry.Description,
     timeEntry.Duration.HasValue
             ? DurationAndFormatToString.Convert(
         TimeSpan.FromSeconds(timeEntry.Duration.Value), durationFormat)
             : string.Empty,
     timeEntry.Project?.DisplayName(),
     timeEntry.Project?.DisplayColor(),
     timeEntry.Project?.Client?.Name,
     timeEntry.Task?.Name,
     timeEntry.TagIds.Any(),
     timeEntry.SyncStatus == SyncStatus.SyncNeeded,
     timeEntry.SyncStatus != SyncStatus.SyncFailed,
     timeEntry.IsInaccessible,
     indexInLog,
     dayInLog,
     daysInThePast);
        private static LogItemViewModel header(
            IThreadSafeTimeEntry[] group,
            LogItemVisualizationIntent visualizationIntent,
            DurationFormat durationFormat)
        {
            var sample = group.First();

            return(new LogItemViewModel(
                       groupId: new GroupId(sample),
                       representedTimeEntriesIds: group.Select(timeEntry => timeEntry.Id).ToArray(),
                       visualizationIntent: visualizationIntent,
                       isBillable: sample.Billable,
                       isActive: sample.Project?.Active ?? true,
                       description: sample.Description,
                       duration: DurationAndFormatToString.Convert(
                           TimeSpan.FromSeconds(group.Sum(timeEntry => timeEntry.Duration ?? 0)),
                           durationFormat),
                       projectName: sample.Project?.Name,
                       projectColor: sample.Project?.Color,
                       clientName: sample.Project?.Client?.Name,
                       taskName: sample.Task?.Name,
                       hasTags: sample.Tags.Any(),
                       needsSync: group.Any(timeEntry => timeEntry.SyncStatus == SyncStatus.SyncNeeded),
                       canSync: group.All(timeEntry => timeEntry.SyncStatus != SyncStatus.SyncFailed),
                       isInaccessible: sample.IsInaccessible,
                       indexInLog: 0,
                       dayInLog: 0,
                       daysInThePast: 0,
                       projectIsPlaceholder: sample.Project?.IsPlaceholder() ?? false,
                       taskIsPlaceholder: sample.Task?.IsPlaceholder() ?? false));
        }
        protected override void UpdateView()
        {
            // Text
            var projectColor = MvxColor.ParseHexString(Item.ProjectColor).ToNativeColor();

            DescriptionLabel.Text = Item.HasDescription ? Item.Description : Resources.AddDescription;
            ProjectTaskClientLabel.AttributedText = projectTaskClientToAttributedString.Convert(Item.ProjectName, Item.TaskName, Item.ClientName, projectColor);
            TimeLabel.Text = Item.Duration.HasValue
                ? DurationAndFormatToString.Convert(Item.Duration.Value, Item.DurationFormat)
                : "";

            // Colors
            DescriptionLabel.TextColor = Item.HasDescription
                ? UIColor.Black
                : Color.TimeEntriesLog.AddDescriptionTextColor.ToNativeColor();

            // Visibility
            ProjectTaskClientLabel.Hidden = !Item.HasProject;
            SyncErrorImageView.Hidden     = Item.CanContinue;
            UnsyncedImageView.Hidden      = !Item.NeedsSync;
            ContinueButton.Hidden         = !Item.CanContinue;
            ContinueImageView.Hidden      = !Item.CanContinue;
            BillableIcon.Hidden           = !Item.IsBillable;
            TagIcon.Hidden = !Item.HasTags;

            // Grouping
            BackgroundColor = UIColor.White;
            GroupSizeBackground.Layer.CornerRadius = 14;

            GroupSizeLabel.Text = "1";
            setupSingleEntity();
        }
        protected override void UpdateView()
        {
            // Text
            var projectColor = MvxColor.ParseHexString(Item.ProjectColor).ToNativeColor();

            DescriptionLabel.Text = Item.Description;
            ProjectTaskClientLabel.AttributedText = projectTaskClientToAttributedString.Convert(Item.ProjectName, Item.TaskName, Item.ClientName, projectColor);
            TimeLabel.Text = Item.Duration.HasValue
                ? DurationAndFormatToString.Convert(Item.Duration.Value, Item.DurationFormat)
                : "";

            // Constraints
            DescriptionTopDistanceConstraint.Constant    = Item.HasProject ? hasProjectDistance : noProjectDistance;
            AddDescriptionTopDistanceConstraint.Constant = Item.HasProject ? hasProjectDistance : noProjectDistance;
            FadeViewTrailingConstraint.Constant          = calculateFadeViewConstraint(Item.IsBillable, Item.HasTags);
            BillableImageViewSpacingConstraint.Constant  = Item.HasTags ? hasTagsBillableSpacing : noTagsBillableSpacing;

            // Visibility
            ProjectTaskClientLabel.Hidden = !Item.HasProject;
            AddDescriptionLabel.Hidden    = Item.HasDescription;
            SyncErrorImageView.Hidden     = Item.CanSync;
            UnsyncedImageView.Hidden      = !Item.NeedsSync;
            ContinueButton.Hidden         = !Item.CanSync;
            ContinueImageView.Hidden      = !Item.CanSync;
            BillableImageView.Hidden      = !Item.IsBillable;
            TagsImageView.Hidden          = !Item.HasTags;
        }
        protected override void UpdateView()
        {
            StopAnimating();
            timeEntriesLogCellDescription.Text       = Item.Description;
            timeEntriesLogCellDescription.Visibility = Item.HasDescription.ToVisibility();

            addDescriptionLabel.Visibility = (!Item.HasDescription).ToVisibility();

            timeEntriesLogCellProjectLabel.Text = Item.ProjectName;
            timeEntriesLogCellProjectLabel.SetTextColor(Color.ParseColor(Item.ProjectColor));
            timeEntriesLogCellProjectLabel.Visibility = Item.HasProject.ToVisibility();

            timeEntriesLogCellTaskLabel.Text = $": {Item.TaskName}";
            timeEntriesLogCellTaskLabel.SetTextColor(Color.ParseColor(Item.ProjectColor));
            timeEntriesLogCellTaskLabel.Visibility = (!string.IsNullOrEmpty(Item.TaskName)).ToVisibility();

            timeEntryLogCellClientLabel.Text       = Item.ClientName;
            timeEntryLogCellClientLabel.Visibility = Item.HasProject.ToVisibility();

            timeEntriesLogCellDuration.Text = Item.Duration.HasValue
                ? DurationAndFormatToString.Convert(Item.Duration.Value, Item.DurationFormat)
                : "";

            timeEntriesLogCellContinueImage.Visibility = Item.CanContinue.ToVisibility();
            errorImageView.Visibility = (!Item.CanContinue).ToVisibility();

            errorNeedsSync.Visibility = Item.NeedsSync.ToVisibility();
            timeEntriesLogCellContinueButton.Visibility = Item.CanContinue.ToVisibility();

            billableIcon.Visibility = Item.IsBillable.ToVisibility();
            hasTagsIcon.Visibility  = Item.HasTags.ToVisibility();

            whitePadding.LayoutParameters = getWhitePaddingWidthDependentOnIcons();
        }
        protected override void UpdateView()
        {
            projectName.Text = Item.ProjectName;
            projectName.SetTextColor(Color.ParseColor(Item.Color));

            duration.Text = DurationAndFormatToString.Convert(Item.TrackedTime, Item.DurationFormat);

            percentage.Text = $"{Item.Percentage:0.00}%";
        }
Exemple #7
0
        public TimeEntryViewData(TimeEntryViewModel timeEntryViewModel)
        {
            TimeEntryViewModel = timeEntryViewModel;

            var spannableString = new SpannableStringBuilder();

            if (TimeEntryViewModel.HasProject)
            {
                spannableString.Append(TimeEntryViewModel.ProjectName, new ForegroundColorSpan(Color.ParseColor(TimeEntryViewModel.ProjectColor)), SpanTypes.ExclusiveInclusive);

                if (!string.IsNullOrEmpty(TimeEntryViewModel.TaskName))
                {
                    spannableString.Append($": {TimeEntryViewModel.TaskName}");
                }

                if (!string.IsNullOrEmpty(TimeEntryViewModel.ClientName))
                {
                    spannableString.Append($" {TimeEntryViewModel.ClientName}", new ForegroundColorSpan(Color.ParseColor(ClientNameColor)), SpanTypes.ExclusiveExclusive);
                }

                ProjectTaskClientText       = spannableString;
                ProjectTaskClientVisibility = ViewStates.Visible;
            }
            else
            {
                ProjectTaskClientText       = new SpannableString(string.Empty);
                ProjectTaskClientVisibility = ViewStates.Gone;
            }

            DurationText = TimeEntryViewModel.Duration.HasValue
                ? DurationAndFormatToString.Convert(TimeEntryViewModel.Duration.Value, TimeEntryViewModel.DurationFormat)
                : "";

            DescriptionVisibility         = TimeEntryViewModel.HasDescription.ToVisibility();
            AddDescriptionLabelVisibility = (!TimeEntryViewModel.HasDescription).ToVisibility();
            ContinueImageVisibility       = TimeEntryViewModel.CanContinue.ToVisibility();
            ErrorImageViewVisibility      = (!TimeEntryViewModel.CanContinue).ToVisibility();
            ErrorNeedsSyncVisibility      = TimeEntryViewModel.NeedsSync.ToVisibility();
            ContinueButtonVisibility      = TimeEntryViewModel.CanContinue.ToVisibility();
            BillableIconVisibility        = TimeEntryViewModel.IsBillable.ToVisibility();
            HasTagsIconVisibility         = TimeEntryViewModel.HasTags.ToVisibility();
        }