add share to month view detail view

This commit is contained in:
Trey t
2022-03-15 14:25:10 -05:00
parent 6bb40f2b1c
commit db24115272
2 changed files with 77 additions and 22 deletions

View File

@@ -13,6 +13,8 @@ struct MonthDetailView: View {
@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
@StateObject private var shareImage = StupidAssShareObservableObject()
@State private var showingSheet = false
@State private var selectedEntry: MoodEntry?
@State private var showingUpdateEntryAlert = false
@@ -24,25 +26,41 @@ struct MonthDetailView: View {
var parentViewModel: HomeViewViewModel
let columns = [
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50)),
GridItem(.flexible(minimum: 5, maximum: 50))
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500)),
GridItem(.flexible(minimum: 5, maximum: 500))
]
var image: UIImage {
let image = shareView.asImage(size: CGSize(width: 666, height: 1190))
return image
}
var body: some View {
VStack {
Text("\(Random.monthName(fromMonthInt: monthInt)) \(String(yearInt))")
.font(.title)
.foregroundColor(textColor)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(
theme.currentTheme.secondaryBGColor
)
HStack {
Text("\(Random.monthName(fromMonthInt: monthInt)) \(String(yearInt))")
.font(.title)
.foregroundColor(textColor)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
Image(systemName: "square.and.arrow.up")
.padding(.trailing)
.onTapGesture {
let _image = self.image
self.shareImage.showFuckingSheet = true
self.shareImage.fuckingWrappedShrable = _image
}
}
.background(
theme.currentTheme.secondaryBGColor
)
createListView()
.padding([.leading, .trailing])
@@ -88,6 +106,39 @@ struct MonthDetailView: View {
.background(
theme.currentTheme.bg
)
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
if let uiImage = self.shareImage.fuckingWrappedShrable {
ShareSheet(photo: uiImage)
}
}
}
private var shareView: some View {
VStack {
HStack {
Text("\(Random.monthName(fromMonthInt: monthInt)) \(String(yearInt))")
.font(.title)
.foregroundColor(textColor)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
.background(
theme.currentTheme.secondaryBGColor
)
createListView()
.padding([.leading, .trailing])
.frame(minWidth: 0, maxWidth: .infinity)
monthDetails
.frame(maxWidth: .infinity, alignment: .leading)
.background(
theme.currentTheme.secondaryBGColor
)
}
.background(
theme.currentTheme.bg
)
}
private func createListView() -> some View {
@@ -101,6 +152,7 @@ struct MonthDetailView: View {
showUpdateEntryAlert = true
}
})
.frame(minWidth: 0, maxWidth: .infinity)
}
}
}
@@ -122,9 +174,9 @@ struct MonthDetailView: View {
if entry.mood == .placeholder {
Circle()
.frame(minWidth: 5,
maxWidth: 50,
maxWidth: 500,
minHeight: 5,
maxHeight: 50,
maxHeight: 500,
alignment: .center)
.foregroundColor(moodTint.color(forMood: entry.mood))
} else {
@@ -132,9 +184,9 @@ struct MonthDetailView: View {
.resizable()
.aspectRatio(contentMode: .fit)
.frame(minWidth: 5,
maxWidth: 50,
maxWidth: 500,
minHeight: 5,
maxHeight: 50,
maxHeight: 500,
alignment: .center)
.foregroundColor(moodTint.color(forMood: entry.mood))
}
@@ -153,11 +205,14 @@ struct MonthDetailView: View {
VStack {
SmallRollUpHeaderView(entries: entries,
viewType: .constant(.total))
.frame(minHeight: 0, maxHeight: 100)
SmallRollUpHeaderView(entries: entries,
viewType: .constant(.percentageCircle))
.padding(.top, -20)
.frame(minHeight: 0, maxHeight: 100)
.padding(.top, -20)
}
.frame(minHeight: 0, maxHeight: 200)
.padding()
}
}