From 43bbaa4546dd80387cd464ef376ca5ecca1b56ba Mon Sep 17 00:00:00 2001 From: Trey t Date: Thu, 17 Feb 2022 18:37:04 -0600 Subject: [PATCH] work on share view UI a bit --- .../AllMoodsTotalTemplate.swift | 67 ++++++++++++------- .../CurrentStreakTemplate.swift | 4 +- .../LongestStreakTemplate.swift | 6 +- .../SharingTemplates/MonthTotalTemplate.swift | 9 +-- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/Shared/views/SharingTemplates/AllMoodsTotalTemplate.swift b/Shared/views/SharingTemplates/AllMoodsTotalTemplate.swift index b8763a3..9322f64 100644 --- a/Shared/views/SharingTemplates/AllMoodsTotalTemplate.swift +++ b/Shared/views/SharingTemplates/AllMoodsTotalTemplate.swift @@ -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 diff --git a/Shared/views/SharingTemplates/CurrentStreakTemplate.swift b/Shared/views/SharingTemplates/CurrentStreakTemplate.swift index 2fe3598..9f702a8 100644 --- a/Shared/views/SharingTemplates/CurrentStreakTemplate.swift +++ b/Shared/views/SharingTemplates/CurrentStreakTemplate.swift @@ -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: { diff --git a/Shared/views/SharingTemplates/LongestStreakTemplate.swift b/Shared/views/SharingTemplates/LongestStreakTemplate.swift index 3a13060..4ea8a47 100644 --- a/Shared/views/SharingTemplates/LongestStreakTemplate.swift +++ b/Shared/views/SharingTemplates/LongestStreakTemplate.swift @@ -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 diff --git a/Shared/views/SharingTemplates/MonthTotalTemplate.swift b/Shared/views/SharingTemplates/MonthTotalTemplate.swift index edc6a6a..fb08d0f 100644 --- a/Shared/views/SharingTemplates/MonthTotalTemplate.swift +++ b/Shared/views/SharingTemplates/MonthTotalTemplate.swift @@ -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: {