inisights use selected theme

This commit is contained in:
Trey t
2025-12-10 09:53:51 -06:00
parent 3a35f380d7
commit 84c0e191b1
2 changed files with 735 additions and 46 deletions

View File

@@ -12,6 +12,7 @@ struct InsightsView: View {
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@AppStorage(UserDefaultsStore.Keys.moodImages.rawValue, store: GroupUserDefaults.groupDefaults) private var imagePack: MoodImages = .FontAwesome
@Environment(\.colorScheme) private var colorScheme
@StateObject private var viewModel = InsightsViewModel()
@EnvironmentObject var iapManager: IAPManager
@@ -24,7 +25,7 @@ struct InsightsView: View {
// Header
HStack {
Text("Insights")
.font(.largeTitle.bold())
.font(.system(size: 28, weight: .bold, design: .rounded))
.foregroundColor(textColor)
Spacer()
}
@@ -38,7 +39,7 @@ struct InsightsView: View {
textColor: textColor,
moodTint: moodTint,
imagePack: imagePack,
theme: theme
colorScheme: colorScheme
)
// This Year Section
@@ -49,7 +50,7 @@ struct InsightsView: View {
textColor: textColor,
moodTint: moodTint,
imagePack: imagePack,
theme: theme
colorScheme: colorScheme
)
// All Time Section
@@ -60,7 +61,7 @@ struct InsightsView: View {
textColor: textColor,
moodTint: moodTint,
imagePack: imagePack,
theme: theme
colorScheme: colorScheme
)
}
.padding(.vertical)
@@ -114,7 +115,7 @@ struct InsightsSectionView: View {
let textColor: Color
let moodTint: MoodTints
let imagePack: MoodImages
let theme: Theme
let colorScheme: ColorScheme
@State private var isExpanded = true
@@ -124,18 +125,18 @@ struct InsightsSectionView: View {
Button(action: { withAnimation(.easeInOut(duration: 0.2)) { isExpanded.toggle() } }) {
HStack {
Image(systemName: icon)
.font(.title3)
.foregroundColor(textColor.opacity(0.7))
.font(.system(size: 18, weight: .medium))
.foregroundColor(textColor.opacity(0.6))
Text(title)
.font(.title2.bold())
.font(.system(size: 20, weight: .bold))
.foregroundColor(textColor)
Spacer()
Image(systemName: isExpanded ? "chevron.up" : "chevron.down")
.font(.caption.weight(.semibold))
.foregroundColor(textColor.opacity(0.5))
.font(.system(size: 12, weight: .semibold))
.foregroundColor(textColor.opacity(0.4))
}
.padding(.horizontal, 16)
.padding(.vertical, 14)
@@ -144,13 +145,14 @@ struct InsightsSectionView: View {
// Insights List (collapsible)
if isExpanded {
VStack(spacing: 12) {
VStack(spacing: 10) {
ForEach(insights) { insight in
InsightCardView(
insight: insight,
textColor: textColor,
moodTint: moodTint,
imagePack: imagePack
imagePack: imagePack,
colorScheme: colorScheme
)
}
}
@@ -161,7 +163,7 @@ struct InsightsSectionView: View {
}
.background(
RoundedRectangle(cornerRadius: 16)
.fill(theme.currentTheme.secondaryBGColor)
.fill(colorScheme == .dark ? Color(.systemGray6) : .white)
)
.padding(.horizontal)
}
@@ -173,12 +175,13 @@ struct InsightCardView: View {
let textColor: Color
let moodTint: MoodTints
let imagePack: MoodImages
let colorScheme: ColorScheme
private var accentColor: Color {
if let mood = insight.mood {
return moodTint.color(forMood: mood)
}
return textColor.opacity(0.6)
return .accentColor
}
var body: some View {
@@ -205,11 +208,11 @@ struct InsightCardView: View {
// Text Content
VStack(alignment: .leading, spacing: 4) {
Text(insight.title)
.font(.subheadline.weight(.semibold))
.font(.system(size: 15, weight: .semibold))
.foregroundColor(textColor)
Text(insight.description)
.font(.subheadline)
.font(.system(size: 14))
.foregroundColor(textColor.opacity(0.7))
.fixedSize(horizontal: false, vertical: true)
}
@@ -219,7 +222,7 @@ struct InsightCardView: View {
.padding(14)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(accentColor.opacity(0.08))
.fill(colorScheme == .dark ? Color(.systemGray5) : Color(.systemGray6))
)
}
}