Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat(ios): answer Is this fix right? while listening, settle and undo fixes on a meeting record, edit a line yourself, and keep a Word list in Settings

wquguru6193a0619d47
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
index 8c9d3c5..2bd1727 100644
--- a/Resources/en.lproj/Localizable.strings
+++ b/Resources/en.lproj/Localizable.strings
@@ -1266,6 +1266,7 @@
"词表" = "Word list";
"还没有词。把常用的人名、产品名贴进来,会中就照这些写法改" = "No words yet. Paste in the names and products you often say, and meetings will use these spellings.";
"最多 %lld 个,满了优先用最近的。只存在这台 Mac 上" = "Up to %lld, recent ones first. Stored only on this Mac";
+"最多 %lld 个,满了优先用最近的。只存在这台设备上" = "Up to %lld, recent ones first. Stored only on this device";
"会中改正听错的词" = "Fix misheard words live";
"走 %@,只发文字" = "Text only, via %@";
"接上 AI 服务后才会改" = "Needs an AI service";
diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.strings
index 440e341..eb413eb 100644
--- a/Resources/ja.lproj/Localizable.strings
+++ b/Resources/ja.lproj/Localizable.strings
@@ -1266,6 +1266,7 @@
"词表" = "単語リスト";
"还没有词。把常用的人名、产品名贴进来,会中就照这些写法改" = "まだ単語がありません。よく使う人名や製品名を貼り付けると、会議中にこの表記で直します";
"最多 %lld 个,满了优先用最近的。只存在这台 Mac 上" = "最大 %lld 個、最近使ったものを優先。この Mac にだけ保存";
+"最多 %lld 个,满了优先用最近的。只存在这台设备上" = "最大 %lld 個、最近使ったものを優先。このデバイスにだけ保存";
"会中改正听错的词" = "会議中に聞き間違いを直す";
"走 %@,只发文字" = "%@ 経由、テキストのみ";
"接上 AI 服务后才会改" = "AI サービスに接続すると使えます";
diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.strings
index 1430081..7734a72 100644
--- a/Resources/ko.lproj/Localizable.strings
+++ b/Resources/ko.lproj/Localizable.strings
@@ -1266,6 +1266,7 @@
"词表" = "단어 목록";
"还没有词。把常用的人名、产品名贴进来,会中就照这些写法改" = "아직 단어가 없습니다. 자주 쓰는 이름과 제품명을 붙여 넣으면 회의 중 이 표기로 고칩니다";
"最多 %lld 个,满了优先用最近的。只存在这台 Mac 上" = "최대 %lld개, 최근 것을 우선. 이 Mac에만 저장";
+"最多 %lld 个,满了优先用最近的。只存在这台设备上" = "최대 %lld개, 최근 것을 우선. 이 기기에만 저장";
"会中改正听错的词" = "회의 중 잘못 들은 단어 고치기";
"走 %@,只发文字" = "%@ 사용, 텍스트만 전송";
"接上 AI 服务后才会改" = "AI 서비스를 연결하면 사용할 수 있습니다";
diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.strings
index 56e45dd..bde4efb 100644
--- a/Resources/zh-Hans.lproj/Localizable.strings
+++ b/Resources/zh-Hans.lproj/Localizable.strings
@@ -1266,6 +1266,7 @@
"词表" = "词表";
"还没有词。把常用的人名、产品名贴进来,会中就照这些写法改" = "还没有词。把常用的人名、产品名贴进来,会中就照这些写法改";
"最多 %lld 个,满了优先用最近的。只存在这台 Mac 上" = "最多 %lld 个,满了优先用最近的。只存在这台 Mac 上";
+"最多 %lld 个,满了优先用最近的。只存在这台设备上" = "最多 %lld 个,满了优先用最近的。只存在这台设备上";
"会中改正听错的词" = "会中改正听错的词";
"走 %@,只发文字" = "走 %@,只发文字";
"接上 AI 服务后才会改" = "接上 AI 服务后才会改";
diff --git a/ios/Sources/Cicada/CicadaApp.swift b/ios/Sources/Cicada/CicadaApp.swift
index b75c7e7..d1195b0 100644
--- a/ios/Sources/Cicada/CicadaApp.swift
+++ b/ios/Sources/Cicada/CicadaApp.swift
@@ -104,6 +104,15 @@ final class AppModel: ObservableObject {
@Published var speakerUndo: SpeakerUndo?
/// The speaker number whose 是谁 prompt is open on the record page.
@Published var namingSpeaker: Int?
+ /// 改正听错的词: the line being rewritten (改这句…), the record line tapped open, and 设置 › 词表's
+ /// state (pushed, 粘贴导入's text, the word being edited, the word just deleted).
+ @Published var editingLine: LineEdit?
+ @Published var openLine: String?
+ @Published var showWordList = false
+ @Published var wordImport: String?
+ @Published var editingWord: String?
+ @Published var deletedWord: DeletedWord?
+ @Published var wordConflict: WordConflict?
/// Dev only: the iPad window size `window:` lays the app out at (DevWindow in Debug.swift).
@Published var devWindow: CGSize?
@@ -214,6 +223,31 @@ final class AppModel: ObservableObject {
debugLog("delete \(id) sessions=\(store.sessions.count)")
}
+ // MARK: 词表
+
+ /// Swiped away: 撤销 in its place for a few seconds, as on the Mac.
+ func deleteWord(_ t: Vocabulary.Term) {
+ let index = vocabulary.terms.firstIndex(of: t) ?? 0
+ vocabulary.remove(t.word)
+ let d = DeletedWord(term: t, index: index)
+ deletedWord = d
+ if editingWord == t.word { editingWord = nil }
+ DispatchQueue.main.asyncAfter(deadline: .now() + 8) { [weak self] in
+ if self?.deletedWord == d { self?.deletedWord = nil }
+ }
+ }
+
+ /// A heard form typed on a word: added, or, when another word has it, asked about (改给 / 两个都留).
+ func addHeard(_ text: String, to t: Vocabulary.Term) {
+ let h = text.trimmingCharacters(in: .whitespaces)
+ guard !h.isEmpty, h.count <= 40 else { return }
+ if let owner = vocabulary.owners(ofHeard: h, except: t.word).first {
+ wordConflict = WordConflict(word: t.word, heard: h, owner: owner)
+ } else {
+ vocabulary.confirm(heard: h, word: t.word, source: t.source)
+ }
+ }
+
// MARK: Speakers (the Mac's AppModel.renameSpeaker / mergeSpeaker / undoSpeakerEdit)
/// Name a voice ("" keeps 说话人 N, nil goes back to Ling's guess).
diff --git a/ios/Sources/Cicada/Debug.swift b/ios/Sources/Cicada/Debug.swift
index d02b3f2..157022f 100644
--- a/ios/Sources/Cicada/Debug.swift
+++ b/ios/Sources/Cicada/Debug.swift
@@ -198,6 +198,28 @@ extension AppModel {
if let l = store.session(id)?.lines.first(where: { $0.id == parts.first }), let f = l.fixes?.first(where: \.applied) {
fixes.revert(f, lineID: l.id, in: id)
}
+ // The fix screens, for screenshots: a record line tapped open, 改这句… on a line (of the open
+ // record), 设置 › 词表, 粘贴导入 with text ("|" for new lines), a word opened, a word swiped away.
+ case "openLine": openLine = arg.isEmpty ? nil : arg
+ case "scrollTo": NotificationCenter.default.post(name: .debugScroll, object: arg)
+ case "fixEditor": // fixEditor:<line id>[=<start text>]
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ let sid = selection ?? fixSession
+ if let l = store.session(sid)?.lines.first(where: { $0.id == p.first }) {
+ editingLine = LineEdit(session: sid, line: l.id, start: p.count > 1 ? p[1] : l.shown)
+ }
+ case "closeEditor": editingLine = nil
+ case "wordList":
+ tab = .settings
+ showSettings = true
+ showWordList = arg != "off"
+ case "wordImport": wordImport = arg == "off" ? nil : arg.replacingOccurrences(of: "|", with: "\n")
+ case "wordEdit": editingWord = arg.isEmpty ? nil : arg
+ case "wordHeard": // wordHeard:<word>=<heard form>, as typed on an opened word
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ if p.count == 2, let t = vocabulary.terms.first(where: { $0.word == p[0] }) { addHeard(p[1], to: t) }
+ case "wordDelete":
+ if let t = vocabulary.terms.first(where: { $0.word == arg }) { deleteWord(t) }
case "state":
debugLog("room running=\(room.isRunning) lines=\(room.lines.count) draft=\(room.draft.count) level=\(room.level) status=\(room.status) session=\(room.sessionID ?? "-")")
debugLog("state tab=\(tab.rawValue) selection=\(selection ?? "-") page=\(recordPage) sessions=\(store.sessions.count) query=\(query) notesLang=\(notesLanguageCode(selection ?? store.sessions.first?.id ?? "")) undo=\(speakerUndo?.text ?? "-")")
diff --git a/ios/Sources/Cicada/FixViews.swift b/ios/Sources/Cicada/FixViews.swift
index 6fd00b0..2d52d87 100644
--- a/ios/Sources/Cicada/FixViews.swift
+++ b/ios/Sources/Cicada/FixViews.swift
@@ -1,6 +1,9 @@
import SwiftUI
-/// 改正听错的词 on iPhone and iPad: a line as shown, its fixed words with the Mac's dotted underline.
+// 改正听错的词 on iPhone and iPad: the Mac's FixViews and WordListSettings in iOS idiom. The engine
+// is the Mac's own (`LiveFixes`, `Vocabulary`); these only show it and pass taps back.
+
+/// A line as shown, its fixed words with the Mac's dotted underline.
enum FixedText {
/// The line with its applied fixes; each fixed word dotted, a word still waiting (这样改对吗?)
/// on a pale wash as heard. The Mac's `TranscriptParagraphs.joinFixed` for one line.
@@ -16,4 +19,521 @@ enum FixedText {
}
return a
}
+
+ /// The line's applied fixes, as the user sees them ("莫拉" → "Morpho").
+ static func applied(_ l: TranscriptLine) -> [LineFix] { (l.fixes ?? []).filter(\.applied) }
+}
+
+/// 改这句… open: the meeting, the line, and what the editor starts with.
+struct LineEdit: Identifiable, Equatable {
+ var id: String { session + "/" + line }
+ let session: String
+ let line: String
+ let start: String
+}
+
+/// A small button on a card or banner: ink for the answer that changes something, grey for the other.
+struct FixButton: View {
+ let title: LocalizedStringKey
+ var dark = false
+ let action: () -> Void
+
+ var body: some View {
+ Button(action: action) {
+ Text(title).font(.subheadline.weight(dark ? .semibold : .regular))
+ .foregroundStyle(dark ? .white : Ink.ink)
+ .padding(.horizontal, 16).frame(minHeight: 36)
+ .background(dark ? Ink.ink : Color.white, in: Capsule())
+ .overlay { if !dark { Capsule().strokeBorder(Ink.line, lineWidth: 1) } }
+ .contentShape(Capsule())
+ }
+ .buttonStyle(.plain)
+ .frame(minHeight: 44)
+ }
+}
+
+/// 这样改对吗? while listening: a name the app couldn't check by sound, asked about once. 对 fixes
+/// every line waiting on it and adds it to the word list; 稍后再看 asks again after the meeting.
+struct FixAskCard: View {
+ @EnvironmentObject var model: AppModel
+ @ObservedObject var fixes: LiveFixes
+ let session: String
+
+ var body: some View {
+ if let a = fixes.asking(in: session) {
+ let c = Correction.core(a.fix.from, a.fix.to)
+ VStack(alignment: .leading, spacing: 10) {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text("这样改对吗?").font(.subheadline.weight(.semibold)).foregroundStyle(Ink.ink)
+ Spacer(minLength: 4)
+ if a.of > 1 { Text(verbatim: "1 / \(a.of)").font(.footnote.monospacedDigit()).foregroundStyle(Ink.tertiary) }
+ }
+ VStack(alignment: .leading, spacing: 3) {
+ (Text(c.from) + Text(verbatim: " → ").foregroundStyle(Ink.tertiary) + Text(c.to).bold())
+ .font(.body).foregroundStyle(Ink.ink)
+ Text(verbatim: "\(TranscriptExport.clock(a.line.t)) · \(a.line.src)")
+ .font(.footnote).foregroundStyle(Ink.tertiary).lineLimit(1)
+ Text("确认后整场一起改,以后也这样改").font(.footnote).foregroundStyle(Ink.secondary)
+ }
+ HStack(spacing: 8) {
+ FixButton(title: "对", dark: true) { fixes.answer(a.fix, yes: true, in: session) }
+ FixButton(title: "不对") { fixes.answer(a.fix, yes: false, in: session) }
+ Spacer(minLength: 0)
+ Button { fixes.later(a.fix, in: session) } label: {
+ Text("稍后再看").font(.subheadline).foregroundStyle(Ink.secondary).frame(minHeight: 44)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ .padding(.horizontal, 16).padding(.top, 14).padding(.bottom, 6)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(Color.white, in: RoundedRectangle(cornerRadius: 20, style: .continuous))
+ .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).strokeBorder(Ink.accent.opacity(0.35), lineWidth: 1.5))
+ .shadow(color: Ink.ink.opacity(0.08), radius: 10, y: 4)
+ .transition(.opacity.combined(with: .move(edge: .top)))
+ }
+ }
+}
+
+/// Above a finished meeting's transcript: how many words were fixed, and the ones waiting for the
+/// user, one at a time (对 / 不对 / 改成…). Nothing when there was nothing to fix.
+struct FixReviewBanner: View {
+ @ObservedObject var fixes: LiveFixes
+ let session: Session
+ let onShow: (String) -> Void
+ let onEdit: (TranscriptLine, String) -> Void
+
+ var body: some View {
+ let waiting = fixes.pending(in: session.id)
+ let fixedCount = session.lines.reduce(0) { $0 + FixedText.applied($1).count }
+ if let first = waiting.first {
+ let c = Correction.core(first.fix.from, first.fix.to)
+ VStack(alignment: .leading, spacing: 8) {
+ Button { onShow(first.line.id) } label: {
+ VStack(alignment: .leading, spacing: 3) {
+ Text("改了 \(fixedCount) 处听错的词,\(waiting.count) 处等你确认")
+ .font(.subheadline.weight(.semibold)).foregroundStyle(Ink.ink)
+ (Text(verbatim: "\(c.from) → \(c.to)?") + Text(verbatim: " · \(TranscriptExport.clock(first.line.t))").foregroundStyle(Ink.tertiary))
+ .font(.footnote).foregroundStyle(Ink.secondary)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ HStack(spacing: 8) {
+ FixButton(title: "对", dark: true) { fixes.answer(first.fix, yes: true, in: session.id) }
+ FixButton(title: "不对") { fixes.answer(first.fix, yes: false, in: session.id) }
+ FixButton(title: "改成…") { onEdit(first.line, first.line.shown) }
+ }
+ }
+ .padding(.horizontal, 14).padding(.top, 12).padding(.bottom, 4)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(Ink.accent.opacity(0.05), in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ .overlay(RoundedRectangle(cornerRadius: 16, style: .continuous).strokeBorder(Ink.accentWash, lineWidth: 1))
+ // Not scrolled to on opening, as the Mac does: on a phone the banner would leave the
+ // screen with it. A tap on the question goes there.
+ } else if fixedCount > 0 {
+ Text("改了 \(fixedCount) 处听错的词").font(.footnote).foregroundStyle(Ink.tertiary)
+ }
+ }
+}
+
+/// Under a line tapped open in the record: each fixed word, what it was heard as, 改回; and 改这句….
+/// The Mac shows the same while the line is pointed at.
+struct FixedWords: View {
+ let line: TranscriptLine
+ let onRevert: (LineFix) -> Void
+ let onEdit: () -> Void
+
+ var body: some View {
+ FlowLayout(spacing: 6) {
+ ForEach(Array(FixedText.applied(line).enumerated()), id: \.offset) { _, f in
+ let c = Correction.core(f.from, f.to)
+ HStack(spacing: 6) {
+ (Text("听成").foregroundStyle(Ink.tertiary) + Text(verbatim: " \(c.from)") + Text(verbatim: " → ").foregroundStyle(Ink.tertiary) + Text(c.to))
+ .font(.footnote)
+ Button("改回") { onRevert(f) }
+ .buttonStyle(.plain).font(.footnote.weight(.semibold)).foregroundStyle(Ink.link)
+ }
+ .padding(.horizontal, 10).frame(minHeight: 34)
+ .background(Ink.ground, in: Capsule())
+ }
+ Button(action: onEdit) {
+ Text("改这句…").font(.footnote.weight(.semibold)).foregroundStyle(Ink.link)
+ .padding(.horizontal, 10).frame(minHeight: 34)
+ }
+ .buttonStyle(.plain)
+ }
+ .padding(.top, 4)
+ }
+}
+
+/// 改这句…: the line as shown, to rewrite. What changed becomes the user's own fix
+/// (`LiveFixes.edit`), on every line heard the same way or only this one.
+struct LineEditorSheet: View {
+ let edit: LineEdit
+ @ObservedObject var fixes: LiveFixes
+ @EnvironmentObject var model: AppModel
+ @Environment(\.dismiss) private var dismiss
+ @State private var text = ""
+ @State private var everywhere = true
+ @State private var keep = true
+ @FocusState private var focused: Bool
+
+ var body: some View {
+ let same = fixes.sameHeard(lineID: edit.line, in: edit.session, edited: text)
+ NavigationStack {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 0) {
+ Card(radius: 16) {
+ TextField(text: $text, axis: .vertical) { Text("改这句") }
+ .font(.body).lineSpacing(3)
+ .focused($focused)
+ .padding(14)
+ }
+ if let same {
+ (Text("听成").foregroundStyle(Ink.tertiary) + Text(verbatim: " \(same.heard)"))
+ .font(.subheadline).foregroundStyle(Ink.ink)
+ .padding(.horizontal, 16).padding(.top, 18).padding(.bottom, 8)
+ Card(radius: 16) {
+ if same.count > 1 {
+ choice(Text("整场听成 \(same.heard) 的 \(same.count) 处都改"), on: everywhere) { everywhere = true }
+ Hairline()
+ choice(Text("只改这一处"), on: !everywhere) { everywhere = false }
+ Hairline()
+ }
+ Toggle(isOn: $keep) { Text("记进词表,以后自动改").foregroundStyle(Ink.ink) }
+ .tint(Ink.ok)
+ .disabled(same.count > 1 && !everywhere)
+ .padding(.horizontal, 16).frame(minHeight: 50)
+ }
+ }
+ }
+ .padding(16)
+ }
+ .background(Ink.ground)
+ .navigationTitle(Text("改这句"))
+ .navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ ToolbarItem(placement: .cancellationAction) { Button("取消") { dismiss() } }
+ ToolbarItem(placement: .confirmationAction) {
+ Button("改成", action: apply).fontWeight(.semibold).disabled(same == nil)
+ }
+ }
+ }
+ .tint(Ink.ink)
+ .presentationDetents([.medium, .large])
+ .onAppear { text = edit.start; focused = true }
+ }
+
+ private func choice(_ title: Text, on: Bool, _ pick: @escaping () -> Void) -> some View {
+ Button(action: pick) {
+ HStack {
+ title.foregroundStyle(Ink.ink).multilineTextAlignment(.leading)
+ Spacer()
+ if on { Image(systemName: "checkmark").font(.body.weight(.semibold)).foregroundStyle(Ink.accent) }
+ }
+ .padding(.horizontal, 16).frame(minHeight: 50).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .accessibilityAddTraits(on ? .isSelected : [])
+ }
+
+ private func apply() {
+ guard let same = fixes.sameHeard(lineID: edit.line, in: edit.session, edited: text) else { dismiss(); return }
+ let all = same.count > 1 ? everywhere : true
+ fixes.edit(lineID: edit.line, in: edit.session, to: text, everywhere: all, remember: keep && all)
+ dismiss()
+ }
+}
+
+/// The last fix decision said back for a few seconds, with 撤销: the speaker toast's look.
+struct FixToast: View {
+ @ObservedObject var fixes: LiveFixes
+
+ var body: some View {
+ if let t = fixes.toast {
+ SpeakerUndoBar(text: t.text) { fixes.undo() }.id(t.id)
+ }
+ }
+}
+
+// MARK: - 设置 › 词表
+
+/// The switches for 改正听错的词 and the word list itself: each word, what it has been heard as,
+/// where it came from and how often it fixed a line. Swipe to delete (撤销 in its place for a few
+/// seconds), tap to change the spelling or the heard forms, 粘贴导入 for many at once.
+struct WordListPage: View {
+ @EnvironmentObject var model: AppModel
+ @EnvironmentObject var ling: LingClient
+ @ObservedObject var vocabulary: Vocabulary
+ @AppStorage(Pref.fixMisheard) private var fixMisheard = true
+ @AppStorage(Pref.askNames) private var askNames = true
+ @State private var query = ""
+
+ var body: some View {
+ List {
+ Section {
+ VStack(alignment: .leading, spacing: 2) {
+ HStack {
+ Text("会中改正听错的词").foregroundStyle(Ink.ink)
+ Spacer()
+ if ling.usable {
+ Toggle(isOn: $fixMisheard) { Text("会中改正听错的词") }.labelsHidden().tint(Ink.ok)
+ } else {
+ NavigationLink { KeyPage() } label: { Text("去设置").foregroundStyle(Ink.link) }.fixedSize()
+ }
+ }
+ Text(ling.usable ? L("走 \("Ling"),只发文字") : L("接上 AI 服务后才会改"))
+ .font(.footnote).foregroundStyle(Ink.secondary)
+ }
+ .padding(.vertical, 4)
+ VStack(alignment: .leading, spacing: 2) {
+ Toggle(isOn: $askNames) { Text("没见过的名字和专称先问我").foregroundStyle(Ink.ink) }
+ .tint(Ink.ok).disabled(!fixMisheard || !ling.usable)
+ Text("关掉就只改词表里的词和同音错字").font(.footnote).foregroundStyle(Ink.secondary)
+ }
+ .padding(.vertical, 4)
+ }
+
+ Section {
+ if let d = model.deletedWord {
+ HStack {
+ (Text("已删除") + Text(verbatim: " ") + Text(d.term.word).bold()).foregroundStyle(Ink.secondary)
+ Spacer()
+ Button("撤销") { vocabulary.insert(d.term, at: d.index); model.deletedWord = nil }
+ .buttonStyle(.plain).fontWeight(.semibold).foregroundStyle(Ink.link)
+ }
+ }
+ if vocabulary.terms.isEmpty && model.deletedWord == nil {
+ Text("还没有词。把常用的人名、产品名贴进来,会中就照这些写法改")
+ .font(.subheadline).foregroundStyle(Ink.secondary).padding(.vertical, 6)
+ }
+ ForEach(shown, id: \.word) { t in
+ WordRow(term: t, vocabulary: vocabulary)
+ .swipeActions(edge: .trailing, allowsFullSwipe: true) {
+ Button(role: .destructive) { model.deleteWord(t) } label: { Label("删除", systemImage: "trash") }
+ }
+ }
+ } header: {
+ HStack(spacing: 8) {
+ Text("词")
+ if !vocabulary.terms.isEmpty { Text(verbatim: "\(vocabulary.terms.count)").monospacedDigit() }
+ }
+ } footer: {
+ Text("最多 \(Vocabulary.limit) 个,满了优先用最近的。只存在这台设备上")
+ }
+ }
+ .listStyle(.insetGrouped)
+ .scrollContentBackground(.hidden)
+ .background(Ink.ground)
+ .contentMargins(.bottom, 100, for: .scrollContent)
+ .navigationTitle(Text("词表"))
+ .navigationBarTitleDisplayMode(.inline)
+ .modifier(WordSearch(on: vocabulary.terms.count > 12, query: $query))
+ .toolbar {
+ ToolbarItem(placement: .topBarTrailing) {
+ Button("粘贴导入…") { model.wordImport = UIPasteboard.general.hasStrings ? (UIPasteboard.general.string ?? "") : "" }
+ }
+ }
+ .sheet(isPresented: Binding(get: { model.wordImport != nil }, set: { if !$0 { model.wordImport = nil } })) {
+ WordImportSheet(vocabulary: vocabulary, text: model.wordImport ?? "")
+ }
+ .tint(Ink.ink)
+ .animation(.snappy(duration: 0.2), value: model.deletedWord?.term.word)
+ }
+
+ /// Most recently useful first, then the rest newest first.
+ private var shown: [Vocabulary.Term] {
+ let q = Vocabulary.key(query)
+ let all = vocabulary.terms.reversed().sorted { ($0.used ?? .distantPast) > ($1.used ?? .distantPast) }
+ guard !q.isEmpty else { return all }
+ return all.filter { Vocabulary.key($0.word).contains(q) || $0.heard.contains { Vocabulary.key($0).contains(q) } }
+ }
+}
+
+/// 搜索词表 once the list is long enough to need it, as on the Mac (more than 12).
+private struct WordSearch: ViewModifier {
+ let on: Bool
+ @Binding var query: String
+
+ func body(content: Content) -> some View {
+ if on { content.searchable(text: $query, prompt: Text("搜索词表")) } else { content }
+ }
+}
+
+/// A heard form typed for a word that another word already has: whose it should be.
+struct WordConflict: Equatable {
+ let word: String
+ let heard: String
+ let owner: String
+}
+
+/// A deleted word, shown in its place with 撤销 for a few seconds.
+struct DeletedWord: Equatable {
+ let term: Vocabulary.Term
+ let index: Int
+}
+
+/// One word: its spelling, what it was heard as, where it came from and how often it fixed a line.
+/// Tapped, it opens in place: the spelling to change, heard forms to take off or add.
+private struct WordRow: View {
+ @EnvironmentObject var model: AppModel
+ let term: Vocabulary.Term
+ @ObservedObject var vocabulary: Vocabulary
+ @State private var word = ""
+ @State private var newHeard = ""
+ @FocusState private var wordFocused: Bool
+
+ private var editing: Bool { model.editingWord == term.word }
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 8) {
+ if editing {
+ HStack {
+ TextField(text: $word) { Text(verbatim: term.word) }
+ .font(.body.weight(.semibold))
+ .focused($wordFocused)
+ .submitLabel(.done)
+ .onSubmit(commit)
+ Button("完成", action: commit).fontWeight(.semibold).buttonStyle(.plain).foregroundStyle(Ink.link)
+ }
+ } else {
+ Button { word = term.word; model.editingWord = term.word } label: {
+ HStack(alignment: .firstTextBaseline) {
+ Text(term.word).font(.body.weight(.semibold)).foregroundStyle(Ink.ink)
+ Spacer(minLength: 8)
+ Text(term.source == "live" ? L("会中确认") : L("你加的"))
+ .font(.footnote).foregroundStyle(term.source == "live" ? Ink.accentText : Ink.tertiary)
+ Text(verbatim: "·").font(.footnote).foregroundStyle(Ink.tertiary)
+ Text(term.fixes > 0 ? L("改过 \(term.fixes) 次") : L("还没用上"))
+ .font(.footnote.monospacedDigit()).foregroundStyle(Ink.tertiary)
+ }
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ }
+ if !term.heard.isEmpty || editing {
+ FlowLayout(spacing: 6) {
+ ForEach(term.heard, id: \.self) { h in
+ HStack(spacing: 4) {
+ Text(h).font(.footnote).foregroundStyle(Ink.secondary)
+ if editing {
+ Button { vocabulary.forget(heard: h, word: term.word) } label: {
+ Image(systemName: "xmark").font(.caption2.weight(.bold)).foregroundStyle(Ink.tertiary)
+ .frame(width: 24, height: 28).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain).accessibilityLabel(Text("删掉这个听错的词"))
+ }
+ }
+ .padding(.leading, 10).padding(.trailing, editing ? 2 : 10).frame(minHeight: 28)
+ .background(Ink.ground, in: Capsule())
+ }
+ if editing {
+ TextField(text: $newHeard) { Text("加一个容易听错的词") }
+ .font(.footnote).frame(width: 150)
+ .submitLabel(.done)
+ .onSubmit(addHeard)
+ .padding(.horizontal, 10).frame(minHeight: 28)
+ .overlay(Capsule().strokeBorder(style: StrokeStyle(lineWidth: 1, dash: [3, 2])).foregroundStyle(Ink.line))
+ }
+ }
+ }
+ if let c = model.wordConflict, c.word == term.word {
+ VStack(alignment: .leading, spacing: 6) {
+ Text("“\(c.heard)”已经记在 \(c.owner) 下").font(.subheadline).foregroundStyle(Ink.ink)
+ HStack(spacing: 8) {
+ FixButton(title: "改给 \(term.word)", dark: true) {
+ vocabulary.forget(heard: c.heard, word: c.owner)
+ vocabulary.confirm(heard: c.heard, word: term.word, source: term.source)
+ model.wordConflict = nil
+ }
+ FixButton(title: "两个都留") {
+ vocabulary.confirm(heard: c.heard, word: term.word, source: term.source)
+ model.wordConflict = nil
+ }
+ }
+ }
+ }
+ }
+ .padding(.vertical, 4)
+ .onChange(of: editing) { if editing { word = term.word; wordFocused = true } }
+ .onAppear { if editing { word = term.word } }
+ }
+
+ private func commit() {
+ if !newHeard.trimmingCharacters(in: .whitespaces).isEmpty { addHeard() }
+ if model.wordConflict?.word == term.word { return }
+ model.editingWord = nil
+ vocabulary.rename(term.word, to: word)
+ }
+
+ private func addHeard() {
+ model.addHeard(newHeard, to: term)
+ newHeard = ""
+ }
+}
+
+/// 粘贴导入: many words at once, each line one word, heard forms after "=". The counts follow what
+/// is pasted, and the button says how many go in.
+struct WordImportSheet: View {
+ @ObservedObject var vocabulary: Vocabulary
+ @Environment(\.dismiss) private var dismiss
+ @State var text: String
+ @State private var result: Vocabulary.ImportResult?
+
+ var body: some View {
+ let preview = vocabulary.preview(text)
+ let n = preview.added + preview.updated
+ NavigationStack {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 12) {
+ Text("一行一个。常被听错的词,写在 = 后面").font(.subheadline).foregroundStyle(Ink.secondary)
+ .padding(.horizontal, 4)
+ TextEditor(text: $text)
+ .font(.body).frame(minHeight: 200)
+ .scrollContentBackground(.hidden)
+ .overlay(alignment: .topLeading) {
+ if text.isEmpty {
+ Text(verbatim: "Uniswap V3\nMorpho = 莫拉、莫法\n巡检")
+ .font(.body).foregroundStyle(Ink.tertiary.opacity(0.7))
+ .padding(.leading, 5).padding(.top, 8).allowsHitTesting(false)
+ }
+ }
+ .padding(10)
+ .background(Color.white, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ if let r = result {
+ VStack(alignment: .leading, spacing: 4) {
+ Text("新增 \(r.added) · 补充听成 \(r.updated) · 跳过 \(r.skipped.count)")
+ .font(.subheadline.weight(.semibold)).foregroundStyle(Ink.ink)
+ if !r.skipped.isEmpty {
+ Text("第 \(r.skipped.map(String.init).joined(separator: "、")) 行没加进去:超过 40 个字")
+ .font(.footnote).foregroundStyle(Ink.accentText)
+ }
+ }
+ .padding(.horizontal, 4)
+ } else if !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
+ Text("新增 \(preview.added) · 补充听成 \(preview.updated) · 跳过 \(preview.skipped.count)")
+ .font(.subheadline).foregroundStyle(Ink.secondary).padding(.horizontal, 4)
+ }
+ }
+ .padding(16)
+ }
+ .background(Ink.ground)
+ .navigationTitle(Text("粘贴导入"))
+ .navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ ToolbarItem(placement: .cancellationAction) {
+ Button(result == nil ? "取消" : "完成") { dismiss() }
+ }
+ if result == nil {
+ ToolbarItem(placement: .confirmationAction) {
+ Button("导入 \(n) 个") { result = vocabulary.importText(text); text = "" }
+ .fontWeight(.semibold).disabled(n == 0)
+ }
+ }
+ }
+ }
+ .tint(Ink.ink)
+ .presentationDetents([.medium, .large])
+ }
}
diff --git a/ios/Sources/Cicada/LiveViews.swift b/ios/Sources/Cicada/LiveViews.swift
index 22a573e..83987f8 100644
--- a/ios/Sources/Cicada/LiveViews.swift
+++ b/ios/Sources/Cicada/LiveViews.swift
@@ -167,6 +167,7 @@ struct LivePhone: View {
HomeTitle()
ListenBar()
PillSwitch(selection: $page, options: [(.subtitles, "字幕"), (.notes, notesTitle)])
+ if let id = room.sessionID { FixAskCard(fixes: model.fixes, session: id) }
}
.padding(.horizontal, 16)
.padding(.top, 6)
@@ -177,6 +178,8 @@ struct LivePhone: View {
}
}
.background(Ink.ground)
+ .overlay(alignment: .bottom) { FixToast(fixes: model.fixes).padding(.horizontal, 16).padding(.bottom, 8) }
+ .animation(.snappy(duration: 0.2), value: model.fixes.toast)
.onChange(of: model.livePage) { page = model.livePage }
}
@@ -250,6 +253,10 @@ struct LivePad: View {
@State private var page: LivePage = .subtitles
var body: some View {
+ VStack(spacing: 0) {
+ if let id = room.sessionID {
+ FixAskCard(fixes: model.fixes, session: id).frame(maxWidth: 560).padding(.horizontal, 20).padding(.top, 18)
+ }
GeometryReader { g in
if g.size.width >= 820 {
HStack(alignment: .top, spacing: 22) {
@@ -273,7 +280,11 @@ struct LivePad: View {
.padding(.horizontal, 20).padding(.top, 18)
}
}
+ }
.background(Ink.ground)
+ .overlay(alignment: .bottom) { FixToast(fixes: model.fixes).frame(maxWidth: 560).padding(.horizontal, 20).padding(.bottom, 12) }
+ .animation(.snappy(duration: 0.2), value: model.fixes.toast)
+ .animation(.snappy(duration: 0.2), value: model.fixes.asking(in: room.sessionID ?? "")?.fix)
.onChange(of: model.livePage) { page = model.livePage }
}
diff --git a/ios/Sources/Cicada/RecordView.swift b/ios/Sources/Cicada/RecordView.swift
index f4704a9..fa21d94 100644
--- a/ios/Sources/Cicada/RecordView.swift
+++ b/ios/Sources/Cicada/RecordView.swift
@@ -20,6 +20,7 @@ struct RecordView: View {
@AppStorage(Pref.voices) private var voicesOn = true
var body: some View {
+ ScrollViewReader { proxy in
ScrollView {
VStack(alignment: .leading, spacing: 0) {
// The design's 28 pt title; the day is in the line below, so a notes title's
@@ -56,7 +57,15 @@ struct RecordView: View {
.padding(.top, 16)
switch model.recordPage {
- case .transcript: TranscriptList(session: session, playing: player.lineID(in: session), focus: picked ?? playingNumber(voicesOn ? TranscriptExport.speakerNumbers(session) : [:]), dimOthers: picked != nil) { player.seek($0) }
+ case .transcript:
+ // 改正听错的词 after the meeting: the waiting fixes, one at a time.
+ if session.id != model.store.liveID {
+ FixReviewBanner(fixes: model.fixes, session: session,
+ onShow: { id in withAnimation { proxy.scrollTo(id, anchor: .center) } },
+ onEdit: { l, start in model.editingLine = LineEdit(session: session.id, line: l.id, start: start) })
+ .padding(.top, 14)
+ }
+ TranscriptList(session: session, playing: player.lineID(in: session), focus: picked ?? playingNumber(voicesOn ? TranscriptExport.speakerNumbers(session) : [:]), dimOthers: picked != nil) { player.seek($0) }
case .notes:
if notes.generatingID == session.id {
HStack(spacing: 10) {
@@ -77,6 +86,10 @@ struct RecordView: View {
.frame(maxWidth: 720, alignment: .leading)
.frame(maxWidth: .infinity)
}
+ .onReceive(NotificationCenter.default.publisher(for: .debugScroll)) { n in
+ if let id = n.object as? String { proxy.scrollTo(id, anchor: .center) }
+ }
+ }
.background(Color.white)
.navigationBarTitleDisplayMode(.inline)
// The design's trailing glass pair: 生成纪要 and 导出, in ink like the back button.
@@ -106,11 +119,13 @@ struct RecordView: View {
if let u = model.speakerUndo, u.session == session.id, !u.text.isEmpty, !player.available {
SpeakerUndoBar(text: u.text) { model.undoSpeakerEdit() }.padding(.horizontal, 16).padding(.bottom, 8)
}
+ if !player.available { FixToast(fixes: model.fixes).padding(.horizontal, 16).padding(.bottom, 8) }
if player.available {
VStack(spacing: 8) {
if let u = model.speakerUndo, u.session == session.id, !u.text.isEmpty {
SpeakerUndoBar(text: u.text) { model.undoSpeakerEdit() }
}
+ FixToast(fixes: model.fixes)
PlayerBar(player: player)
}
.padding(.horizontal, 16)
@@ -124,8 +139,13 @@ struct RecordView: View {
}
}
.animation(.snappy(duration: 0.2), value: model.speakerUndo?.id)
+ .animation(.snappy(duration: 0.2), value: model.fixes.toast)
+ .sheet(item: Binding(get: { model.editingLine.flatMap { $0.session == session.id ? $0 : nil } },
+ set: { model.editingLine = $0 })) { e in
+ LineEditorSheet(edit: e, fixes: model.fixes)
+ }
.onAppear { player.load(store: model.store, session: session) }
- .onChange(of: session.id) { titleDraft = nil; model.focusSpeaker = nil; player.load(store: model.store, session: session) }
+ .onChange(of: session.id) { titleDraft = nil; model.focusSpeaker = nil; model.openLine = nil; player.load(store: model.store, session: session) }
.onDisappear { player.stop() }
.onReceive(NotificationCenter.default.publisher(for: .debugPlay)) { n in
if let t = n.object as? Double { player.seek(t) }
@@ -257,6 +277,7 @@ struct SpeakerUndoBar: View {
}
struct TranscriptList: View {
+ @EnvironmentObject var model: AppModel
let session: Session
/// The line the recording is at, highlighted like the design's.
let playing: String?
@@ -294,9 +315,31 @@ struct TranscriptList: View {
if let d = l.dst, d != l.src, d != l.shown {
Text(d).font(.system(size: dstSize)).foregroundStyle(Ink.ink).lineSpacing(4)
}
+ // Tapped open: what its fixed words were heard as, 改回, and 改这句….
+ if model.openLine == l.id {
+ FixedWords(line: l, onRevert: { f in model.fixes.revert(f, lineID: l.id, in: session.id) },
+ onEdit: { edit(l) })
+ }
}
}
- .textSelection(.enabled)
+ .contentShape(Rectangle())
+ .onTapGesture { withAnimation(.snappy(duration: 0.2)) { model.openLine = model.openLine == l.id ? nil : l.id } }
+ // Held: the same, and 拷贝 (a long press here can't also select text).
+ .contextMenu {
+ Button { edit(l) } label: { Label("改这句…", systemImage: "pencil") }
+ ForEach(Array(FixedText.applied(l).enumerated()), id: \.offset) { _, f in
+ let c = Correction.core(f.from, f.to)
+ Section {
+ Button { model.fixes.revert(f, lineID: l.id, in: session.id) } label: { Label("改回", systemImage: "arrow.uturn.backward") }
+ } header: {
+ Text("听成") + Text(verbatim: " \(c.from) → \(c.to)")
+ }
+ }
+ Button {
+ UIPasteboard.general.string = [l.shown, l.dst].compactMap { $0 }.joined(separator: "\n")
+ } label: { Label("拷贝", systemImage: "doc.on.doc") }
+ }
+ .id(l.id)
.opacity(dimOthers && !mine ? 0.4 : 1)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 14)
@@ -319,6 +362,10 @@ struct TranscriptList: View {
}
}
+ private func edit(_ l: TranscriptLine) {
+ model.editingLine = LineEdit(session: session.id, line: l.id, start: l.shown)
+ }
+
/// The time; with a recording it plays from that line.
private func time(_ l: TranscriptLine, _ on: Bool) -> some View {
Button { seek(l.t) } label: {
@@ -534,4 +581,6 @@ struct PlayerBar: View {
extension Notification.Name {
/// Debug `play:<seconds>`: the open record plays from there.
static let debugPlay = Notification.Name("cicada.debugPlay")
+ /// Debug `scrollTo:<line id>`: the open record scrolls there.
+ static let debugScroll = Notification.Name("cicada.debugScroll")
}
diff --git a/ios/Sources/Cicada/SettingsView.swift b/ios/Sources/Cicada/SettingsView.swift
index e3cbae7..7b1a775 100644
--- a/ios/Sources/Cicada/SettingsView.swift
+++ b/ios/Sources/Cicada/SettingsView.swift
@@ -39,6 +39,16 @@ struct SettingsView: View {
.pickerStyle(.menu)
.tint(Ink.secondary)
}
+ Hairline()
+ NavigationLink { WordListPage(vocabulary: model.vocabulary) } label: {
+ row(Text("词表")) {
+ if !model.vocabulary.terms.isEmpty {
+ Text(verbatim: "\(model.vocabulary.terms.count)").foregroundStyle(Ink.secondary).monospacedDigit()
+ }
+ Chevron()
+ }
+ }
+ .buttonStyle(RowPress())
}
SectionLabel(text: L("听对方"))
Card {
@@ -80,6 +90,7 @@ struct SettingsView: View {
.frame(maxWidth: .infinity)
}
.background(Ink.ground)
+ .navigationDestination(isPresented: $model.showWordList) { WordListPage(vocabulary: model.vocabulary) }
.toolbar(sheet ? .visible : .hidden, for: .navigationBar)
.navigationTitle(sheet ? Text("设置") : Text(""))
.navigationBarTitleDisplayMode(.inline)