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() { //Text DescriptionLabel.Text = Item.Description; ProjectLabel.AttributedText = projectTaskClientToAttributedString.Convert( Item.ProjectName, Item.TaskName, Item.ClientName, new Color(Item.ProjectColor).ToNativeColor()); //Visibility DescriptionTopDistanceConstraint.Constant = Item.HasProject ? HasProjectDistance : NoProjectDistance; ProjectLabel.Hidden = !Item.HasProject; }
protected override void UpdateView() { updateAccessibilityProperties(); // Text DescriptionLabel.Text = Item.HasDescription ? Item.Description : Resources.AddDescription; ProjectTaskClientLabel.AttributedText = projectTaskClientToAttributedString.Convert(Item); TimeLabel.Text = Item.Duration; // Colors DescriptionLabel.TextColor = Item.HasDescription ? ColorAssets.Text : ColorAssets.Text3; ContentView.BackgroundColor = ColorAssets.CellBackground; // Visibility ProjectTaskClientFadeView.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; switch (Item.VisualizationIntent) { case LogItemVisualizationIntent.SingleItem: presentAsSingleTimeEntry(); break; case LogItemVisualizationIntent.GroupItem: presentAsTimeEntryInAGroup(); break; case LogItemVisualizationIntent.CollapsedGroupHeader: presentAsCollapsedGroupHeader(Item.RepresentedTimeEntriesIds.Length); break; case LogItemVisualizationIntent.ExpandedGroupHeader: presentAsExpandedGroupHeader(Item.RepresentedTimeEntriesIds.Length); break; default: throw new ArgumentOutOfRangeException($"Cannot visualize {Item.VisualizationIntent} in the time entries log table."); } }
protected override void UpdateView() { var projectColor = new Color(Item.ProjectColor).ToNativeColor(); TitleLabel.Text = Item.Title; DetailsLabel.TextColor = Colors.Siri.InvocationPhrase.ToNativeColor(); if (Item.ProjectName == null) { DetailsLabel.Text = $"in {Item.WorkspaceName}"; } else { DetailsLabel.AttributedText = projectTaskClientToAttributedString.Convert(Item.ProjectName, null, Item.ClientName, projectColor); } InvocationLabel.Text = $"\"{Item.InvocationPhrase}\""; InvocationLabel.TextColor = Colors.Siri.InvocationPhrase.ToNativeColor(); BillableIcon.Hidden = !Item.IsBillable; TagsIcon.Hidden = !Item.HasTags; }
protected override void UpdateView() { var projectColor = new Color(Item.ProjectColor).ToNativeColor(); TitleLabel.Text = Item.Title; DetailsLabel.TextColor = ColorAssets.Text2; if (Item.ProjectName == null) { DetailsLabel.Text = string.Format(Resources.CustomSiriShortcutCellIn, Item.WorkspaceName); } else { DetailsLabel.AttributedText = projectTaskClientToAttributedString.Convert(Item.ProjectName, null, Item.ClientName, projectColor); } InvocationLabel.Text = $"\"{Item.InvocationPhrase}\""; InvocationLabel.TextColor = ColorAssets.Text2; BillableIcon.Hidden = !Item.IsBillable; TagsIcon.Hidden = !Item.HasTags; }
public override void ViewDidLoad() { base.ViewDidLoad(); prepareViews(); prepareSiriButton(); localizeLabels(); BillableSwitch.Rx().Changed() .Select(_ => BillableSwitch.On) .Subscribe(ViewModel.IsBillable.Accept) .DisposedBy(DisposeBag); TagsTextView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); ViewModel.HasTags .Invert() .Subscribe(AddTagsView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.HasTags .Subscribe(TagsTextView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.TagNames .Select(tagsListToAttributedString.Convert) .Subscribe(TagsTextView.Rx().AttributedTextObserver()) .DisposedBy(DisposeBag); SelectTagsView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); SelectProjectView.Rx() .BindAction(ViewModel.SelectProject) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => projectTaskClientToAttributedString.Convert( info.Project, info.Task, info.Client, new Color(info.ProjectColor).ToNativeColor())) .Subscribe(ProjectTaskClientLabel.Rx().AttributedText()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => info.HasProject) .Subscribe(ProjectTaskClientLabel.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => !info.HasProject) .Subscribe(AddProjectAndTaskView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.IsBillable .Subscribe(BillableSwitch.Rx().CheckedObserver()) .DisposedBy(DisposeBag); ViewModel.IsBillableAvailable .Subscribe(BillableView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Invert() .Subscribe(DescriptionTextView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(DescriptionUsingClipboardWrapperView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(PasteFromClipboardHintView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Select(enabled => enabled ? pasteFromClipboardButtonImageEnabled : pasteFromClipboardButtonImage) .Subscribe(image => { PasteFromClipboardButton.SetImage(image, UIControlState.Normal); }) .DisposedBy(DisposeBag); ViewModel.PasteFromClipboard .Subscribe(enabled => { if (enabled) { DescriptionTextView.ResignFirstResponder(); } else { DescriptionTextView.BecomeFirstResponder(); } }) .DisposedBy(DisposeBag); DescriptionTextView.TextObservable .Subscribe(ViewModel.Description.Accept) .DisposedBy(DisposeBag); PasteFromClipboardButton.Rx() .BindAction(ViewModel.SelectClipboard) .DisposedBy(DisposeBag); }
public override void ViewDidLoad() { base.ViewDidLoad(); projectTaskClientToAttributedString = new ProjectTaskClientToAttributedString( ProjectTaskClientLabel.Font.CapHeight, Colors.EditTimeEntry.ClientText.ToNativeColor()); tagsListToAttributedString = new TagsListToAttributedString(TagsTextView); localizeLabels(); prepareViews(); prepareOnboarding(); contentSizeChangedDisposable = ScrollViewContent.AddObserver(boundsKey, NSKeyValueObservingOptions.New, onContentSizeChanged); DescriptionTextView.Text = ViewModel.Description.Value; ViewModel.Preferences .Select(preferences => preferences.DurationFormat) .Select(format => ViewModel.GroupDuration.ToFormattedString(format)) .Subscribe(GroupDuration.Rx().Text()) .DisposedBy(DisposeBag); CloseButton.Rx().Tap() .Subscribe(ViewModel.CloseWithDefaultResult) .DisposedBy(DisposeBag); ConfirmButton.Rx() .BindAction(ViewModel.Save) .DisposedBy(DisposeBag); DescriptionTextView.TextObservable .Subscribe(ViewModel.Description.Accept) .DisposedBy(DisposeBag); DescriptionTextView.SizeChangedObservable .Subscribe(adjustHeight) .DisposedBy(DisposeBag); ViewModel.SyncErrorMessage .Subscribe(ErrorMessageLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.IsSyncErrorMessageVisible .Subscribe(ErrorView.Rx().IsVisible()) .DisposedBy(DisposeBag); ErrorView.Rx().Tap() .Subscribe(ViewModel.DismissSyncErrorMessage.Inputs) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => projectTaskClientToAttributedString.Convert( info.Project, info.Task, info.Client, new Color(info.ProjectColor).ToNativeColor())) .Subscribe(ProjectTaskClientLabel.Rx().AttributedText()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => info.HasProject) .Subscribe(ProjectTaskClientLabel.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.ProjectClientTask .Select(info => !info.HasProject) .Subscribe(AddProjectAndTaskView.Rx().IsVisible()) .DisposedBy(DisposeBag); SelectProject.Rx() .BindAction(ViewModel.SelectProject) .DisposedBy(DisposeBag); TagsTextView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); AddTagsView.Rx() .BindAction(ViewModel.SelectTags) .DisposedBy(DisposeBag); var containsTags = ViewModel.Tags .Select(tags => tags.Any()); containsTags .Invert() .Subscribe(AddTagsView.Rx().IsVisible()) .DisposedBy(DisposeBag); containsTags .Subscribe(TagsTextView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.IsBillable .Subscribe(BillableSwitch.Rx().CheckedObserver()) .DisposedBy(DisposeBag); BillableSwitch.Rx().Changed() .Subscribe(ViewModel.ToggleBillable.Inputs) .DisposedBy(DisposeBag); ViewModel.IsBillableAvailable .Subscribe(BillableView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.IsInaccessible .Subscribe(adjustUIForInaccessibleTimeEntry) .DisposedBy(DisposeBag); ViewModel.StartTime .WithLatestFrom(ViewModel.Preferences, (startTime, preferences) => DateTimeToFormattedString.Convert( startTime, preferences.TimeOfDayFormat.Format)) .Subscribe(StartTimeLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.StartTime .WithLatestFrom(ViewModel.Preferences, (startTime, preferences) => DateTimeToFormattedString.Convert( startTime, preferences.DateFormat.Short)) .Subscribe(StartDateLabel.Rx().Text()) .DisposedBy(DisposeBag); StartTimeView.Rx().Tap() .SelectValue(EditViewTapSource.StartTime) .Subscribe(ViewModel.EditTimes.Inputs) .DisposedBy(DisposeBag); StartDateView.Rx().Tap() .Subscribe(ViewModel.SelectStartDate.Inputs) .DisposedBy(DisposeBag); ViewModel.IsTimeEntryRunning .Subscribe(StopButton.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.IsTimeEntryRunning .Select(CommonFunctions.Invert) .Subscribe(EndTimeLabel.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.StopTime .Where(stopTime => stopTime.HasValue) .Select(stopTime => stopTime.Value) .WithLatestFrom(ViewModel.Preferences, (stopTime, preferences) => DateTimeToFormattedString.Convert( stopTime, preferences.TimeOfDayFormat.Format)) .Subscribe(EndTimeLabel.Rx().Text()) .DisposedBy(DisposeBag); EndTimeView.Rx().Tap() .SelectLatestFrom(ViewModel.IsTimeEntryRunning) .Invert() .Where(CommonFunctions.Identity) .SelectValue(EditViewTapSource.StopTime) .Subscribe(ViewModel.EditTimes.Inputs) .DisposedBy(DisposeBag); EndTimeView.Rx().Tap() .Merge(StopButton.Rx().Tap()) .SelectLatestFrom(ViewModel.IsTimeEntryRunning) .Where(CommonFunctions.Identity) .SelectUnit() .Subscribe(ViewModel.StopTimeEntry.Inputs) .DisposedBy(DisposeBag); ViewModel.Duration .WithLatestFrom(ViewModel.Preferences, (duration, preferences) => duration.ToFormattedString(preferences.DurationFormat)) .Subscribe(DurationLabel.Rx().Text()) .DisposedBy(DisposeBag); DurationView.Rx().Tap() .SelectValue(EditViewTapSource.Duration) .Subscribe(ViewModel.EditTimes.Inputs) .DisposedBy(DisposeBag); DeleteButton.Rx() .BindAction(ViewModel.Delete) .DisposedBy(DisposeBag); }