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:
@@ -22,6 +22,7 @@ struct YearView: View {
|
||||
@StateObject private var shareImage = ShareImageStateViewModel()
|
||||
@State private var trialWarningHidden = false
|
||||
@State private var showSubscriptionStore = false
|
||||
@State private var sharePickerData: SharePickerData? = nil
|
||||
|
||||
/// Cached sorted year keys to avoid re-sorting in ForEach on every render
|
||||
@State private var cachedSortedYearKeys: [Int] = []
|
||||
@@ -146,9 +147,23 @@ struct YearView: View {
|
||||
filteredDays: filteredDays.currentFilters,
|
||||
yearIndex: yearIndex,
|
||||
demoManager: demoManager,
|
||||
onShare: { image in
|
||||
shareImage.selectedShareImage = image
|
||||
shareImage.showSheet = true
|
||||
onShare: { metrics, entries, year in
|
||||
let totalCount = entries.filter { ![.missing, .placeholder].contains($0.mood) }.count
|
||||
sharePickerData = SharePickerData(
|
||||
title: String(year),
|
||||
designs: [
|
||||
SharingDesign(
|
||||
name: "Gradient",
|
||||
shareView: AnyView(AllMoodsV2(metrics: metrics, totalCount: totalCount)),
|
||||
image: { AllMoodsV2(metrics: metrics, totalCount: totalCount).image }
|
||||
),
|
||||
SharingDesign(
|
||||
name: "Color Block",
|
||||
shareView: AnyView(AllMoodsV5(metrics: metrics, totalCount: totalCount)),
|
||||
image: { AllMoodsV5(metrics: metrics, totalCount: totalCount).image }
|
||||
),
|
||||
]
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -260,23 +275,13 @@ struct YearView: View {
|
||||
.sheet(isPresented: $showSubscriptionStore) {
|
||||
FeelsSubscriptionStoreView()
|
||||
}
|
||||
.sheet(isPresented: $shareImage.showSheet) {
|
||||
if let uiImage = shareImage.selectedShareImage {
|
||||
ImageOnlyShareSheet(photo: uiImage)
|
||||
}
|
||||
.sheet(item: $sharePickerData) { data in
|
||||
SharingStylePickerView(title: data.title, designs: data.designs)
|
||||
}
|
||||
.onAppear(perform: {
|
||||
self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date())
|
||||
cachedSortedYearKeys = Array(viewModel.data.keys.sorted(by: >))
|
||||
#if DEBUG
|
||||
// Auto-start or restart demo mode for video recording
|
||||
if demoManager.isDemoMode {
|
||||
// Already in demo mode (e.g., came from MonthView), restart animation
|
||||
demoManager.restartAnimation()
|
||||
} else {
|
||||
demoManager.startDemoMode()
|
||||
}
|
||||
#endif
|
||||
// Demo mode is toggled manually via triple-tap
|
||||
})
|
||||
.onChange(of: viewModel.data.keys.count) { _, _ in
|
||||
cachedSortedYearKeys = Array(viewModel.data.keys.sorted(by: >))
|
||||
@@ -321,7 +326,7 @@ struct YearCard: View, Equatable {
|
||||
let filteredDays: [Int]
|
||||
let yearIndex: Int // Which year this is (0 = most recent)
|
||||
@ObservedObject var demoManager: DemoAnimationManager
|
||||
let onShare: (UIImage) -> Void
|
||||
let onShare: ([MoodMetrics], [MoodEntryModel], Int) -> Void
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -519,8 +524,7 @@ struct YearCard: View, Equatable {
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
let image = shareableView.asImage(size: CGSize(width: 400, height: 750))
|
||||
onShare(image)
|
||||
onShare(cachedMetrics, yearEntries, year)
|
||||
}) {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
.font(.subheadline.weight(.medium))
|
||||
|
||||
Reference in New Issue
Block a user