Skip to content

Commit

Permalink
Merge pull request #509 from pennlabs/anli/02-25-tweak-home
Browse files Browse the repository at this point in the history
Tweak home page styling
  • Loading branch information
anli5005 authored Feb 25, 2024
2 parents 59eafaf + 70c66bf commit c6297f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
37 changes: 16 additions & 21 deletions PennMobile/Home/HomeCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct GenericPostCardView: View {
if let description {
Text(description)
.font(.caption)
.lineLimit(3)
}
}
.padding()
Expand All @@ -71,30 +70,24 @@ struct GenericPostCardView: View {
var body: some View {
HomeCardView {
if let imageURL {
ZStack(alignment: .bottom) {
Rectangle().fill(Material.ultraThin)
.background(
KFImage(imageURL)
.resizable()
.scaledToFill()
)
VStack(spacing: 0) {
KFImage(imageURL)
.resizable()
.scaledToFill()

Rectangle().fill(.clear)
.overlay(
KFImage(imageURL)
.resizable()
.scaledToFill()
)
.mask(alignment: .top) {
VStack(spacing: 0) {
Rectangle().fill(.white).frame(height: 93)
LinearGradient(colors: [.white, .clear], startPoint: .top, endPoint: .bottom).frame(height: 64)
content
.background(alignment: .top) {
ZStack {
KFImage(imageURL)
.resizable()
.scaledToFill()
.scaleEffect(x: 1, y: -1)
Rectangle().fill(.regularMaterial)
}
.drawingGroup()
}

content.padding(.top, 150)
.clipped()
}
.environment(\.colorScheme, .dark)
} else {
content
}
Expand Down Expand Up @@ -181,5 +174,7 @@ struct NewsDetailView: UIViewControllerRepresentable {
PostCardView(post: Post(id: 1, title: "Congratulations!", subtitle: "You are our lucky winner", postUrl: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", imageUrl: "https://www.cnet.com/a/img/resize/2bec42558a71a3922e6e590476b919288a015288/hub/2017/06/01/a176bcb9-1442-4d6d-a7d9-f01efdbcc4bc/broken-screen-ipad-6200-002.jpg?auto=webp&fit=crop&height=675&width=1200", createdDate: Date(), startDate: Date.midnightYesterday, expireDate: Date.midnightToday, source: "Totally Legit Source"))
}
.frame(width: 400)
.fixedSize(horizontal: false, vertical: true)
.padding(.vertical)
.frame(maxHeight: .infinity)
}
12 changes: 2 additions & 10 deletions PennMobile/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ struct HomeView<Model: HomeViewModel>: View {
.day()
}

var backgroundGradient: some View {
LinearGradient(colors: [colorScheme == .dark ? Color("baseDarkBlue") : Color("baseLabsBlue").opacity(0.5), .clear], startPoint: .topLeading, endPoint: .center)
}

var body: some View {
Group {
switch viewModel.data {
case .none:
ProgressView()
.controlSize(.large)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(backgroundGradient)
.ignoresSafeArea()
case .some(.success(let data)):
NavigationStack {
Expand All @@ -47,16 +42,16 @@ struct HomeView<Model: HomeViewModel>: View {
.background(GeometryReader { geometry in
let minY = geometry.frame(in: .global).minY
Color.clear.onChange(of: minY) { minY in
showTitle = minY <= 32
showTitle = minY <= 16
}
})

if let splashText {
HStack(alignment: .top) {
Text(splashText)
.fontWeight(.medium)
.opacity(0.7)
}
.foregroundStyle(.secondary)
}
}
.offset(y: -16)
Expand Down Expand Up @@ -93,7 +88,6 @@ struct HomeView<Model: HomeViewModel>: View {
.refreshable {
try? await viewModel.fetchData(force: true)
}
.background(backgroundGradient.ignoresSafeArea(edges: .all))
}
case .some(.failure(let error)):
VStack(spacing: 16) {
Expand Down Expand Up @@ -122,8 +116,6 @@ struct HomeView<Model: HomeViewModel>: View {
.multilineTextAlignment(.center)
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(LinearGradient(colors: [.red, .clear], startPoint: .topLeading, endPoint: .center))
.ignoresSafeArea()
}
}.onAppear {
Task {
Expand Down

0 comments on commit c6297f5

Please sign in to comment.