Files
Calendarr-IOS/Calendarr iOS/Views/ServerSetupView.swift
Scarriffle c0edca338e iOS: localization fixes, per-calendar reminders, widget polish
C1 — Localization: route the remaining hardcoded German strings through
L10n (LoginView, ServerSetupView, SettingsView email, EventDetailSheet) so
"System Default" + English device language shows fully English text.

C2 — Per-calendar reminders: parse the new reminders_enabled flag on every
calendar type; CalendarStore persists a reminderDisabledKeys set and passes
it to NotificationScheduler, which skips events of muted calendars (default
and per-event reminders). Filter sheet gains a per-calendar reminder toggle
(leading swipe + bell.slash indicator), reconciled from the server and
synced back via PUT.

C3 — Widgets:
- Shared WidgetTime.range helper; Today / Today & Tomorrow / Three Days /
  Up Next now show start–end instead of only the start time.
- This Week: show up to 6 events per day (was 3) to use the height.
- Two Weeks: mini event-title pills instead of bare dots.
- Two Months: weeks expand to fill the column (no more empty lower third).
- Day & Events: smaller header/strip/rows so content stops clipping.
- Next 5 days → Next 7 days (range + labels), higher row cap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 20:14:39 +02:00

96 lines
3.5 KiB
Swift

import SwiftUI
struct ServerSetupView: View {
@Environment(AppState.self) var appState
@AppStorage("appLanguage") private var appLang = "system"
@State private var urlInput = ""
@State private var error = ""
@State private var isChecking = false
var body: some View {
NavigationStack {
VStack(spacing: 0) {
Spacer()
VStack(spacing: 24) {
VStack(spacing: 8) {
Image(systemName: "calendar")
.font(.system(size: 56, weight: .light))
.foregroundStyle(Color.accentColor)
Text("Calendarr")
.font(.largeTitle.bold())
Text(L10n.t("server.connect_title", appLang))
.font(.subheadline)
.foregroundStyle(.secondary)
}
VStack(alignment: .leading, spacing: 8) {
Text(L10n.t("server.url", appLang))
.font(.footnote.weight(.medium))
.foregroundStyle(.secondary)
TextField("https://calendarr.example.com", text: $urlInput)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.keyboardType(.URL)
.padding(12)
.background(.quaternary)
.clipShape(RoundedRectangle(cornerRadius: 10))
if !error.isEmpty {
Text(error)
.font(.caption)
.foregroundStyle(.red)
}
}
Button {
Task { await connect() }
} label: {
HStack {
if isChecking {
ProgressView()
.tint(.white)
} else {
Text(L10n.t("server.connect", appLang))
.fontWeight(.semibold)
}
}
.frame(maxWidth: .infinity)
.padding(14)
.background(Color.accentColor)
.foregroundStyle(.white)
.clipShape(RoundedRectangle(cornerRadius: 12))
}
.disabled(urlInput.isEmpty || isChecking)
}
.padding(.horizontal, 32)
Spacer()
Text("© 2026 Scarriffleservices")
.font(.caption2)
.foregroundStyle(.tertiary)
.padding(.bottom, 24)
}
.navigationBarHidden(true)
}
}
private func connect() async {
isChecking = true
error = ""
defer { isChecking = false }
var url = urlInput.trimmingCharacters(in: .whitespacesAndNewlines)
if !url.hasPrefix("http") { url = "https://" + url }
if url.hasSuffix("/") { url = String(url.dropLast()) }
do {
_ = try await CalendarrAPI.checkSetupRequired(baseURL: url)
appState.saveServer(url: url)
} catch {
self.error = L10n.t("server.unreachable", appLang)
}
}
}