Branchwell

Jotley / app · jotley.ai / iOS / Views / iOSNoteDetailView+Body.swift

Raw 26.9 KB on c22c50f3614b055549c1ecbf54af0165e0bc8df1
1import SwiftUI
2
3extension NoteDetailView {
4 var body: some View {
5 ScrollView {
6 VStack(spacing: 0) {
7 noteHeaderSection
8 if hasTranscript || hasSummary { noteTabPickerSection }
9 if selectedTab == "Summary", hasSummary {
10 if summaryIsRunning && transcriptionManager.summaryPreview.isEmpty {
11 Text("Long transcripts are reviewed in sections on this device. Your summary will appear here as it is written. You can leave this note or lock your phone; the summary keeps going and is saved when it finishes.")
12 .font(.body).foregroundColor(.themeTextSecondary)
13 .frame(maxWidth: .infinity, alignment: .leading).padding()
14 } else {
15 StructuredSummaryView(content: summaryIsRunning ? transcriptionManager.summaryPreview : note.summary ?? "", isStreaming: summaryIsRunning)
16 .padding(.horizontal).accessibilityIdentifier("noteDetailSummaryContent")
17 }
18 } else if hasTranscript || noteIsTranscribing {
19 transcriptContent.padding(.horizontal)
20 } else {
21 ContentUnavailableView("No Words Yet", systemImage: "text.bubble", description: Text("Tap Continue Transcription to add spoken words to this note."))
22 }
23 }
24 .padding(.bottom, actionsFooterHeight + 16)
25 }
26 .scrollPosition($summaryScrollPosition)
27 .onScrollGeometryChange(for: NoteScrollRange.self) { geometry in
28 NoteScrollRange(geometry)
29 } action: { _, range in
30 updateScrollJump(range)
31 }
32 .onScrollGeometryChange(for: CGFloat.self) { $0.contentSize.height } action: { previous, height in
33 guard isWritingVisibleSummary, followsLiveSummary, previous != height else { return }
34 // Move only after the new text has a measured height.
35 summaryScrollPosition.scrollTo(edge: .bottom)
36 }
37 .onScrollPhaseChange { _, phase, context in
38 jumpScrollPhase = phase
39 if phase == .interacting {
40 jumpScrollAnchor = NoteScrollRange(context.geometry).offset
41 jumpDestination = nil
42 }
43 guard isWritingVisibleSummary else { return }
44 if phase == .interacting {
45 followsLiveSummary = false
46 } else if phase == .idle {
47 let geometry = context.geometry
48 followsLiveSummary = geometry.visibleRect.maxY >= geometry.contentSize.height - 40
49 }
50 }
51 .task(id: jumpScrollPhase) {
52 guard jumpScrollPhase == .idle, jumpDestination != nil else { return }
53 // Leave a short window to tap the arrow after the scroll settles.
54 do { try await Task.sleep(for: .seconds(1.5)) }
55 catch { return }
56 guard jumpScrollPhase == .idle else { return }
57 jumpDestination = nil
58 }
59 .onChange(of: isWritingVisibleSummary) { _, writing in
60 if !writing { followsLiveSummary = true }
61 }
62 .background(Color.themeBackground)
63 .navigationBarTitleDisplayMode(.inline)
64 .overlay(alignment: .bottom) {
65 if newTranscriptionAction == nil {
66 noteActionsFooter
67 }
68 }
69 .preference(key: NoteFooterContentKey.self,
70 value: newTranscriptionAction != nil ? note.id.map { [$0: AnyView(noteActionsFooter)] } ?? [:] : [:])
71 .sheet(isPresented: $showingTranscriptEditor, onDismiss: { selectedTab = "Transcript" }) { MobileNoteTextEditor(note: note, field: .transcript) }
72 .sheet(isPresented: $showingSummaryEditor, onDismiss: { selectedTab = hasSummary ? "Summary" : "Transcript" }) { MobileNoteTextEditor(note: note, field: .summary) }
73 .sheet(item: $templatePresentation) { presentation in
74 NavigationStack {
75 Group {
76 if presentation == .create {
77 NewSummaryTemplateView(onSaved: { templatePresentation = nil }, onUse: { definition in
78 templatePresentation = nil; selectTemplate(definition)
79 })
80 } else {
81 SummaryTemplatesView(onUse: { definition in templatePresentation = nil; selectTemplate(definition) })
82 }
83 }
84 .toolbar {
85 ToolbarItem(placement: .cancellationAction) {
86 Button("Done") { templatePresentation = nil }
87 .jotleyDismissButtonStyle(inToolbar: true)
88 }
89 .sharedBackgroundVisibility(.hidden)
90 }
91 }
92 }
93 .sheet(isPresented: $showingAskAI) { LocalAskNoteView(note: note) }
94 .sheet(isPresented: $showingTranscription, onDismiss: { selectedTab = "Transcript" }) { LiveTranscriptionView(isPresented: $showingTranscription, existingNote: note, transcriptionManager: transcriptionManager) }
95 .sheet(isPresented: $showingAddTag) {
96 AddTagSheetView(note: note, isPresented: $showingAddTag, newTagText: $newTagText, currentTags: $currentTags, onSave: transcriptionManager.saveEdits)
97 }
98 .sheet(item: $exportPayload, onDismiss: clearExport) { payload in ShareSheet(activityItems: payload.items) }
99 .alert("Move to Trash?", isPresented: $showingDelete) {
100 Button("Cancel", role: .cancel) { }
101 Button("Move to Trash", role: .destructive) {
102 do { try transcriptionManager.delete(note); dismiss() } catch { transcriptionManager.errorMessage = error.localizedDescription }
103 }
104 } message: { Text("You can restore this note from Trash.") }
105 .onAppear { currentTags = note.tagNames; if hasSummary { selectedTab = "Summary" } }
106 .onChange(of: note.tagNames) { _, tags in
107 currentTags = tags
108 if tags.isEmpty { isTagsExpanded = false }
109 }
110 .onChange(of: selectedTab) { _, _ in jumpDestination = nil }
111 .onChange(of: isTitleFieldFocused) { _, focused in if !focused { isEditingTitle = false } }
112 .onChange(of: hasSummary) { _, available in if !available { selectedTab = "Transcript" } }
113 .onChange(of: summaryIsRunning) { _, running in if running { selectedTab = "Summary" } }
114 .tint(.themeActionText)
115 .observeThemeChanges()
116 }
117 private var isWritingVisibleSummary: Bool { summaryIsRunning && selectedTab == "Summary" }
118
119 private func updateScrollJump(_ range: NoteScrollRange) {
120 if jumpScrollPhase == .interacting {
121 let travel = range.offset - jumpScrollAnchor
122 if abs(travel) >= 3 {
123 jumpDestination = travel > 0 ? .bottom : .top
124 jumpScrollAnchor = range.offset
125 }
126 }
127 // Hide at either destination and on pages that fit in the viewport.
128 guard let jumpDestination else { return }
129 let remaining = jumpDestination == .top ? range.offset : range.maximumOffset - range.offset
130 if range.maximumOffset <= 24 || remaining <= 12 {
131 self.jumpDestination = nil
132 }
133 }
134
135 private func scrollJumpButton(to destination: VerticalEdge) -> some View {
136 Button {
137 jumpDestination = nil
138 if isWritingVisibleSummary { followsLiveSummary = false }
139 withAnimation(reduceMotion ? nil : .easeInOut(duration: 0.3)) {
140 summaryScrollPosition.scrollTo(edge: destination == .top ? .top : .bottom)
141 }
142 if isWritingVisibleSummary && destination == .bottom { followsLiveSummary = true }
143 } label: {
144 Image(systemName: destination == .top ? "arrow.up" : "arrow.down")
145 .font(.system(size: 16, weight: .semibold))
146 }
147 .buttonStyle(JotleyGlassButtonStyle(circular: true, floatsOverContent: true))
148 .accessibilityLabel(destination == .top ? Text("Jump to top") : Text("Jump to bottom"))
149 .accessibilityIdentifier(destination == .top ? "noteDetailJumpTop" : "noteDetailJumpBottom")
150 }
151
152 @ViewBuilder private var scrollJumpControl: some View {
153 if let jumpDestination {
154 scrollJumpButton(to: jumpDestination)
155 }
156 }
157
158 private var noteHeaderActions: some View {
159 HStack(spacing: 10) {
160 Menu {
161 Button("Copy", systemImage: "doc.on.doc") { UIPasteboard.general.string = selectedTab == "Summary" ? note.summary : note.transcription }
162 .accessibilityIdentifier("copyCurrentTabButton")
163 Button("Share as Text", systemImage: "square.and.arrow.up", action: shareAsText)
164 .accessibilityIdentifier("shareNoteButton")
165 if Note.isMeaningfulSummaryText(note.summary) {
166 Button("Share Summary as PDF", systemImage: "doc.richtext", action: shareSummaryPDF)
167 .disabled(summaryIsRunning)
168 .accessibilityIdentifier("shareSummaryPDFButton")
169 }
170 Divider()
171 Menu("More Export Options", systemImage: "ellipsis.circle") {
172 Button("Full Note (Plain Text)") { export(.plainText) }.accessibilityIdentifier("exportPlainTextButton")
173 Button("Full Note (Formatted)") { export(.markdown) }.accessibilityIdentifier("exportMarkdownButton")
174 if Note.isMeaningfulSummaryText(note.summary) {
175 Button("Summary Only") { export(.summary) }.accessibilityIdentifier("exportSummaryButton")
176 }
177 if !transcript.isEmpty {
178 Button("Transcript Only") { export(.transcript) }.accessibilityIdentifier("exportTranscriptButton")
179 }
180 }
181 } label: {
182 noteHeaderMenuLabel
183 }
184 .buttonStyle(.glass)
185 .buttonBorderShape(.circle)
186 .overlay { noteHeaderMenuIcon("square.and.arrow.up", verticalOffset: -1.5) }
187 .accessibilityLabel("Share Actions").accessibilityIdentifier("noteDetailShareButton")
188 Menu {
189 Button { showingAskAI = true } label: {
190 MobileActionLabel("Ask AI", systemImage: "bubble.left.and.bubble.right")
191 }
192 .disabled((!hasTranscript && !hasSummary) || noteIsTranscribing || summaryIsRunning)
193 .accessibilityIdentifier("noteDetailAskAIButton")
194 Menu("Summary Style", systemImage: "text.alignleft") {
195 SummaryDisplayStylePicker().pickerStyle(.inline)
196 }.accessibilityIdentifier("noteDetailSummaryStyleMenu")
197 if hasTranscript {
198 Menu("Template", systemImage: "sparkles") {
199 summaryTemplateChoices
200 }
201 .disabled(!transcriptionManager.canStart)
202 .accessibilityIdentifier("noteDetailSummaryTemplateMenu")
203 if note.hasMeaningfulSummaryText {
204 Button("Regenerate Summary", systemImage: "arrow.clockwise") { generateSummary() }
205 .disabled(!transcriptionManager.canStart)
206 .accessibilityIdentifier("noteDetailRegenerateSummaryMenuButton")
207 } else if !summaryIsRunning {
208 Button("Generate Summary", systemImage: "sparkles") { generateSummary() }
209 .disabled(!transcriptionManager.canStart)
210 .accessibilityIdentifier("noteDetailGenerateSummaryMenuButton")
211 }
212 }
213 if hasTranscript || Note.isMeaningfulSummaryText(note.summary) { Divider() }
214 if Note.isMeaningfulSummaryText(note.summary) {
215 Button("Edit Summary", systemImage: "pencil") { showingSummaryEditor = true }
216 .disabled(!transcriptionManager.canStart)
217 .accessibilityIdentifier("noteDetailEditSummaryButton")
218 }
219 if hasTranscript {
220 Button("Edit Transcript", systemImage: "pencil") { showingTranscriptEditor = true }
221 .disabled(!transcriptionManager.canStart)
222 .accessibilityIdentifier("noteDetailEditTranscriptButton")
223 }
224 Button("Continue", systemImage: "mic.fill") { showingTranscription = true }
225 .disabled(!transcriptionManager.canStart && !noteIsTranscribing)
226 .accessibilityIdentifier("noteDetailContinueTranscriptionMenuButton")
227 if InkspringIdeaLink.isInstalled {
228 Button("Post Idea to Inkspring", systemImage: "lightbulb") {
229 InkspringIdeaLink.send(title: note.title, summary: note.summary, transcript: transcript)
230 }
231 .disabled(!hasTranscript && !note.hasMeaningfulSummaryText)
232 .accessibilityIdentifier("noteDetailPostIdeaToInkspringButton")
233 }
234 Divider()
235 Button("Move to Trash", role: .destructive) { showingDelete = true }.disabled(!transcriptionManager.canStart)
236 } label: { noteHeaderMenuLabel }
237 .buttonStyle(.glass)
238 .buttonBorderShape(.circle)
239 .overlay { noteHeaderMenuIcon("ellipsis") }
240 .accessibilityLabel("More Actions")
241 .accessibilityIdentifier("noteDetailMoreActionsButton")
242 }
243 .menuIndicator(.hidden)
244 }
245
246 private var noteHeaderMenuLabel: some View {
247 Color.clear.frame(width: 24, height: 24)
248 }
249
250 private func noteHeaderMenuIcon(_ systemImage: String, verticalOffset: CGFloat = 0) -> some View {
251 Image(systemName: systemImage)
252 .font(.system(size: 16, weight: .semibold))
253 .foregroundStyle(headerIconColor)
254 .offset(y: verticalOffset)
255 .allowsHitTesting(false)
256 .accessibilityHidden(true)
257 }
258
259 private var noteHeaderSection: some View {
260 VStack(alignment: .leading, spacing: 8) {
261 HStack(alignment: .top, spacing: 8) {
262 Group {
263 if isEditingTitle {
264 TextField("Untitled", text: $editedTitle)
265 .tint(Color.themePrimaryAccent)
266 .focused($isTitleFieldFocused).submitLabel(.done)
267 .accessibilityIdentifier("noteDetailTitleEditor")
268 .onChange(of: editedTitle) { _, value in note.title = value; transcriptionManager.saveEdits() }
269 .onSubmit { isEditingTitle = false; isTitleFieldFocused = false }
270 } else {
271 Text(note.titleOrUntitled).accessibilityIdentifier("noteDetailTitle")
272 .onTapGesture { editedTitle = note.title ?? ""; isEditingTitle = true; isTitleFieldFocused = true }
273 }
274 }
275 .font(.title2.bold()).foregroundColor(Color(uiColor: .label))
276 .frame(maxWidth: .infinity, minHeight: 44, alignment: .leading)
277 noteHeaderActions.fixedSize(horizontal: true, vertical: false)
278 }
279 .padding(.horizontal)
280 if let timestamp = note.timestamp {
281 Text(timestamp, format: .dateTime.weekday(.wide).month(.wide).day().year().hour(.defaultDigits(amPM: .abbreviated)).minute())
282 .font(.subheadline).foregroundColor(.themeTextSecondary).padding(.horizontal)
283 .accessibilityIdentifier("noteDetailTimestamp")
284 }
285 noteOrganization
286 }.frame(maxWidth: .infinity, alignment: .leading).padding(.top,8).padding(.bottom,16)
287 }
288
289 private var noteOrganization: some View {
290 let tags = note.tagNames
291 return VStack(alignment: .leading, spacing: 2) {
292 FlowLayout(spacing: 8) {
293 iOSNoteFolderRow(note: note, onChange: transcriptionManager.saveEdits)
294 if tags.isEmpty {
295 addTagButton
296 } else {
297 Button { isTagsExpanded.toggle() } label: {
298 HStack(spacing: 5) {
299 Image(systemName: "tag")
300 .foregroundStyle(Color.themePrimaryAccent)
301 .accessibilityHidden(true)
302 Text("\(tags.count) tags")
303 .foregroundStyle(.primary)
304 Image(systemName: isTagsExpanded ? "chevron.down" : "chevron.right")
305 .font(.caption2.weight(.semibold))
306 .foregroundStyle(.secondary)
307 .accessibilityHidden(true)
308 }
309 .noteMetadataPill(font: .footnote.weight(.medium), minHeight: 27)
310 .frame(minHeight: 44)
311 .contentShape(Rectangle())
312 }
313 .buttonStyle(.plain)
314 .accessibilityValue(isTagsExpanded ? Text("Expanded") : Text("Collapsed"))
315 .accessibilityIdentifier("noteDetailTagCount")
316 }
317 }
318 if isTagsExpanded && !tags.isEmpty {
319 FlowLayout(spacing: 8) {
320 ForEach(tags, id: \.self) { tag in
321 iOSTagView(tag: tag, onRemove: {
322 note.removeTagByName(tag)
323 currentTags = note.tagNames
324 transcriptionManager.saveEdits()
325 })
326 .accessibilityIdentifier("noteDetailTag-\(tag)")
327 }
328 addTagButton
329 }
330 }
331 }
332 .padding(.horizontal)
333 }
334
335 private var addTagButton: some View {
336 Button { showingAddTag = true } label: {
337 JotleyAccentIconLabel(title: "Add Tag", systemImage: "plus.circle")
338 .noteMetadataPill(font: .footnote.weight(.medium), minHeight: 27)
339 .frame(minHeight: 44)
340 .contentShape(Rectangle())
341 }
342 .buttonStyle(.plain)
343 .disabled(note.tagSet.count >= LocalNoteTags.maximumCount)
344 .accessibilityHint(note.tagSet.count >= LocalNoteTags.maximumCount ? "Remove a tag to add another." : "")
345 .accessibilityIdentifier("noteDetailAddTagButton")
346 }
347
348 private var noteTabPickerSection: some View {
349 HStack {
350 NoteContentSwitch(selection: $selectedTab, showsSummary: hasSummary, animatesSelection: false)
351 Spacer()
352 }.padding(.horizontal).padding(.bottom,16)
353 }
354 @ViewBuilder private var transcriptContent: some View {
355 if !note.transcriptUtterances.isEmpty {
356 LazyVStack(alignment: .leading, spacing: 8) {
357 ForEach(note.transcriptUtterances) { utterance in
358 TranscriptBubbleView(text: utterance.text, timestampText: utterance.timestampLabel, allowsTextSelection: true)
359 }
360 }.accessibilityIdentifier("noteDetailTranscriptContent")
361 } else {
362 TranscriptBubbleView(text: transcript, allowsTextSelection: true)
363 .accessibilityIdentifier("noteDetailTranscriptContent")
364 }
365 }
366 private var noteActionsFooter: some View {
367 Group {
368 if summaryIsRunning { summaryProgressFooter }
369 else { transcriptionAndSummaryFooter }
370 }
371 .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { actionsFooterHeight = $0 }
372 }
373
374 private var summaryProgressFooter: some View {
375 VStack(spacing: 10) {
376 HStack(spacing: 12) {
377 ProgressView().tint(.themePrimaryAccent)
378 VStack(alignment: .leading, spacing: 3) {
379 Text(transcriptionManager.summaryProgress.title).font(.body.weight(.semibold))
380 if let detail = transcriptionManager.summaryProgress.detail {
381 Text(detail).font(.subheadline).foregroundColor(.themeTextSecondary)
382 }
383 }.frame(maxWidth: .infinity, alignment: .leading)
384 }.accessibilityIdentifier("noteDetailSummaryProgress")
385 if let fraction = transcriptionManager.summaryProgress.fraction {
386 ProgressView(value: fraction).tint(.themePrimaryAccent)
387 }
388 HStack(spacing: newTranscriptionAction == nil ? 8 : 12) {
389 scrollJumpControl
390 Button { transcriptionManager.cancelProcessing() } label: {
391 Label {
392 Text("Cancel Generation").modifier(JotleyNoteFooterTextStyle())
393 } icon: {
394 Image(systemName: "xmark.circle.fill")
395 }
396 }.jotleyDismissButtonStyle()
397 .accessibilityIdentifier("noteDetailCancelGenerationButton")
398 .frame(maxWidth: .infinity)
399 if let newTranscriptionAction {
400 NotesNewTranscriptionButton(action: newTranscriptionAction)
401 }
402 }
403 }
404 .padding(.horizontal, newTranscriptionAction == nil ? 16 : 24)
405 .padding(.top, 8).padding(.bottom, footerBottomInset)
406 .frame(maxWidth: .infinity)
407 .background(Color.themeBackground)
408 }
409
410 private var transcriptionAndSummaryFooter: some View {
411 VStack(spacing: 12) {
412 if hasTranscript && !hasSummary {
413 NoteSummaryActionsLayout(spacing: 8) {
414 summaryTemplateButton
415 primarySummaryButton
416 }
417 .frame(maxWidth: 384)
418 }
419 contextualActionsRow
420 }
421 .padding(.horizontal, newTranscriptionAction == nil ? 16 : 24)
422 .padding(.top, 16).padding(.bottom, footerBottomInset)
423 .frame(maxWidth: .infinity)
424 }
425
426 private var contextualActionsRow: some View {
427 HStack {
428 Spacer(minLength: 0)
429 contextualNoteAction
430 Spacer(minLength: 0)
431 }
432 // Keep the main action centered even when the arrow appears or disappears.
433 .padding(.horizontal, 56)
434 .frame(minHeight: 44)
435 .overlay(alignment: .leading) { scrollJumpControl }
436 .overlay(alignment: .trailing) {
437 if let newTranscriptionAction {
438 NotesNewTranscriptionButton(action: newTranscriptionAction)
439 }
440 }
441 }
442
443 private var footerBottomInset: CGFloat {
444 newTranscriptionAction == nil ? MobileNoteFooterInsets.splitBottom : MobileNoteFooterInsets.phoneBottom
445 }
446
447 @ViewBuilder private var contextualNoteAction: some View {
448 if selectedTab == "Summary" {
449 Button { showingAskAI = true } label: {
450 Label {
451 Text("Ask AI").modifier(JotleyNoteFooterTextStyle())
452 } icon: {
453 Image(systemName: "bubble.left.and.bubble.right")
454 .foregroundStyle(Color.themePrimaryAccent)
455 }
456 }
457 .buttonStyle(JotleyGlassButtonStyle(floatsOverContent: true))
458 .disabled((!hasTranscript && !hasSummary) || noteIsTranscribing || summaryIsRunning)
459 .accessibilityIdentifier("noteDetailSummaryAskAIButton")
460 } else {
461 Button { showingTranscription = true } label: {
462 Label {
463 Text("Continue Transcription").modifier(JotleyNoteFooterTextStyle())
464 } icon: {
465 Image(systemName: "waveform")
466 .foregroundStyle(Color.themePrimaryAccent)
467 }
468 .fixedSize(horizontal: false, vertical: true)
469 }
470 .buttonStyle(JotleyGlassButtonStyle(floatsOverContent: true))
471 .disabled(!transcriptionManager.canStart && !noteIsTranscribing)
472 .accessibilityIdentifier("noteDetailContinueTranscriptionButton")
473 }
474 }
475
476 @ViewBuilder private var summaryTemplateChoices: some View {
477 Button("New Template…") { templatePresentation = .create }
478 .accessibilityIdentifier("noteNewTemplateButton")
479 Button("Manage Templates…") { templatePresentation = .manage }
480 Divider()
481 if !templateCatalog.templates.isEmpty {
482 Section("My Templates") {
483 ForEach(templateCatalog.templates) { custom in
484 Button { selectTemplate(custom.definition) } label: {
485 if note.summaryType == custom.key { Label(custom.name, systemImage: "checkmark") }
486 else { Text(custom.name) }
487 }.accessibilityIdentifier("noteTemplate-\(custom.key)")
488 }
489 }
490 }
491 Section("Built-in Templates") {
492 ForEach(LocalSummaryTemplate.allCases) { builtIn in
493 let template = SummaryTemplateDefinition(builtIn)
494 Button { selectTemplate(template) } label: {
495 if note.summaryType == template.key { Label(template.title, systemImage: "checkmark") }
496 else { Text(template.title) }
497 }.accessibilityIdentifier("noteTemplate-\(template.key)")
498 }
499 }
500
501 }
502
503 private var summaryTemplateButton: some View {
504 Menu {
505 summaryTemplateChoices
506 } label: {
507 Label {
508 Text(selectedTemplateTitle).modifier(JotleyNoteFooterTextStyle())
509 } icon: {
510 Image(systemName: "sparkles")
511 .foregroundStyle(headerIconColor)
512 }
513 .font(.system(size: 15, weight: .medium))
514 .lineLimit(1).truncationMode(.tail)
515 .padding(.horizontal, 16)
516 .frame(maxWidth: .infinity, minHeight: 44)
517 .contentShape(Capsule())
518 }
519 .buttonStyle(.plain)
520 .menuIndicator(.hidden)
521 // Keeping the surface outside the native menu label avoids its extra highlight.
522 .modifier(JotleyGlassMenuLabel(shape: Capsule()))
523 .disabled(!transcriptionManager.canStart)
524 .accessibilityLabel("Templates: \(selectedTemplateTitle)")
525 .accessibilityIdentifier("noteDetailTemplatesButton")
526 }
527
528 private var primarySummaryButton: some View {
529 Button { generateSummary() } label: {
530 Text("Generate Summary")
531 .font(.system(size: 15, weight: .semibold))
532 .fixedSize(horizontal: true, vertical: false)
533 .frame(maxWidth: .infinity, minHeight: 44)
534 }
535 .buttonStyle(JotleyGlassButtonStyle(floatsOverContent: true, usesAccentForeground: true))
536 .disabled(!transcriptionManager.canStart || transcript.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
537 .accessibilityIdentifier("noteDetailGenerateSummaryButton")
538 }
539}