From db263702544a3c4da4a76949d2fc17fa19bf6d39 Mon Sep 17 00:00:00 2001 From: Liang Yesheng Date: Mon, 27 Sep 2021 18:54:15 +0800 Subject: [PATCH] Fix list row height --- Source/Hollow.xcodeproj/project.pbxproj | 16 +++---- .../View/Hierarchy/Main/SearchView.swift | 45 ++++++------------- .../ViewModel/Hollow/HollowDetailStore.swift | 9 +++- 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/Source/Hollow.xcodeproj/project.pbxproj b/Source/Hollow.xcodeproj/project.pbxproj index 54449625..a20c91e5 100644 --- a/Source/Hollow.xcodeproj/project.pbxproj +++ b/Source/Hollow.xcodeproj/project.pbxproj @@ -1433,7 +1433,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 77; + CURRENT_PROJECT_VERSION = 78; DEVELOPMENT_TEAM = C5UH93T368; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Hollow/Info.plist; @@ -1442,7 +1442,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.0.1; + MARKETING_VERSION = 4.0.2; PRODUCT_BUNDLE_IDENTIFIER = treehollow.Hollow; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1459,7 +1459,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 77; + CURRENT_PROJECT_VERSION = 78; DEVELOPMENT_TEAM = C5UH93T368; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Hollow/Info.plist; @@ -1468,7 +1468,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.0.1; + MARKETING_VERSION = 4.0.2; PRODUCT_BUNDLE_IDENTIFIER = treehollow.Hollow; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1484,7 +1484,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 77; + CURRENT_PROJECT_VERSION = 78; DEVELOPMENT_TEAM = C5UH93T368; INFOPLIST_FILE = HollowWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -1493,7 +1493,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.0.1; + MARKETING_VERSION = 4.0.2; OTHER_SWIFT_FLAGS = "-DWIDGET"; PRODUCT_BUNDLE_IDENTIFIER = treehollow.Hollow.HollowWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1511,7 +1511,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 77; + CURRENT_PROJECT_VERSION = 78; DEVELOPMENT_TEAM = C5UH93T368; INFOPLIST_FILE = HollowWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -1520,7 +1520,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.0.1; + MARKETING_VERSION = 4.0.2; OTHER_SWIFT_FLAGS = "-DWIDGET"; PRODUCT_BUNDLE_IDENTIFIER = treehollow.Hollow.HollowWidget; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Source/Hollow/View/Hierarchy/Main/SearchView.swift b/Source/Hollow/View/Hierarchy/Main/SearchView.swift index 20fa5027..1428b4f2 100644 --- a/Source/Hollow/View/Hierarchy/Main/SearchView.swift +++ b/Source/Hollow/View/Hierarchy/Main/SearchView.swift @@ -53,38 +53,21 @@ struct SearchView: View { .verticalCenter() .horizontalCenter() } else { - let listView = { - PostListView( - postDataWrappers: $store.posts, - detailStore: $detailStore, - revealFoldedTags: store.type != .searchTrending, - voteHandler: store.vote, - starHandler: store.star, - imageReloadHandler: { _ in store.fetchImages() } - ) - .defaultPadding(.horizontal) - } - Group { - if store.type == .search { - // FIXME: List - // Use ScrollView rather than List for search - // because when row height changes (by the loading - // of extra comments), List will not update the - // height correspondingly - CustomScrollView( - didScrollToBottom: store.loadMorePosts, - refresh: store.refresh) { - LazyVStack(spacing: 0) { listView() } - } - } else { - CustomList( - didScrollToBottom: store.loadMorePosts, - refresh: store.refresh, - content: listView) + CustomList( + didScrollToBottom: store.loadMorePosts, + refresh: store.refresh) { + PostListView( + postDataWrappers: $store.posts, + detailStore: $detailStore, + revealFoldedTags: store.type != .searchTrending, + voteHandler: store.vote, + starHandler: store.star, + imageReloadHandler: { _ in store.fetchImages() } + ) + .defaultPadding(.horizontal) } - } - .proposedIgnoringSafeArea(edges: .bottom) - .modifier(LoadingIndicator(isLoading: store.isLoading)) + .proposedIgnoringSafeArea(edges: .bottom) + .modifier(LoadingIndicator(isLoading: store.isLoading)) } } else { Spacer() diff --git a/Source/Hollow/ViewModel/Hollow/HollowDetailStore.swift b/Source/Hollow/ViewModel/Hollow/HollowDetailStore.swift index f8bcffa4..2dca61f9 100644 --- a/Source/Hollow/ViewModel/Hollow/HollowDetailStore.swift +++ b/Source/Hollow/ViewModel/Hollow/HollowDetailStore.swift @@ -53,7 +53,14 @@ class HollowDetailStore: ObservableObject, ImageCompressStore, HollowErrorHandle // source of truth when the detail view exists. bindingCancellable = $postDataWrapper .receive(on: DispatchQueue.main) - .assign(to: \.bindingPostWrapper.wrappedValue, on: self) + .sink { post in + var post = post + // FIXME: Updating Comments + // Use original comments, as comments change will cause + // the post card to be misplaced in List. + post.post.comments = bindingPostWrapper.post.comments.wrappedValue + bindingPostWrapper.wrappedValue = post + } } func cancelAll() {