Skip to content

Commit

Permalink
fix: iPad reading width
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuz0u committed May 24, 2021
1 parent 7393f6f commit 38a7f62
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions EhPanda/View/Content/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ struct ContentView: View, StoreAccessor {
retryLimit: setting.contentRetryLimit,
onSuccessAction: onWebImageSuccess
)
.frame(height: calImageHeight(item.tag))
.frame(
width: absoluteScreenW,
height: calImageHeight(item.tag)
)
.onAppear {
onWebImageAppear(item)
}
Expand Down Expand Up @@ -121,7 +124,7 @@ struct ContentView: View, StoreAccessor {
for: Notification.Name("DetailViewOnDisappear")
)
) { _ in
onReceiveDetailViewOnDisappearNotification()
onDetailViewDisappear()
}
.onReceive(
NotificationCenter.default.publisher(
Expand All @@ -137,6 +140,13 @@ struct ContentView: View, StoreAccessor {
) { _ in
onResignActive()
}
.onReceive(
NotificationCenter.default.publisher(
for: NSNotification.Name("AppWidthDidChange")
)
) { _ in
onWidthChange()
}
.onAppear(perform: onAppear)
.onDisappear(perform: onDisappear)
.navigationBarBackButtonHidden(true)
Expand Down Expand Up @@ -175,9 +185,16 @@ private extension ContentView {
saveAspectBox()
saveReadingProgress()
}
func onReceiveDetailViewOnDisappearNotification() {
func onDetailViewDisappear() {
toggleNavBarHiddenIfNeeded()
}
func onWidthChange() {
DispatchQueue.main.async {
setOffset(.zero)
setScale(1.1)
setScale(1)
}
}
func onLazyVStackAppear(_ proxy: ScrollViewProxy) {
if let tag = mangaDetail?.readingProgress {
proxy.scrollTo(tag)
Expand Down Expand Up @@ -217,7 +234,7 @@ private extension ContentView {
// MARK: ReadingProgress
func calImageHeight(_ tag: Int) -> CGFloat {
if let aspect = aspectBox[tag] {
return screenW * aspect
return absoluteScreenW * aspect
} else {
return screenH * contentHScale
}
Expand Down Expand Up @@ -369,7 +386,7 @@ private struct ImageContainer: View {
percentage: percentage
)
.frame(
width: screenW,
width: absoluteScreenW,
height: screenH * contentHScale
)
}
Expand Down

0 comments on commit 38a7f62

Please sign in to comment.