add sharing to month view
This commit is contained in:
@@ -53,6 +53,9 @@ struct MonthDetailView: View {
|
|||||||
Image(systemName: "square.and.arrow.up")
|
Image(systemName: "square.and.arrow.up")
|
||||||
.padding(.trailing)
|
.padding(.trailing)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
|
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||||
|
impactMed.impactOccurred()
|
||||||
|
|
||||||
let _image = self.image
|
let _image = self.image
|
||||||
self.shareImage.showFuckingSheet = true
|
self.shareImage.showFuckingSheet = true
|
||||||
self.shareImage.fuckingWrappedShrable = _image
|
self.shareImage.fuckingWrappedShrable = _image
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ struct MonthView: View {
|
|||||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
||||||
|
|
||||||
|
@StateObject private var shareImage = StupidAssShareObservableObject()
|
||||||
|
|
||||||
// store a value that gets changed when user updates custom colors to update the view since the moodTint doesn't change
|
// store a value that gets changed when user updates custom colors to update the view since the moodTint doesn't change
|
||||||
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
|
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
|
||||||
|
|
||||||
@@ -81,9 +83,14 @@ struct MonthView: View {
|
|||||||
})
|
})
|
||||||
.padding([.top, .bottom])
|
.padding([.top, .bottom])
|
||||||
.background(
|
.background(
|
||||||
theme.currentTheme.bg
|
theme.currentTheme.bg
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
)
|
)
|
||||||
|
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
|
||||||
|
if let uiImage = self.shareImage.fuckingWrappedShrable {
|
||||||
|
ShareSheet(photo: uiImage)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -138,9 +145,53 @@ extension MonthView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func shareViewImage(month: Int, year: Int, entries: [MoodEntry]) -> some View {
|
||||||
|
ZStack {
|
||||||
|
VStack {
|
||||||
|
HStack {
|
||||||
|
homeViewTwoSectionHeaderView(month: month, year: year)
|
||||||
|
}
|
||||||
|
Divider()
|
||||||
|
LazyVGrid(columns: columns, spacing: 15) {
|
||||||
|
ForEach(entries, id: \.self) { entry in
|
||||||
|
Circle()
|
||||||
|
.foregroundColor(entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood))
|
||||||
|
.frame(minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
.background(
|
||||||
|
RoundedRectangle(cornerRadius: 10)
|
||||||
|
.foregroundColor(
|
||||||
|
theme.currentTheme.secondaryBGColor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
.background(
|
||||||
|
theme.currentTheme.bg
|
||||||
|
)
|
||||||
|
.padding(.bottom, 55)
|
||||||
|
}
|
||||||
|
|
||||||
private func homeViewTwoMonthListView(month: Int, year: Int, entries: [MoodEntry]) -> some View {
|
private func homeViewTwoMonthListView(month: Int, year: Int, entries: [MoodEntry]) -> some View {
|
||||||
VStack {
|
VStack {
|
||||||
homeViewTwoSectionHeaderView(month: month, year: year)
|
HStack {
|
||||||
|
homeViewTwoSectionHeaderView(month: month, year: year)
|
||||||
|
|
||||||
|
Image(systemName: "square.and.arrow.up")
|
||||||
|
.padding([.trailing, .bottom])
|
||||||
|
.onTapGesture {
|
||||||
|
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||||
|
impactMed.impactOccurred()
|
||||||
|
|
||||||
|
let _image = shareViewImage(month: month, year: year, entries: entries).asImage(size: CGSize(width: 400, height: 260))
|
||||||
|
self.shareImage.showFuckingSheet = true
|
||||||
|
self.shareImage.fuckingWrappedShrable = _image
|
||||||
|
}
|
||||||
|
}
|
||||||
Divider()
|
Divider()
|
||||||
LazyVGrid(columns: columns, spacing: 15) {
|
LazyVGrid(columns: columns, spacing: 15) {
|
||||||
ForEach(entries, id: \.self) { entry in
|
ForEach(entries, id: \.self) { entry in
|
||||||
|
|||||||
Reference in New Issue
Block a user