// HomeInput mounts one voice dock; this says, over the fan, what became of// the words the box sent: a kept thought's receipt with its Undo.importCottonKitimportCottonPaperimportSwiftUIstructFanRecord: View {let dock: DockModel/// The strip's lines.let words: VoiceWords/// The thought the last send kept, while its receipt stands.let kept: ThoughtFiled?let undone: Bool/// Takes the kept thought back; nil once it is taken back or while busy.let undo: (() -> Void)?/// The receipt's time is up.let onDismiss: () -> Voidvar body: someView {Color.clear .frame(width: 0, height: 0) .preference(key: FanToastKey.self, value: toast)// A receipt stands for a receipt's time. .task(id: kept?.id) {guard kept != nilelse { return }try? awaitTask.sleep(for: .seconds(ToastWindow.receipt))if !Task.isCancelled { onDismiss() } } }/// What the toast says: nothing while the dock listens; a kept/// thought's receipt, with its Undo, for a toast's time; else nothing.privatevar toast: FanToast? {guard !dock.isListening, kept != nilelse { returnnil }let act = undo.map { FanToast.Act(label: words.undo, run: $0) }returnFanToast(words: undone ? words.undone : words.saved, act: act) }}/// The hub closes the open tier; at the root it is the fan.enumFanButton: Equatable {case closesEdit, closesWhole, fanstaticfunc of(editing: Bool, inWhole: Bool) -> FanButton {if editing { return .closesEdit }if inWhole { return .closesWhole }return .fan }}/// A nested fan's close: the acts' on the cream paper with the ink X, a/// value row's on the red with the paper's X. The record button is it while/// a card is edited or a whole's parts are dealt (`FanButton`); a fan with no/// record button under it — a customer's (`CustomerShell`) — stands the/// edit's just above the fan (`FanHome.closesEdits`).structFanClose: View {let size: CGFloat/// The fan holds a card's acts or a whole's parts, not a value row.let acts: Boollet close: () -> Void/// The hub's own id where the X is the fan's root close (`shell.fan`),/// not a tier's.var identifier = "fan-record-close" @Environment(\.theme) privatevar themevar body: someView {Button { withAnimation(.easeOut(duration: Double(theme.scale[.fanTurnMsMin]) / 1000)) { close() } } label: { ZStack {Circle() .fill(acts ? NavChrome.circleFill : theme.colors.accent.color) .frame(width: size, height: size) .softShadow()FanCloseMark() .stroke(acts ? NavChrome.glyphInk : theme.colors.accentContrast.color, style: StrokeStyle(lineWidth: size * 0.035, lineCap: .round)) .frame(width: size * theme.scale[.fanRecordGlyph] * 0.75, height: size * theme.scale[.fanRecordGlyph] * 0.75) } .contentShape(Circle()) } .buttonStyle(MotionButtonStyle()) .accessibilityLabel(CottonStrings.close) .accessibilityIdentifier(identifier) }}privatestructFanCloseMark: Shape {func path(in rect: CGRect) -> Path {Path { path in path.move(to: CGPoint(x: rect.minX, y: rect.minY)) path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY)) path.move(to: CGPoint(x: rect.maxX, y: rect.minY)) path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY)) } }}