public void WorksForMoreThan24Hours() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(43, 6, 12); var expected = $"43:06:12"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public void WorksIfMinutesAreZero() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(12, 0, 12); var expected = $"12:00:12"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public void DoesNotRemoveLeadingZeroFromHours() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(3, 6, 12); var expected = $"03:06:12"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public void AppendsTheSecondUnitIfTimeSpanIsLessThanOneMinute() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(0, 0, 42); var expected = $"42 { Resources.UnitSecond }"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public void AppendsTheMinuteUnitIfTimeSpanIsNotLongerThanOneHour() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(0, 43, 59); var expected = $"43:59 { Resources.UnitMin }"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public void DoesNotAppendUnitIfTimeSpanIsLongerThanOneHour() { var converter = new TimeSpanToDurationWithUnitValueConverter(); var timeSpan = new TimeSpan(12, 32, 42); var expected = "12:32:42"; var actual = converter.Convert(timeSpan, typeof(string), null, CultureInfo.CurrentCulture); actual.Should().Be(expected); }
public override void ViewDidLoad() { base.ViewDidLoad(); prepareViews(); if (PresentationController is ModalPresentationController modalPresentationController) { syncErrorMessageView = EditTimeEntryErrorView.Create(); var contentView = modalPresentationController.AdditionalContentView; contentView.AddSubview(syncErrorMessageView); syncErrorMessageView.TranslatesAutoresizingMaskIntoConstraints = false; syncErrorMessageView.TopAnchor .ConstraintEqualTo(contentView.TopAnchor, 28).Active = true; syncErrorMessageView.LeadingAnchor .ConstraintEqualTo(contentView.LeadingAnchor, 8).Active = true; syncErrorMessageView.TrailingAnchor .ConstraintEqualTo(contentView.TrailingAnchor, -8).Active = true; } var durationConverter = new TimeSpanToDurationWithUnitValueConverter(); var dateConverter = new DateToTitleStringValueConverter(); var timeConverter = new DateTimeToTimeConverter(); var visibilityConverter = new MvxVisibilityValueConverter(); var inverterVisibilityConverter = new MvxInvertedVisibilityValueConverter(); var projectTaskClientCombiner = new ProjectTaskClientValueCombiner( ProjectTaskClientLabel.Font.CapHeight, Color.EditTimeEntry.ClientText.ToNativeColor(), false ); var bindingSet = this.CreateBindingSet <EditTimeEntryViewController, EditTimeEntryViewModel>(); if (syncErrorMessageView != null) { bindingSet.Bind(syncErrorMessageView) .For(v => v.Text) .To(vm => vm.SyncErrorMessage); bindingSet.Bind(syncErrorMessageView) .For(v => v.BindTap()) .To(vm => vm.DismissSyncErrorMessageCommand); bindingSet.Bind(syncErrorMessageView) .For(v => v.CloseCommand) .To(vm => vm.DismissSyncErrorMessageCommand); bindingSet.Bind(syncErrorMessageView) .For(v => v.BindVisible()) .To(vm => vm.SyncErrorMessageVisible) .WithConversion(inverterVisibilityConverter); } //Text bindingSet.Bind(DescriptionTextField).To(vm => vm.Description); bindingSet.Bind(BillableSwitch) .For(v => v.BindAnimatedOn()) .To(vm => vm.Billable); bindingSet.Bind(DurationLabel) .To(vm => vm.Duration) .WithConversion(durationConverter); bindingSet.Bind(ProjectTaskClientLabel) .For(v => v.AttributedText) .ByCombining(projectTaskClientCombiner, v => v.Project, v => v.Task, v => v.Client, v => v.ProjectColor); bindingSet.Bind(StartDateLabel) .To(vm => vm.StartTime) .WithConversion(dateConverter); bindingSet.Bind(StartTimeLabel) .To(vm => vm.StartTime) .WithConversion(timeConverter); bindingSet.Bind(TagsLabel) .To(vm => vm.Tags) .WithConversion(new CollectionToStringValueConverter <string>()); //Commands bindingSet.Bind(CloseButton).To(vm => vm.CloseCommand); bindingSet.Bind(DeleteButton).To(vm => vm.DeleteCommand); bindingSet.Bind(ConfirmButton).To(vm => vm.ConfirmCommand); bindingSet.Bind(DurationLabel) .For(v => v.BindTap()) .To(vm => vm.EditDurationCommand); bindingSet.Bind(ProjectTaskClientLabel) .For(v => v.BindTap()) .To(vm => vm.SelectProjectCommand); bindingSet.Bind(AddProjectAndTaskView) .For(v => v.BindTap()) .To(vm => vm.SelectProjectCommand); bindingSet.Bind(StartDateTimeView) .For(v => v.BindTap()) .To(vm => vm.SelectStartDateTimeCommand); bindingSet.Bind(TagsLabel) .For(v => v.BindTap()) .To(vm => vm.SelectTagsCommand); bindingSet.Bind(AddTagsView) .For(v => v.BindTap()) .To(vm => vm.SelectTagsCommand); bindingSet.Bind(BillableView) .For(v => v.BindTap()) .To(vm => vm.ToggleBillableCommand); //Project visibility bindingSet.Bind(AddProjectAndTaskView) .For(v => v.BindVisible()) .To(vm => vm.Project) .WithConversion(visibilityConverter); bindingSet.Bind(ProjectTaskClientLabel) .For(v => v.BindVisible()) .To(vm => vm.Project) .WithConversion(inverterVisibilityConverter); //Tags visibility bindingSet.Bind(AddTagsView) .For(v => v.BindVisible()) .To(vm => vm.HasTags) .WithConversion(visibilityConverter); bindingSet.Bind(TagsLabel) .For(v => v.BindVisible()) .To(vm => vm.HasTags) .WithConversion(inverterVisibilityConverter); bindingSet.Apply(); }
public override void ViewDidLoad() { base.ViewDidLoad(); DurationLabel.Font = DurationLabel.Font.GetMonospacedDigitFont(); PreferredContentSize = View.Frame.Size; resizeSwitch(); var durationConverter = new TimeSpanToDurationWithUnitValueConverter(); var dateConverter = new DateToTitleStringValueConverter(); var timeConverter = new DateTimeToTimeConverter(); var visibilityConverter = new MvxVisibilityValueConverter(); var inverterVisibilityConverter = new MvxInvertedVisibilityValueConverter(); var colorConverter = new MvxRGBValueConverter(); var bindingSet = this.CreateBindingSet <EditTimeEntryViewController, EditTimeEntryViewModel>(); //Text bindingSet.Bind(DescriptionLabel).To(vm => vm.Description); bindingSet.Bind(ProjectLabel).To(vm => vm.Project); bindingSet.Bind(ClientLabel).To(vm => vm.Client); bindingSet.Bind(BillableSwitch).To(vm => vm.Billable); bindingSet.Bind(DurationLabel) .To(vm => vm.Duration) .WithConversion(durationConverter); bindingSet.Bind(StartDateLabel) .To(vm => vm.StartTime) .WithConversion(dateConverter); bindingSet.Bind(StartTimeLabel) .To(vm => vm.StartTime) .WithConversion(timeConverter); //Commands bindingSet.Bind(CloseButton).To(vm => vm.CloseCommand); bindingSet.Bind(DeleteButton).To(vm => vm.DeleteCommand); //Description visibility bindingSet.Bind(AddDescriptionView) .For(v => v.BindVisible()) .To(vm => vm.Description) .WithConversion(visibilityConverter); bindingSet.Bind(DescriptionLabel) .For(v => v.BindVisible()) .To(vm => vm.Description) .WithConversion(inverterVisibilityConverter); //Project visibility bindingSet.Bind(AddProjectAndTaskView) .For(v => v.BindVisible()) .To(vm => vm.Project) .WithConversion(visibilityConverter); bindingSet.Bind(ProjectLabel) .For(v => v.BindVisible()) .To(vm => vm.Project) .WithConversion(inverterVisibilityConverter); bindingSet.Bind(ProjectDot) .For(v => v.BindVisible()) .To(vm => vm.Project) .WithConversion(inverterVisibilityConverter); //Tags visibility bindingSet.Bind(AddTagsView) .For(v => v.BindVisible()) .To(vm => vm.Tags) .WithConversion(visibilityConverter); bindingSet.Bind(TagsLabel) .For(v => v.BindVisible()) .To(vm => vm.Tags) .WithConversion(inverterVisibilityConverter); //Colors bindingSet.Bind(ProjectDot) .For(v => v.BackgroundColor) .To(vm => vm.ProjectColor) .WithConversion(colorConverter); bindingSet.Apply(); }