work on share view UI a bit

This commit is contained in:
Trey t
2022-02-17 18:37:04 -06:00
parent 107086b695
commit 43bbaa4546
4 changed files with 55 additions and 31 deletions

View File

@@ -52,7 +52,7 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
} }
entries = entries.sorted(by: { entries = entries.sorted(by: {
$0.mood.rawValue > $1.mood.rawValue $0.percent > $1.percent
}) })
} else { } else {
fatalError("no data") fatalError("no data")
@@ -81,33 +81,51 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
.foregroundColor(mood.color) .foregroundColor(mood.color)
} }
} }
.frame(maxWidth: .infinity, alignment: .center)
.frame(height: 100)
HStack { VStack {
ForEach(entries, id: \.mood) { model in HStack {
ZStack { ForEach(entries.prefix(2), id: \.mood) { model in
Circle().fill(model.mood.color) ZStack {
Circle().fill(model.mood.color)
Text("\(model.percent, specifier: "%.0f")%")
.font(.title) Text("\(model.percent, specifier: "%.0f")%")
.fontWeight(.bold) .font(.title)
.scaledToFill() .fontWeight(.bold)
.minimumScaleFactor(0.5) .scaledToFill()
.lineLimit(1) .minimumScaleFactor(0.5)
.foregroundColor(Color(UIColor.white)) .lineLimit(1)
.padding(2) .foregroundColor(Color(UIColor.white))
.padding(2)
}
} }
.frame(maxWidth: .infinity, alignment: .center)
.frame(height: 100)
} }
.frame(maxWidth: .infinity, alignment: .center)
HStack {
ForEach(entries.suffix(3), id: \.mood) { model in
ZStack {
Circle().fill(model.mood.color)
Text("\(model.percent, specifier: "%.0f")%")
.font(.title)
.fontWeight(.bold)
.scaledToFill()
.minimumScaleFactor(0.5)
.lineLimit(1)
.foregroundColor(Color(UIColor.white))
.padding(2)
}
}
}
.frame(maxWidth: .infinity, alignment: .center)
} }
.padding(.top, 30)
HStack { HStack {
ForEach(entries, id: \.mood) { model in ForEach(entries, id: \.mood) { model in
ZStack { ZStack {
Circle().fill(model.mood.color) Circle().fill(model.mood.color)
Text("\(model.total)") Text("\(model.total)")
.font(.title) .font(.title)
.fontWeight(.bold) .fontWeight(.bold)
@@ -117,8 +135,6 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
.foregroundColor(Color(UIColor.white)) .foregroundColor(Color(UIColor.white))
.padding(2) .padding(2)
} }
.frame(maxWidth: .infinity, alignment: .center)
.frame(height: 100)
} }
} }
} }
@@ -130,19 +146,20 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
.font(.title) .font(.title)
.foregroundColor(Color(UIColor.label)) .foregroundColor(Color(UIColor.label))
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 1) .padding()
circularViews circularViews
.padding([.trailing, .leading, .top])
Spacer() Spacer()
} }.padding()
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
Spacer() .background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
showSharingTemplate = true showSharingTemplate = true

View File

@@ -74,7 +74,7 @@ struct CurrentStreakTemplate: View, SharingTemplate {
.font(.title) .font(.title)
.foregroundColor(Color(UIColor.label)) .foregroundColor(Color(UIColor.label))
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 1) .padding(.top)
HStack { HStack {
VStack { VStack {
@@ -95,6 +95,8 @@ struct CurrentStreakTemplate: View, SharingTemplate {
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {

View File

@@ -114,7 +114,7 @@ struct LongestStreakTemplate: View, SharingTemplate {
.font(.title) .font(.title)
.foregroundColor(Color(UIColor.label)) .foregroundColor(Color(UIColor.label))
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 1) .padding()
HStack { HStack {
Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter) Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter)
@@ -135,6 +135,8 @@ struct LongestStreakTemplate: View, SharingTemplate {
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 1) .padding(.top, 1)
} }
.padding()
HStack { HStack {
VStack { VStack {
LazyVGrid(columns: columns, spacing: 0) { LazyVGrid(columns: columns, spacing: 0) {
@@ -157,6 +159,8 @@ struct LongestStreakTemplate: View, SharingTemplate {
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
Menu(content: { Menu(content: {
ForEach(Mood.allValues) { mood in ForEach(Mood.allValues) { mood in

View File

@@ -111,10 +111,10 @@ struct MonthTotalTemplate: View, SharingTemplate {
.font(.title) .font(.title)
.foregroundColor(Color(UIColor.label)) .foregroundColor(Color(UIColor.label))
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 1) .padding()
VStack { VStack {
LazyVGrid(columns: columns, spacing: 0) { LazyVGrid(columns: columns, spacing: 10) {
ForEach(moodEntries) { entry in ForEach(moodEntries) { entry in
entry.mood.icon entry.mood.icon
.resizable() .resizable()
@@ -123,17 +123,18 @@ struct MonthTotalTemplate: View, SharingTemplate {
} }
} }
} }
.padding()
circularViews circularViews
.padding([.trailing, .leading, .top]) .padding([.trailing, .leading, .top])
Spacer()
} }
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {