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:
@@ -20,6 +20,7 @@ struct MonthView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
|
||||
|
||||
@StateObject private var shareImage = ShareImageStateViewModel()
|
||||
@State private var sharePickerData: SharePickerData? = nil
|
||||
|
||||
@EnvironmentObject var iapManager: IAPManager
|
||||
@StateObject private var selectedDetail = DetailViewStateViewModel()
|
||||
@@ -192,9 +193,22 @@ struct MonthView: View {
|
||||
selectedDetail.selectedItem = detailView
|
||||
selectedDetail.showSheet = true
|
||||
},
|
||||
onShare: { image in
|
||||
shareImage.selectedShareImage = image
|
||||
shareImage.showSheet = true
|
||||
onShare: { metrics, entries, month in
|
||||
sharePickerData = SharePickerData(
|
||||
title: Random.monthName(fromMonthInt: month),
|
||||
designs: [
|
||||
SharingDesign(
|
||||
name: "Clean Calendar",
|
||||
shareView: AnyView(MonthTotalV1(moodMetrics: metrics, moodEntries: entries, month: month)),
|
||||
image: { MonthTotalV1(moodMetrics: metrics, moodEntries: entries, month: month).image }
|
||||
),
|
||||
SharingDesign(
|
||||
name: "Stacked Bars",
|
||||
shareView: AnyView(MonthTotalV5(moodMetrics: metrics, moodEntries: entries, month: month)),
|
||||
image: { MonthTotalV5(moodMetrics: metrics, moodEntries: entries, month: month).image }
|
||||
),
|
||||
]
|
||||
)
|
||||
}
|
||||
)
|
||||
.id("month-\(monthIndex)")
|
||||
@@ -337,10 +351,8 @@ struct MonthView: View {
|
||||
onDismiss: didDismiss) {
|
||||
selectedDetail.selectedItem
|
||||
}
|
||||
.sheet(isPresented: self.$shareImage.showSheet) {
|
||||
if let uiImage = self.shareImage.selectedShareImage {
|
||||
ImageOnlyShareSheet(photo: uiImage)
|
||||
}
|
||||
.sheet(item: $sharePickerData) { data in
|
||||
SharingStylePickerView(title: data.title, designs: data.designs)
|
||||
}
|
||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||
withAnimation {
|
||||
@@ -349,15 +361,7 @@ struct MonthView: View {
|
||||
}
|
||||
.onAppear {
|
||||
cachedSortedData = computeSortedYearMonthData()
|
||||
#if DEBUG
|
||||
// Auto-start or restart demo mode for video recording
|
||||
if demoManager.isDemoMode {
|
||||
// Already in demo mode (e.g., came from YearView), restart animation
|
||||
demoManager.restartAnimation()
|
||||
} else {
|
||||
demoManager.startDemoMode()
|
||||
}
|
||||
#endif
|
||||
// Demo mode is toggled manually via triple-tap
|
||||
}
|
||||
.onChange(of: viewModel.numberOfItems) { _, _ in
|
||||
// Use numberOfItems as a lightweight proxy for data changes
|
||||
@@ -398,7 +402,7 @@ struct MonthCard: View, Equatable {
|
||||
let filteredDays: [Int]
|
||||
let monthIndex: Int // Index for demo animation sequencing
|
||||
let onTap: () -> Void
|
||||
let onShare: (UIImage) -> Void
|
||||
let onShare: ([MoodMetrics], [MoodEntryModel], Int) -> Void
|
||||
|
||||
private var labelColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -587,8 +591,7 @@ struct MonthCard: View, Equatable {
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
let image = shareableView.asImage(size: CGSize(width: 400, height: 700))
|
||||
onShare(image)
|
||||
onShare(cachedMetrics, entries, month)
|
||||
}) {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
.font(.subheadline.weight(.medium))
|
||||
|
||||
Reference in New Issue
Block a user