Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Landscape mode Improvement #25

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 50 additions & 8 deletions Dashboard/Dashboard/Presentation/Elements/PrimaryCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public struct PrimaryCardView: View {
private var resumeAction: () -> Void
private var upgradeAction: () -> Void
private var isUpgradeable: Bool
@Environment(\.isHorizontal) var isHorizontal

public init(
courseName: String,
Expand Down Expand Up @@ -76,22 +77,65 @@ public struct PrimaryCardView: View {

public var body: some View {
ZStack {
if isHorizontal {
horizontalLayout
} else {
verticalLayout
}
}
.background(Theme.Colors.courseCardBackground)
.cornerRadius(8)
.shadow(color: Theme.Colors.courseCardShadow, radius: 4, x: 0, y: 3)
.padding(20)
}

@ViewBuilder
var verticalLayout: some View {
VStack(alignment: .leading, spacing: 0) {
Group {
courseBanner
.frame(height: 140)
.clipped()
ProgressLineView(progressEarned: progressEarned, progressPossible: progressPossible)
courseTitle
}
.onTapGesture {
openCourseAction()
}
assignments
}
}

@ViewBuilder
var horizontalLayout: some View {
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
Group {
GeometryReader { proxy in
courseBanner
ProgressLineView(progressEarned: progressEarned, progressPossible: progressPossible)
.frame(width: proxy.size.width)
.clipped()
}
ProgressLineView(progressEarned: progressEarned, progressPossible: progressPossible)
}
.onTapGesture {
openCourseAction()
}
VStack(alignment: .leading, spacing: 0) {
ZStack(alignment: .leading) {
courseTitle
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.background(
Theme.Colors.background // need for tap area
)

.onTapGesture {
openCourseAction()
}
assignments
}
}
.background(Theme.Colors.courseCardBackground)
.cornerRadius(8)
.shadow(color: Theme.Colors.courseCardShadow, radius: 4, x: 0, y: 3)
.padding(20)
.frame(minHeight: 240)
}

private var assignments: some View {
Expand Down Expand Up @@ -245,8 +289,6 @@ public struct PrimaryCardView: View {
.onFailureImage(CoreAssets.noCourseImage.image)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(height: 140)
.clipped()
.accessibilityElement(children: .ignore)
.accessibilityIdentifier("course_image")
}
Expand Down
Loading