Skip to content

Commit

Permalink
fix: #82 Add background color to the main view's top safe area
Browse files Browse the repository at this point in the history
- 슀크둀 μ‹œ safe area 상단뢀에 빈 화면이 ν‘œμ‹œλ˜λŠ” 문제λ₯Ό λ°©μ§€ν•˜κΈ° μœ„ν•΄ 배경색을 μˆ˜μ •/μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
  • Loading branch information
zaehorang committed Nov 21, 2024
1 parent 602b7fe commit 9e40df5
Showing 1 changed file with 72 additions and 74 deletions.
146 changes: 72 additions & 74 deletions FiveGuyes/FiveGuyes/Sources/Views/Screen/Main/MainHomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,96 +26,94 @@ struct MainHomeView: View {
let mainAlertText = "ν˜„μž¬ 읽고 μžˆλŠ” <\(title)>\(title.postPositionParticle()) μ±…μž₯μ—μ„œ μ‚­μ œν• κΉŒμš”?"

ScrollView {
ZStack(alignment: .top) {
Color.green.opacity(0.2)
.frame(height: 448)

VStack(spacing: 0) {
HStack {
Spacer()
notiButton {
navigationCoordinator.push(.empthNoti)
}
VStack(spacing: 0) {
HStack {
Spacer()
notiButton {
navigationCoordinator.push(.empthNoti)
}
.padding(.bottom, 42)
}
.padding(.bottom, 42)

HStack(alignment: .top) {
titleDescription
.padding(.bottom, 40)
Spacer()

HStack(alignment: .top) {
titleDescription
.padding(.bottom, 40)
Spacer()

if !currentlyReadingBooks.isEmpty {
Button {
showReadingBookAlert = true
} label: {
Image(systemName: "ellipsis")
.resizable()
.scaledToFit()
.frame(width: 20, height: 22)
.tint(Color(red: 0.44, green: 0.44, blue: 0.44))
}
.alert(isPresented: $showReadingBookAlert) {
Alert(
title: Text(mainAlertText),
message: Text(mainAlertMessage),
primaryButton: .cancel(Text("μ·¨μ†Œν•˜κΈ°")),
secondaryButton: .destructive(Text("μ‚­μ œ")) {
if let currentReadingBook = currentlyReadingBooks.first {
// SwiftData μ»¨ν…μŠ€νŠΈμ—μ„œ μ‚­μ œ ν•„μš”
modelContext.delete(currentReadingBook)
}
if !currentlyReadingBooks.isEmpty {
Button {
showReadingBookAlert = true
} label: {
Image(systemName: "ellipsis")
.resizable()
.scaledToFit()
.frame(width: 20, height: 22)
.tint(Color(red: 0.44, green: 0.44, blue: 0.44))
}
.alert(isPresented: $showReadingBookAlert) {
Alert(
title: Text(mainAlertText),
message: Text(mainAlertMessage),
primaryButton: .cancel(Text("μ·¨μ†Œν•˜κΈ°")),
secondaryButton: .destructive(Text("μ‚­μ œ")) {
if let currentReadingBook = currentlyReadingBooks.first {
// SwiftData μ»¨ν…μŠ€νŠΈμ—μ„œ μ‚­μ œ ν•„μš”
modelContext.delete(currentReadingBook)
}
)
}
}
)
}
}
}

ZStack(alignment: .top) {

WeeklyReadingProgressView()
.padding(.top, 153)

ZStack(alignment: .top) {

WeeklyReadingProgressView()
.padding(.top, 153)

if let currentReadingBook = currentlyReadingBooks.first,
let coverURL = currentReadingBook.book.coverURL,
let url = URL(string: coverURL) {
// TODO: μ˜†μ— μ±… 제λͺ©, μ €μž text μΆ”κ°€ν•˜κΈ°
AsyncImage(url: url) { image in
image
.resizable()
.scaledToFill()
.frame(width: 104, height: 161)
.shadow(color: Color(red: 0.84, green: 0.84, blue: 0.84).opacity(0.25), radius: 2, x: 0, y: 4)
} placeholder: {
ProgressView()
}
} else {
Rectangle()
.foregroundColor(.white)
if let currentReadingBook = currentlyReadingBooks.first,
let coverURL = currentReadingBook.book.coverURL,
let url = URL(string: coverURL) {
// TODO: μ˜†μ— μ±… 제λͺ©, μ €μž text μΆ”κ°€ν•˜κΈ°
AsyncImage(url: url) { image in
image
.resizable()
.scaledToFill()
.frame(width: 104, height: 161)
.shadow(color: Color(red: 0.84, green: 0.84, blue: 0.84).opacity(0.25), radius: 2, x: 0, y: 4)
} placeholder: {
ProgressView()
}

} else {
Rectangle()
.foregroundColor(.white)
.frame(width: 104, height: 161)
.shadow(color: Color(red: 0.84, green: 0.84, blue: 0.84).opacity(0.25), radius: 2, x: 0, y: 4)
}
.padding(.bottom, 16)

HStack(spacing: 16) {
calendarFullScreenButton
.frame(width: 107)

mainActionButton
}
.padding(.bottom, 40)

CompletionListView()
}
.padding(.bottom, 16)

HStack(spacing: 16) {
calendarFullScreenButton
.frame(width: 107)

mainActionButton
}
.padding(.horizontal, 20)
.padding(.top, topSafeAreaInset)
.padding(.bottom, 40)

CompletionListView()

}
.padding(.horizontal, 20)
.padding(.top, topSafeAreaInset)
}
.background(.white)
.ignoresSafeArea(edges: .top)
.scrollIndicators(.hidden)
.background(alignment: .top) {
LinearGradient(colors: [Color(red: 0.81, green: 1, blue: 0.77), .white], startPoint: .top, endPoint: .bottom)
.frame(height: 448)
}
.onAppear {
// 상단 μ•ˆμ „ μ˜μ—­ κ°’ 계산
if let window = UIApplication.shared.connectedScenes
Expand Down Expand Up @@ -173,7 +171,7 @@ struct MainHomeView: View {
let opacity = isReadingBookAvailable ? 1 : 0.2

return Button {
navigationCoordinator.push(.totalCalendar)
navigationCoordinator.push(.totalCalendar)
} label: {
HStack(spacing: 8) {
Image(systemName: "calendar")
Expand Down

0 comments on commit 9e40df5

Please sign in to comment.