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

View File

@@ -55,9 +55,9 @@ struct SmallRollUpHeaderView: View {
ZStack { ZStack {
Circle().fill(moodTint.color(forMood: model.mood)) Circle().fill(moodTint.color(forMood: model.mood))
.frame(minWidth: 5, .frame(minWidth: 5,
maxWidth: 70, maxWidth: 500,
minHeight: 5, minHeight: 5,
maxHeight: 70, maxHeight: 500,
alignment: .center) alignment: .center)
.overlay( .overlay(
textView(forModel: model) textView(forModel: model)