Files
Reflect/FeelsWidget2/FeelsIconWidget.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.8 KiB
Swift

//
// FeelsIconWidget.swift
// FeelsWidget
//
// Custom icon widget (small only)
//
import WidgetKit
import SwiftUI
import Intents
// MARK: - Widget Configuration
struct FeelsIconWidget: Widget {
let kind: String = "FeelsIconWidget"
var body: some WidgetConfiguration {
IntentConfiguration(kind: kind,
intent: ConfigurationIntent.self,
provider: Provider()) { entry in
FeelsIconWidgetEntryView(entry: entry)
}
.configurationDisplayName("Feels Icon")
.description("")
.supportedFamilies([.systemSmall])
.contentMarginsDisabled()
}
}
// MARK: - Entry View
struct FeelsIconWidgetEntryView: View {
@Environment(\.sizeCategory) var sizeCategory
@Environment(\.widgetFamily) var family
var entry: Provider.Entry
@ViewBuilder
var body: some View {
SmallIconView(entry: entry)
}
}
// MARK: - Small Icon View
struct SmallIconView: View {
var entry: Provider.Entry
private var customWidget: CustomWidgetModel {
UserDefaultsStore.getCustomWidgets().first(where: { $0.inUse == true })
?? CustomWidgetModel.randomWidget
}
var body: some View {
CustomWidgetView(customWidgetModel: customWidget)
.ignoresSafeArea()
.containerBackground(for: .widget) {
customWidget.bgColor
}
}
}
// MARK: - Preview
#Preview("Custom Icon", as: .systemSmall) {
FeelsIconWidget()
} timeline: {
SimpleEntry(
date: Date(),
configuration: ConfigurationIntent(),
timeLineViews: nil,
hasSubscription: true,
hasVotedToday: true,
promptText: ""
)
}