rename: Jarvis -> Jervis target, scheme, and folder throughout
The bundle-ID and display-name renames weren't enough — the actual Xcode target/product name was still "Jarvis", which drives CFBundleName, Xcode's Organizer archive list, the .xcodeproj filename, and the scheme name. Renamed all the way through: - project.yml: top-level name, target key, PRODUCT_NAME, source/info paths - Jarvis/ -> Jervis/ (source folder, git-tracked as renames, no content diffs on the moved files) - .gitignore, CI workflows, README, CONTRIBUTING: Jarvis.xcodeproj / scheme Jarvis -> Jervis.xcodeproj / scheme Jervis Verified: xcodebuild -scheme Jervis succeeds, produces Jervis.app, CFBundleName/CFBundleExecutable/CFBundleDisplayName all read "Jervis". CFBundleIdentifier intentionally stays com.kisani.jarvis (per prior decision — bundle ID isn't user-facing anywhere including Organizer). Swift type names (JarvisApp, JarvisWordmark, etc.) and the Gitea repo name/URL are unchanged — pure internal source identifiers, not user or developer-facing product identity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
220
Jervis/Views/Settings/NotificationsView.swift
Normal file
220
Jervis/Views/Settings/NotificationsView.swift
Normal file
@@ -0,0 +1,220 @@
|
||||
// NotificationsView.swift
|
||||
// Jarvis — notification preferences: breaking alerts + morning/evening briefings
|
||||
// with weather.
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct NotificationsView: View {
|
||||
@EnvironmentObject var manager: NotificationManager
|
||||
@StateObject private var settings = NotificationSettings.shared
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
private var authorized: Bool {
|
||||
manager.authStatus == .authorized || manager.authStatus == .provisional
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Palette.background.ignoresSafeArea()
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
header
|
||||
if !authorized { permissionCard }
|
||||
alertsSection
|
||||
briefingSection(title: "MORNING BRIEFING", icon: "sunrise",
|
||||
on: $settings.morningEnabled,
|
||||
hour: $settings.morningHour, minute: $settings.morningMinute)
|
||||
briefingSection(title: "EVENING BRIEFING", icon: "sunset",
|
||||
on: $settings.eveningEnabled,
|
||||
hour: $settings.eveningHour, minute: $settings.eveningMinute)
|
||||
weatherSection
|
||||
testButton
|
||||
}
|
||||
.padding(.horizontal, 20).padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
.navigationBarBackButtonHidden(false)
|
||||
.task { await manager.refreshAuthStatus() }
|
||||
.onChange(of: settings.morningEnabled) { _, _ in apply() }
|
||||
.onChange(of: settings.eveningEnabled) { _, _ in apply() }
|
||||
.onChange(of: settings.breakingEnabled) { _, _ in apply() }
|
||||
.onChange(of: settings.weatherEnabled) { _, _ in apply() }
|
||||
}
|
||||
|
||||
private func apply() { Task { await manager.applySettings() } }
|
||||
|
||||
// MARK: - Header
|
||||
|
||||
private var header: some View {
|
||||
Text("Notifications").font(.system(size: 22, weight: .heavy)).foregroundStyle(Palette.primaryText)
|
||||
.padding(.top, 4)
|
||||
}
|
||||
|
||||
private var permissionCard: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Jervis needs permission to send briefings and breaking alerts.")
|
||||
.font(.system(size: 14)).foregroundStyle(Color(hex: "BBBBBB"))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Button {
|
||||
Task { await manager.requestAuthorization() }
|
||||
} label: {
|
||||
Text("Enable notifications")
|
||||
.font(.system(size: 15, weight: .bold)).foregroundStyle(.black)
|
||||
.frame(maxWidth: .infinity).frame(height: 48)
|
||||
.background(Palette.orange).clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
}
|
||||
}
|
||||
.padding(16).background(Palette.surface).clipShape(RoundedRectangle(cornerRadius: 14))
|
||||
}
|
||||
|
||||
// MARK: - Alerts
|
||||
|
||||
private var alertsSection: some View {
|
||||
section("ALERTS") {
|
||||
toggleRow(icon: "bolt.fill", title: "Breaking & new stories",
|
||||
subtitle: "Notify when a high-signal story breaks",
|
||||
isOn: $settings.breakingEnabled)
|
||||
if settings.breakingEnabled {
|
||||
divider
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: "dial.medium").font(.system(size: 18))
|
||||
.foregroundStyle(Palette.secondaryText).frame(width: 26)
|
||||
Text("Only above signal").font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.primaryText)
|
||||
Spacer()
|
||||
Stepper(value: $settings.breakingMinSignal, in: 0...100, step: 5) {}
|
||||
.labelsHidden().fixedSize()
|
||||
Text("\(settings.breakingMinSignal)")
|
||||
.font(.system(size: 15, weight: .bold, design: .monospaced))
|
||||
.foregroundStyle(Palette.orange).frame(width: 34, alignment: .trailing)
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Briefings
|
||||
|
||||
private func briefingSection(title: String, icon: String, on: Binding<Bool>,
|
||||
hour: Binding<Int>, minute: Binding<Int>) -> some View {
|
||||
section(title) {
|
||||
toggleRow(icon: icon, title: "Daily briefing",
|
||||
subtitle: "Weather + top stories to watch", isOn: on)
|
||||
if on.wrappedValue {
|
||||
divider
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: "clock").font(.system(size: 18))
|
||||
.foregroundStyle(Palette.secondaryText).frame(width: 26)
|
||||
Text("Time").font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.primaryText)
|
||||
Spacer()
|
||||
DatePicker("", selection: timeBinding(hour: hour, minute: minute),
|
||||
displayedComponents: .hourAndMinute)
|
||||
.labelsHidden()
|
||||
.onChange(of: hour.wrappedValue) { _, _ in apply() }
|
||||
.onChange(of: minute.wrappedValue) { _, _ in apply() }
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func timeBinding(hour: Binding<Int>, minute: Binding<Int>) -> Binding<Date> {
|
||||
Binding(
|
||||
get: {
|
||||
Calendar.current.date(from: DateComponents(hour: hour.wrappedValue,
|
||||
minute: minute.wrappedValue)) ?? Date()
|
||||
},
|
||||
set: { newDate in
|
||||
let c = Calendar.current.dateComponents([.hour, .minute], from: newDate)
|
||||
hour.wrappedValue = c.hour ?? hour.wrappedValue
|
||||
minute.wrappedValue = c.minute ?? minute.wrappedValue
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Weather
|
||||
|
||||
private var weatherSection: some View {
|
||||
section("WEATHER") {
|
||||
toggleRow(icon: "cloud.sun", title: "Include weather",
|
||||
subtitle: "Today's outlook and rain in your briefing",
|
||||
isOn: $settings.weatherEnabled)
|
||||
if settings.weatherEnabled {
|
||||
divider
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: "mappin.and.ellipse").font(.system(size: 18))
|
||||
.foregroundStyle(Palette.secondaryText).frame(width: 26)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text("Location").font(.system(size: 12)).foregroundStyle(Color(hex: "888888"))
|
||||
TextField("", text: $settings.locationName,
|
||||
prompt: Text("Kampala").foregroundColor(Palette.mutedText))
|
||||
.font(.system(size: 16, weight: .regular))
|
||||
.foregroundStyle(Palette.primaryText)
|
||||
.autocorrectionDisabled()
|
||||
.onSubmit { resolveLocation() }
|
||||
if let place = settings.resolvedPlace {
|
||||
Text(place).font(.system(size: 11, design: .monospaced))
|
||||
.foregroundStyle(Color(hex: "33C25E"))
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button { resolveLocation() } label: {
|
||||
Text("Set").font(.system(size: 13, weight: .bold)).foregroundStyle(.black)
|
||||
.padding(.horizontal, 12).frame(height: 32)
|
||||
.background(Palette.orange).clipShape(Capsule())
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func resolveLocation() {
|
||||
Task {
|
||||
settings.latitude = nil; settings.longitude = nil; settings.resolvedPlace = nil
|
||||
await manager.applySettings() // triggers geocode + reschedule
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Test
|
||||
|
||||
private var testButton: some View {
|
||||
Button { Task { await manager.sendTestBriefing() } } label: {
|
||||
Text("Send a test briefing")
|
||||
.font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.primaryText)
|
||||
.frame(maxWidth: .infinity).frame(height: 50)
|
||||
.background(Palette.surface2).clipShape(RoundedRectangle(cornerRadius: 14))
|
||||
}
|
||||
.disabled(!authorized)
|
||||
.opacity(authorized ? 1 : 0.5)
|
||||
}
|
||||
|
||||
// MARK: - Building blocks
|
||||
|
||||
private func section<C: View>(_ label: String, @ViewBuilder _ content: () -> C) -> some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text(label).font(.system(size: 11, weight: .bold, design: .monospaced))
|
||||
.kerning(0.8).foregroundStyle(Palette.tertiaryText)
|
||||
VStack(spacing: 0) { content() }
|
||||
.background(Palette.surface).clipShape(RoundedRectangle(cornerRadius: 14))
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleRow(icon: String, title: String, subtitle: String, isOn: Binding<Bool>) -> some View {
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: icon).font(.system(size: 18)).foregroundStyle(Palette.secondaryText).frame(width: 26)
|
||||
Toggle(isOn: isOn) {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(title).font(.system(size: 16, weight: .heavy)).foregroundStyle(Palette.primaryText)
|
||||
Text(subtitle).font(.system(size: 12)).foregroundStyle(Color(hex: "888888"))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
.tint(Palette.orange)
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 14)
|
||||
}
|
||||
|
||||
private var divider: some View {
|
||||
Rectangle().fill(Palette.surface2).frame(height: 1).padding(.leading, 54)
|
||||
}
|
||||
}
|
||||
147
Jervis/Views/Settings/SettingsView.swift
Normal file
147
Jervis/Views/Settings/SettingsView.swift
Normal file
@@ -0,0 +1,147 @@
|
||||
// SettingsView.swift
|
||||
// Jarvis — settings hub: Notifications, Connectivity, and server info.
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct SettingsView: View {
|
||||
@EnvironmentObject var settings: ServerSettings
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@AppStorage("appearanceMode") private var appearanceMode: AppearanceMode = .dark
|
||||
@Query private var cachedStories: [CachedStory]
|
||||
@Query private var cachedArticles: [CachedArticle]
|
||||
@State private var showClearConfirm = false
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
Palette.background.ignoresSafeArea()
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 26) {
|
||||
header
|
||||
|
||||
group("APPEARANCE") {
|
||||
appearancePicker
|
||||
}
|
||||
|
||||
group("GENERAL") {
|
||||
NavigationLink { NotificationsView() } label: {
|
||||
row(icon: "bell.badge", title: "Notifications",
|
||||
subtitle: "Briefings & breaking alerts")
|
||||
}
|
||||
divider
|
||||
NavigationLink { ConnectivityView() } label: {
|
||||
row(icon: "globe", title: "Connectivity",
|
||||
subtitle: "Server address & Tailscale remote")
|
||||
}
|
||||
}
|
||||
|
||||
group("PLATFORM") {
|
||||
row(icon: "server.rack", title: settings.host ?? "Not configured",
|
||||
subtitle: "Connected server", chevron: false)
|
||||
}
|
||||
|
||||
group("STORAGE") {
|
||||
Button { showClearConfirm = true } label: {
|
||||
row(icon: "trash", title: "Clear offline cache",
|
||||
subtitle: "\(cachedStories.count) stories · \(cachedArticles.count) articles · keeps saved",
|
||||
chevron: false, tint: Color(hex: "C25555"))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
.presentationDragIndicator(.visible)
|
||||
.confirmationDialog("Clear offline cache?", isPresented: $showClearConfirm, titleVisibility: .visible) {
|
||||
Button("Clear cache", role: .destructive) { CacheMaintenance.clear(modelContext) }
|
||||
Button("Cancel", role: .cancel) {}
|
||||
} message: {
|
||||
Text("Removes cached stories, articles, and read/seen history. Your saved stories are kept.")
|
||||
}
|
||||
}
|
||||
|
||||
private var appearancePicker: some View {
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: "circle.lefthalf.filled")
|
||||
.font(.system(size: 18))
|
||||
.foregroundStyle(Palette.secondaryText)
|
||||
.frame(width: 26)
|
||||
Text("Theme")
|
||||
.font(.system(size: 16, weight: .heavy))
|
||||
.foregroundStyle(Palette.primaryText)
|
||||
Spacer()
|
||||
HStack(spacing: 0) {
|
||||
ForEach(AppearanceMode.allCases, id: \.self) { mode in
|
||||
Button {
|
||||
appearanceMode = mode
|
||||
} label: {
|
||||
Text(mode.label)
|
||||
.font(.system(size: 12, weight: .bold))
|
||||
.foregroundStyle(appearanceMode == mode ? .black : Palette.secondaryText)
|
||||
.padding(.horizontal, 12)
|
||||
.frame(height: 30)
|
||||
.background(appearanceMode == mode ? Palette.orange : Color.clear)
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.background(Palette.surface2)
|
||||
.clipShape(Capsule())
|
||||
.overlay(Capsule().stroke(Palette.surface2, lineWidth: 0.5))
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 14)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
HStack {
|
||||
Text("Settings").font(.system(size: 22, weight: .heavy)).foregroundStyle(Palette.primaryText)
|
||||
Spacer()
|
||||
Button { dismiss() } label: {
|
||||
Image(systemName: "xmark").font(.system(size: 15, weight: .bold))
|
||||
.foregroundStyle(Palette.secondaryText).frame(width: 44, height: 44)
|
||||
}
|
||||
}
|
||||
.padding(.top, 8)
|
||||
}
|
||||
|
||||
private func group<C: View>(_ label: String, @ViewBuilder _ content: () -> C) -> some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text(label).font(.system(size: 11, weight: .bold, design: .monospaced))
|
||||
.kerning(0.8).foregroundStyle(Palette.tertiaryText)
|
||||
VStack(spacing: 0) { content() }
|
||||
.background(Palette.surface)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 14))
|
||||
}
|
||||
}
|
||||
|
||||
private func row(icon: String, title: String, subtitle: String,
|
||||
chevron: Bool = true, tint: Color? = nil) -> some View {
|
||||
let resolvedTint = tint ?? Palette.primaryText
|
||||
return HStack(spacing: 14) {
|
||||
Image(systemName: icon).font(.system(size: 18))
|
||||
.foregroundStyle(tint == nil ? Palette.secondaryText : resolvedTint).frame(width: 26)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title).font(.system(size: 16, weight: .heavy)).foregroundStyle(resolvedTint).lineLimit(1)
|
||||
Text(subtitle).font(.system(size: 12)).foregroundStyle(Palette.secondaryText).lineLimit(1)
|
||||
}
|
||||
Spacer()
|
||||
if chevron {
|
||||
Image(systemName: "chevron.right").font(.system(size: 13, weight: .bold))
|
||||
.foregroundStyle(Palette.tertiaryText)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 14).frame(minHeight: 44)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
|
||||
private var divider: some View {
|
||||
Rectangle().fill(Palette.surface2).frame(height: 1).padding(.leading, 54)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user