Add sharing style picker for design variation selection

Users can now swipe between design variations (e.g. Gradient vs Color Block)
when sharing from month/year views and the sharing templates list. Removes
#if DEBUG wrappers from variation files and disables auto-start demo animation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-10 09:26:21 -06:00
parent 15bc1c94c1
commit bfef0a4472
8 changed files with 1286 additions and 82 deletions

View File

@@ -37,54 +37,102 @@ struct SharingListView: View {
@MainActor
init() {
let earliestDate = DataController.shared.earliestEntry?.forDate ?? Date()
let now = Date()
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: now)!
let monthStart = now.startOfMonth
let monthEnd = now.endOfMonth
// All Moods
let allMoodsEntries = DataController.shared.getData(startDate: earliestDate, endDate: now, includedDays: [1,2,3,4,5,6,7])
let allMoodsMetrics = Random.createTotalPerc(fromEntries: allMoodsEntries)
let allMoodsCount = allMoodsEntries.count
// Current Streak (Last 10 Days)
let streakEntries = DataController.shared.getData(startDate: tenDaysAgo, endDate: now, includedDays: [1,2,3,4,5,6,7])
// Month Total
let monthEntries = DataController.shared.getData(startDate: monthStart, endDate: monthEnd, includedDays: [1,2,3,4,5,6,7])
let monthMetrics = Random.createTotalPerc(fromEntries: monthEntries)
let month = Calendar.current.component(.month, from: now)
self.sharebleItems = [
WrappedSharable(preview: AnyView(
AllMoodsTotalTemplate(isPreview: true,
startDate: DataController.shared.earliestEntry?.forDate ?? Date(),
endDate: Date(),
fakeData: false)
),destination: AnyView(
AllMoodsTotalTemplate(isPreview: false,
startDate: DataController.shared.earliestEntry?.forDate ?? Date(),
endDate: Date(),
fakeData: false)
),description: AllMoodsTotalTemplate.description),
// All Time Moods style picker with 2 variations
WrappedSharable(
preview: AnyView(
AllMoodsTotalTemplate(isPreview: true, startDate: earliestDate, endDate: now, fakeData: false)
),
destination: AnyView(
SharingStylePickerView(title: "All Time Moods", designs: [
SharingDesign(
name: "Gradient",
shareView: AnyView(AllMoodsV2(metrics: allMoodsMetrics, totalCount: allMoodsCount)),
image: { AllMoodsV2(metrics: allMoodsMetrics, totalCount: allMoodsCount).image }
),
SharingDesign(
name: "Color Block",
shareView: AnyView(AllMoodsV5(metrics: allMoodsMetrics, totalCount: allMoodsCount)),
image: { AllMoodsV5(metrics: allMoodsMetrics, totalCount: allMoodsCount).image }
),
])
),
description: AllMoodsTotalTemplate.description
),
//////////////////////////////////////////////////////////
WrappedSharable(preview: AnyView(
CurrentStreakTemplate(isPreview: true,
startDate: Calendar.current.date(byAdding: .day, value: -10, to: Date())!,
endDate: Date(),
fakeData: false)
), destination: AnyView(
CurrentStreakTemplate(isPreview: false,
startDate: Calendar.current.date(byAdding: .day, value: -10, to: Date())!,
endDate: Date(),
fakeData: false)
), description: CurrentStreakTemplate.description),
// Last 10 Days style picker with 2 variations
WrappedSharable(
preview: AnyView(
CurrentStreakTemplate(isPreview: true, startDate: tenDaysAgo, endDate: now, fakeData: false)
),
destination: AnyView(
SharingStylePickerView(title: "Last 10 Days", designs: [
SharingDesign(
name: "Gradient Cards",
shareView: AnyView(CurrentStreakV2(moodEntries: streakEntries)),
image: { CurrentStreakV2(moodEntries: streakEntries).image }
),
SharingDesign(
name: "Color Strips",
shareView: AnyView(CurrentStreakV5(moodEntries: streakEntries)),
image: { CurrentStreakV5(moodEntries: streakEntries).image }
),
])
),
description: CurrentStreakTemplate.description
),
//////////////////////////////////////////////////////////
WrappedSharable(preview: AnyView(
LongestStreakTemplate(isPreview: true,
startDate: DataController.shared.earliestEntry?.forDate ?? Date(),
endDate: Date(),
fakeData: false)
), destination: AnyView(
LongestStreakTemplate(isPreview: false,
startDate: DataController.shared.earliestEntry?.forDate ?? Date(),
endDate: Date(),
fakeData: false)
), description: LongestStreakTemplate.description),
// Longest Streak custom picker with mood selection
WrappedSharable(
preview: AnyView(
LongestStreakTemplate(isPreview: true, startDate: earliestDate, endDate: now, fakeData: false)
),
destination: AnyView(
LongestStreakPickerView(startDate: earliestDate, endDate: now)
),
description: LongestStreakTemplate.description
),
//////////////////////////////////////////////////////////
WrappedSharable(preview: AnyView(
MonthTotalTemplate(isPreview: true,
startDate: Date().startOfMonth,
endDate: Date().endOfMonth,
fakeData: false)
), destination: AnyView(
MonthTotalTemplate(isPreview: false,
startDate: Date().startOfMonth,
endDate: Date().endOfMonth,
fakeData: false)
), description: MonthTotalTemplate.description)
// This Month style picker with 2 variations
WrappedSharable(
preview: AnyView(
MonthTotalTemplate(isPreview: true, startDate: monthStart, endDate: monthEnd, fakeData: false)
),
destination: AnyView(
SharingStylePickerView(title: "This Month", designs: [
SharingDesign(
name: "Clean Calendar",
shareView: AnyView(MonthTotalV1(moodMetrics: monthMetrics, moodEntries: monthEntries, month: month)),
image: { MonthTotalV1(moodMetrics: monthMetrics, moodEntries: monthEntries, month: month).image }
),
SharingDesign(
name: "Stacked Bars",
shareView: AnyView(MonthTotalV5(moodMetrics: monthMetrics, moodEntries: monthEntries, month: month)),
image: { MonthTotalV5(moodMetrics: monthMetrics, moodEntries: monthEntries, month: month).image }
),
])
),
description: MonthTotalTemplate.description
),
//////////////////////////////////////////////////////////
]
}