From 7393f6fa436be8a12c8f07b5de341725a91b8169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=9F=E3=81=A4=E3=81=9D=E3=82=99=E3=81=86?= Date: Mon, 24 May 2021 00:45:39 +0800 Subject: [PATCH] fix: Unexpectedly navigate back to detail --- EhPanda/View/Content/ContentView.swift | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/EhPanda/View/Content/ContentView.swift b/EhPanda/View/Content/ContentView.swift index da7ed019..358fc706 100644 --- a/EhPanda/View/Content/ContentView.swift +++ b/EhPanda/View/Content/ContentView.swift @@ -13,11 +13,6 @@ import SDWebImageSwiftUI struct ContentView: View, StoreAccessor { @EnvironmentObject var store: Store - @State private var geoTimer = Timer.publish( - every: 0.5, on: .current, in: .common - ) - .autoconnect() - @State private var position: CGFloat = 0 @State private var aspectBox = [Int: CGFloat]() @@ -58,11 +53,10 @@ struct ContentView: View, StoreAccessor { ScrollView { GeometryReader { geoProxy in Text("I'm invisible~") - .onReceive(geoTimer) { _ in - updateGeoProxyMinY( - geoProxy.frame(in: .global).minY - ) - } + .onChange( + of: geoProxy.frame(in: .global).minY, + perform: updateGeoProxyMinY + ) } .frame(width: 0, height: 0) LazyVStack(spacing: 0) { @@ -73,10 +67,7 @@ struct ContentView: View, StoreAccessor { retryLimit: setting.contentRetryLimit, onSuccessAction: onWebImageSuccess ) - .frame( - width: screenW, - height: calImageHeight(item.tag) - ) + .frame(height: calImageHeight(item.tag)) .onAppear { onWebImageAppear(item) }