public SiriShortcutViewModel(SiriShortcut siriShortcut, IThreadSafeProject project = null) { if (siriShortcut.VoiceShortcut != null) { VoiceShortcut = siriShortcut.VoiceShortcut; Type = VoiceShortcut.Shortcut.Intent.ShortcutType(); Title = Type.Title(); InvocationPhrase = VoiceShortcut.InvocationPhrase; IsActive = true; Description = siriShortcut.Parameters.Description; WorkspaceName = siriShortcut.Parameters.WorkspaceName; HasTags = siriShortcut.Parameters.Tags != null; IsBillable = siriShortcut.Parameters.Billable; ProjectName = project?.Name; ClientName = project?.Client?.Name; ProjectColor = project?.Color; if (Type == SiriShortcutType.CustomStart) { Title = Description == null?Type.Title() : $"Start timer: { Description }"; IsCustomStart = true; } } else { Type = siriShortcut.Type; Title = Type.Title(); IsActive = false; } }
public SiriShortcut(INVoiceShortcut voiceShortcut) { VoiceShortcut = voiceShortcut; Identifier = voiceShortcut.Identifier.AsString(); Intent = voiceShortcut.Shortcut.Intent; Type = Intent.ShortcutType(); if (Intent is ShowReportPeriodIntent showReportPeriodIntent) { Parameters.WorkspaceId = stringToLong(showReportPeriodIntent.Workspace?.Identifier); Parameters.WorkspaceName = showReportPeriodIntent.Workspace?.DisplayString; Parameters.ReportPeriod = showReportPeriodIntent.Period.ToReportPeriod(); } if (Intent is StartTimerIntent startTimerIntent) { Parameters.Description = startTimerIntent.EntryDescription; Parameters.WorkspaceId = stringToLong(startTimerIntent.Workspace?.Identifier); Parameters.WorkspaceName = startTimerIntent.Workspace?.DisplayString; Parameters.Billable = startTimerIntent.Billable?.Identifier == "True"; Parameters.Tags = startTimerIntent.Tags == null ? null : stringToLongCollection(startTimerIntent.Tags.Select(tag => tag.Identifier)); Parameters.ProjectId = stringToLong(startTimerIntent.ProjectId?.Identifier); } if (Intent is StartTimerFromClipboardIntent startTimerFromClipboardIntent) { Parameters.WorkspaceId = stringToLong(startTimerFromClipboardIntent.Workspace?.Identifier); Parameters.WorkspaceName = startTimerFromClipboardIntent.Workspace?.DisplayString; Parameters.Billable = startTimerFromClipboardIntent.Billable?.Identifier == "True"; Parameters.Tags = startTimerFromClipboardIntent.Tags == null ? null : stringToLongCollection(startTimerFromClipboardIntent.Tags.Select(tag => tag.Identifier)); Parameters.ProjectId = stringToLong(startTimerFromClipboardIntent.ProjectId?.Identifier); } }
public void DidFinish(INUIAddVoiceShortcutViewController controller, INVoiceShortcut voiceShortcut, NSError error) { controller.DismissViewController(true, null); ViewModel.CloseWithDefaultResult(); }
// IINUIEditVoiceShortcutViewControllerDelegate public void DidUpdate(INUIEditVoiceShortcutViewController controller, INVoiceShortcut voiceShortcut, NSError error) { refreshSubject.OnNext(Unit.Default); controller.DismissViewController(true, null); }