Merge origin/main into feat-spotify

Resolve conflict in ContentView.swift by keeping both TodosView and SettingsView tabs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-10 21:05:54 +00:00
7 changed files with 472 additions and 28 deletions

View File

@@ -45,7 +45,7 @@ struct OrchestratorView: View {
Button("Recompute Now") { orchestrator.recomputeNow() }
}
Section("Feed") {
Section("Winner") {
if let feed = orchestrator.lastFeed, let winner = feed.winnerItem() {
Text(winner.title)
.font(.headline)
@@ -54,36 +54,56 @@ struct OrchestratorView: View {
.font(.subheadline)
.foregroundStyle(.secondary)
}
Text("type \(winner.type.rawValue) • prio \(String(format: "%.2f", winner.priority)) • ttl \(winner.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
if feed.feed.count > 1 {
Divider()
LabeledContent("Type") { Text(winner.type.rawValue) }
LabeledContent("Bucket") { Text(winner.bucket.rawValue) }
LabeledContent("Priority") { Text(String(format: "%.2f", winner.priority)) }
LabeledContent("TTL") { Text("\(winner.ttlSec)s") }
if let poiType = winner.poiType {
LabeledContent("POI type") { Text(poiType.rawValue) }
}
if let startsAt = winner.startsAt {
LabeledContent("Starts at") { Text("\(startsAt)") }
}
LabeledContent("ID") {
Text(winner.id)
.font(.caption)
.textSelection(.enabled)
}
} else {
Text("No winner yet")
.foregroundStyle(.secondary)
}
}
ForEach(feed.feed, id: \.id) { item in
VStack(alignment: .leading, spacing: 6) {
HStack {
Text(item.title)
.font(.headline)
.lineLimit(1)
Spacer()
Text(item.type.rawValue)
Section("Feed") {
if let feed = orchestrator.lastFeed {
if feed.feed.isEmpty {
Text("No feed items yet")
.foregroundStyle(.secondary)
} else {
ForEach(feed.feed, id: \.id) { item in
VStack(alignment: .leading, spacing: 6) {
HStack {
Text(item.title)
.font(.headline)
.lineLimit(1)
Spacer()
Text(item.type.rawValue)
.font(.caption)
.foregroundStyle(.secondary)
}
if !item.subtitle.isEmpty {
Text(item.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
}
Text("bucket \(item.bucket.rawValue) • prio \(String(format: "%.2f", item.priority)) • ttl \(item.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
}
if !item.subtitle.isEmpty {
Text(item.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
}
Text("bucket \(item.bucket.rawValue) • prio \(String(format: "%.2f", item.priority)) • ttl \(item.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
.padding(.vertical, 4)
}
.padding(.vertical, 4)
}
} else {
Text("No feed yet")

View File

@@ -0,0 +1,195 @@
//
// TodosView.swift
// iris
//
// Created by Codex.
//
import SwiftUI
struct TodosView: View {
@StateObject private var model = TodosViewModel()
@State private var isDoneExpanded = false
@State private var lastDoneCount = 0
private var openTodos: [TodoItem] {
model.todos.filter { !$0.isCompleted }
}
private var doneTodos: [TodoItem] {
model.todos.filter { $0.isCompleted }
}
var body: some View {
NavigationStack {
List {
Section("Add") {
HStack(spacing: 12) {
TextField("Add a todo", text: $model.newTitle)
.textInputAutocapitalization(.sentences)
.disableAutocorrection(false)
.submitLabel(.done)
.onSubmit { model.addTodo() }
Button {
model.addTodo()
} label: {
Image(systemName: "plus.circle.fill")
.font(.title3)
}
.buttonStyle(.plain)
.disabled(model.newTitle.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
.accessibilityLabel("Add todo")
}
}
Section("Todos") {
if openTodos.isEmpty {
Text("No open todos")
.foregroundStyle(.secondary)
} else {
ForEach(openTodos) { item in
TodoRow(
item: item,
onToggle: { model.toggleCompleted(id: item.id) },
onDelete: { model.deleteTodo(id: item.id) },
onUpdateTitle: { model.updateTitle(id: item.id, title: $0) }
)
}
}
}
Section {
if isDoneExpanded {
if doneTodos.isEmpty {
Text("No completed todos")
.foregroundStyle(.secondary)
} else {
ForEach(doneTodos) { item in
TodoRow(
item: item,
onToggle: { model.toggleCompleted(id: item.id) },
onDelete: { model.deleteTodo(id: item.id) },
onUpdateTitle: { model.updateTitle(id: item.id, title: $0) }
)
}
}
}
} header: {
Button {
withAnimation(.easeInOut(duration: 0.15)) {
isDoneExpanded.toggle()
}
} label: {
HStack(spacing: 8) {
Text("Done")
Spacer()
if doneTodos.count > 0 {
Text("\(doneTodos.count)")
.foregroundStyle(.secondary)
}
Image(systemName: isDoneExpanded ? "chevron.down" : "chevron.right")
.foregroundStyle(.secondary)
.font(.caption)
}
}
.buttonStyle(.plain)
}
}
.navigationTitle("Todos")
.onAppear {
lastDoneCount = doneTodos.count
if lastDoneCount == 0 {
isDoneExpanded = false
}
}
.onChange(of: doneTodos.count) { newCount in
if lastDoneCount == 0, newCount > 0, !isDoneExpanded {
withAnimation(.easeInOut(duration: 0.15)) {
isDoneExpanded = true
}
} else if newCount == 0, isDoneExpanded {
withAnimation(.easeInOut(duration: 0.15)) {
isDoneExpanded = false
}
}
lastDoneCount = newCount
}
}
}
}
private struct TodoRow: View {
let item: TodoItem
let onToggle: () -> Void
let onDelete: () -> Void
let onUpdateTitle: (String) -> Void
@State private var draftTitle: String
@FocusState private var isFocused: Bool
init(item: TodoItem,
onToggle: @escaping () -> Void,
onDelete: @escaping () -> Void,
onUpdateTitle: @escaping (String) -> Void) {
self.item = item
self.onToggle = onToggle
self.onDelete = onDelete
self.onUpdateTitle = onUpdateTitle
_draftTitle = State(initialValue: item.title)
}
var body: some View {
HStack(spacing: 12) {
Button(action: onToggle) {
Image(systemName: item.isCompleted ? "checkmark.circle.fill" : "circle")
.foregroundStyle(item.isCompleted ? .secondary : .primary)
}
.buttonStyle(.plain)
.accessibilityLabel(item.isCompleted ? "Mark incomplete" : "Mark complete")
TextField("Todo", text: $draftTitle)
.focused($isFocused)
.submitLabel(.done)
.onSubmit { commitTitleIfNeeded() }
.onChange(of: isFocused) { focused in
if !focused {
commitTitleIfNeeded()
}
}
.onChange(of: item.title) { newValue in
if !isFocused {
draftTitle = newValue
}
}
.foregroundStyle(item.isCompleted ? .secondary : .primary)
.opacity(item.isCompleted ? 0.7 : 1.0)
}
.onDisappear {
if isFocused {
commitTitleIfNeeded()
}
}
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive, action: onDelete) {
Label("Delete", systemImage: "trash")
}
}
}
private func commitTitleIfNeeded() {
let trimmed = draftTitle.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
draftTitle = item.title
return
}
guard trimmed != item.title else { return }
onUpdateTitle(trimmed)
}
}
struct TodosView_Previews: PreviewProvider {
static var previews: some View {
TodosView()
}
}