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

View File

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

View File

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

View File

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