Files
Reflect/FeelsWidget2/WidgetModels.swift
Trey t e9adc14851 Refactor widgets into separate focused files
Split the two large widget files (~2000 lines combined) into 10 focused files:
- WidgetBundle.swift: Main @main bundle registration
- WidgetModels.swift: Shared data models (WatchTimelineView, SimpleEntry, etc.)
- WidgetProviders.swift: Timeline providers and TimeLineCreator
- WidgetSharedViews.swift: Shared voting views
- FeelsTimelineWidget.swift: Timeline widget (small/medium/large)
- FeelsVoteWidget.swift: Vote widget with stats views
- FeelsIconWidget.swift: Custom icon widget
- FeelsGraphicWidget.swift: Graphic mood widget
- FeelsMoodControlWidget.swift: Control Center widget
- FeelsLiveActivity.swift: Live Activity with proper previews

Preserves real-time update architecture (VoteMoodIntent, WidgetCenter,
WidgetDataProvider patterns). Adds proper Live Activity preview support
with sample content states.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 10:18:40 -06:00

77 lines
1.9 KiB
Swift

//
// WidgetModels.swift
// FeelsWidget
//
// Data models for widget timeline entries
//
import WidgetKit
import SwiftUI
import Intents
// MARK: - Timeline View Model
class WatchTimelineView: Identifiable {
let id = UUID()
let image: Image
let graphic: Image
let date: Date
let color: Color
let secondaryColor: Color
let mood: Mood
init(image: Image, graphic: Image, date: Date, color: Color, secondaryColor: Color, mood: Mood) {
self.image = image
self.date = date
self.color = color
self.graphic = graphic
self.secondaryColor = secondaryColor
self.mood = mood
}
}
// MARK: - Timeline Widget Entry
struct SimpleEntry: TimelineEntry {
let date: Date
let configuration: ConfigurationIntent
let timeLineViews: [WatchTimelineView]?
let showStats: Bool
let hasSubscription: Bool
let hasVotedToday: Bool
let promptText: String
init(date: Date, configuration: ConfigurationIntent, timeLineViews: [WatchTimelineView]?, showStats: Bool = false, hasSubscription: Bool = false, hasVotedToday: Bool = true, promptText: String = "") {
self.date = date
self.configuration = configuration
self.timeLineViews = timeLineViews
self.showStats = showStats
self.hasSubscription = hasSubscription
self.hasVotedToday = hasVotedToday
self.promptText = promptText
}
}
// MARK: - Vote Widget Entry
struct VoteWidgetEntry: TimelineEntry {
let date: Date
let hasSubscription: Bool
let hasVotedToday: Bool
let todaysMood: Mood?
let stats: MoodStats?
let promptText: String
}
// MARK: - Mood Stats
struct MoodStats {
let totalEntries: Int
let moodCounts: [Mood: Int]
func percentage(for mood: Mood) -> Double {
guard totalEntries > 0 else { return 0 }
return Double(moodCounts[mood, default: 0]) / Double(totalEntries) * 100
}
}