Skip to content

Commit f378616

Browse files
[Horizon] Fix dashboard & course details ui issues (#3403)
1 parent da0de9b commit f378616

File tree

9 files changed

+39
-16
lines changed

9 files changed

+39
-16
lines changed

Core/CoreTests/Common/CommonUI/NavigationBar/UIKit/UINavigationBarExtensionsTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class UINavigationBarExtensionsTests: XCTestCase {
5454
navIconFillActive: .textLightest.variantForLightMode,
5555
navTextColor: .textLightest.variantForLightMode,
5656
navTextColorActive: .textLightest.variantForLightMode,
57-
primary: .textLightest.variantForLightMode
57+
primary: .textLightest.variantForLightMode,
58+
institutionLogo: URL(string: "https://canvas.com/logo.png")
5859
)
5960
bar.useGlobalNavStyle(brand: shiny)
6061
XCTAssertEqual(bar.barStyle, .default)

Core/CoreTests/Features/Dashboard/K5/Model/Schedule/K5ScheduleItemInfoTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class K5ScheduleItemInfoTests: CoreTestCase {
6262
navIconFillActive: nil,
6363
navTextColor: nil,
6464
navTextColorActive: nil,
65-
primary: .red)
65+
primary: .red,
66+
institutionLogo: nil)
6667
XCTAssertEqual(APIPlannable.make(course_id: ID("testID")).k5ScheduleSubject(courseInfoByCourseIDs: ["testID": (color: .green,
6768
image: nil,
6869
isHomeroom: false,

Core/CoreTests/TestHelpers/CoreTestCase.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class CoreTestCase: XCTestCase {
157157
navIconFillActive: nil,
158158
navTextColor: nil,
159159
navTextColorActive: nil,
160-
primary: nil
160+
primary: nil,
161+
institutionLogo: nil
161162
)
162163
}
163164
}

Horizon/Horizon/Sources/Common/View/ModuleItemListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct ModuleItemListView: View {
5656
Text(item.title)
5757
.huiTypography(.labelMediumBold)
5858
.foregroundStyle(Color.huiColors.text.body)
59-
.padding(.top, .huiSpaces.space12)
59+
.padding(.top, items.first?.id == item.id ? .zero : .huiSpaces.space32)
6060
}
6161

6262
private func moduleItemButton(item: HModuleItem, type: ModuleItemType) -> some View {

Horizon/Horizon/Sources/Features/Dashboard/View/DashboardView.swift

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import SwiftUI
2323
struct DashboardView: View {
2424
@Bindable private var viewModel: DashboardViewModel
2525
@Environment(\.viewController) private var viewController
26+
@State private var isShowHeader: Bool = true
2627

2728
init(viewModel: DashboardViewModel) {
2829
self.viewModel = viewModel
@@ -41,7 +42,7 @@ struct DashboardView: View {
4142
),
4243
refreshAction: viewModel.reload
4344
) { _ in
44-
LazyVStack(spacing: .zero) {
45+
VStack(spacing: .zero) {
4546
if viewModel.courses.isEmpty, viewModel.state == .data {
4647
Text("You aren’t currently enrolled in a course.", bundle: .horizon)
4748
.padding(.huiSpaces.space24)
@@ -50,22 +51,42 @@ struct DashboardView: View {
5051
.huiTypography(.h3)
5152

5253
} else {
54+
topView
5355
contentView(courses: viewModel.courses)
5456
.padding(.bottom, .huiSpaces.space16)
5557
}
5658
}
5759
}
5860
}
59-
.toolbar(.hidden)
60-
.safeAreaInset(edge: .top, spacing: .zero) { navigationBar }
61+
.safeAreaInset(edge: .top, spacing: .zero) {
62+
if isShowHeader {
63+
navigationBar
64+
.toolbar(.hidden)
65+
.transition(.move(edge: .top).combined(with: .opacity))
66+
} else {
67+
Rectangle()
68+
.fill(Color.huiColors.surface.pagePrimary)
69+
.frame(height: 55)
70+
.ignoresSafeArea()
71+
}
72+
}
6173
.scrollIndicators(.hidden, axes: .vertical)
6274
.background(Color.huiColors.surface.pagePrimary)
6375
.animation(.smooth, value: viewModel.invitedCourses)
76+
.animation(.linear, value: isShowHeader)
6477
.alert(isPresented: $viewModel.isAlertPresented) {
6578
Alert(title: Text("Something went wrong", bundle: .horizon), message: Text(viewModel.errorMessage))
6679
}
6780
}
6881

82+
private var topView: some View {
83+
Color.clear
84+
.frame(height: 0)
85+
.readingFrame { frame in
86+
isShowHeader = frame.minY > -100
87+
}
88+
}
89+
6990
private func contentView(courses: [HCourse]) -> some View {
7091
ForEach(courses) { course in
7192
VStack(alignment: .leading, spacing: .zero) {
@@ -81,6 +102,7 @@ struct DashboardView: View {
81102

82103
if let learningObjectCardModel = course.learningObjectCardModel {
83104
learningObjectCard(model: learningObjectCardModel, progress: course.progress)
105+
.padding(.bottom, .huiSpaces.space16)
84106
} else {
85107
Text("Congrats! You've completed your course.", bundle: .horizon)
86108
.huiTypography(.h3)
@@ -101,7 +123,7 @@ struct DashboardView: View {
101123
Text(course.name)
102124
.huiTypography(.h1)
103125
.foregroundStyle(Color.huiColors.text.title)
104-
.padding(.top, .huiSpaces.space48)
126+
.padding(.top, .huiSpaces.space16)
105127
.padding(.bottom, .huiSpaces.space16)
106128

107129
HorizonUI.ProgressBar(

Horizon/Horizon/Sources/Features/Learn/Scores/View/ScoresAssignmentGroupsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct ScoresAssignmentGroupsView: View {
107107

108108
@ViewBuilder
109109
private func assignmentGroupListRow(group: ScoresAssignmentGroup) -> some View {
110-
VStack(alignment: .leading, spacing: .huiSpaces.space8) {
110+
VStack(alignment: .leading, spacing: .huiSpaces.space12) {
111111
Text(group.name)
112112
.huiTypography(.p1)
113113
.foregroundStyle(Color.huiColors.text.body)

Horizon/Horizon/Sources/Features/Learn/Scores/View/ScoresAssignmentsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct ScoresAssignmentsView: View {
3737
.padding(.top, .huiSpaces.space24)
3838
VStack(spacing: .zero) {
3939
ForEach(Array(details.assignments.enumerated()), id: \.offset) { index, assignment in
40-
VStack(alignment: .leading, spacing: .huiSpaces.space8) {
40+
VStack(alignment: .leading, spacing: .huiSpaces.space12) {
4141
Text("Name: \(assignment.name)", bundle: .horizon)
4242
if let dueAtString = assignment.dueAtString {
4343
Text("Due Date: \(dueAtString)", bundle: .horizon)

packages/HorizonUI/Sources/HorizonUI/Sources/Components/Cards/LearningObjectItem/HorizonUI.LearningObjectItem.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,26 @@ public extension HorizonUI {
120120
Text(duration)
121121
.foregroundStyle(Color.huiColors.text.timestamp)
122122
.huiTypography(.labelSmall)
123-
.padding(.leading, .huiSpaces.space16)
124123
}
125124
}
126-
.padding(.top, .huiSpaces.space12)
125+
.padding(.top, .huiSpaces.space4)
127126

128127
HStack(spacing: .zero) {
129128
if let dueDate {
130129
dueDateView(dueDate)
131-
.padding(.top, .huiSpaces.space24)
130+
.padding(.top, .huiSpaces.space4)
132131
.padding(.trailing, .huiSpaces.space16)
133132
}
134133

135134
if let points {
136135
Text("\(points) pts")
137136
.foregroundStyle(Color.huiColors.text.timestamp)
138-
.padding(.top, .huiSpaces.space24)
137+
.padding(.top, .huiSpaces.space4)
139138
}
140139
if let minScore {
141140
Text(" | \(minScore)")
142141
.foregroundStyle(Color.huiColors.text.timestamp)
143-
.padding(.top, .huiSpaces.space24)
142+
.padding(.top, .huiSpaces.space4)
144143
}
145144
}
146145
.huiTypography(.labelSmall)

packages/HorizonUI/Sources/HorizonUI/Sources/Components/ProgressBar/HorizonUI.ProgressBar.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ extension HorizonUI.ProgressBar {
107107
Group {
108108
Text(percentageRound, format: .number) + Text("%")
109109
}
110-
.padding(.horizontal, .huiSpaces.space8)
111110
.huiTypography(.buttonTextMedium)
112111
}
113112
}

0 commit comments

Comments
 (0)