Skip to content

Commit

Permalink
Use List to resolve scrolling issue
Browse files Browse the repository at this point in the history
List to the rescue!
  • Loading branch information
liang2kl committed May 27, 2021
1 parent 62908df commit e6de27e
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 207 deletions.
25 changes: 21 additions & 4 deletions Source/Hollow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
0EDA263125D2465100B67292 /* LoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDA263025D2465100B67292 /* LoadingIndicator.swift */; };
0EDEC0E52650E5A6003112BA /* View+makeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDEC0E42650E5A6003112BA /* View+makeButton.swift */; };
0EE60EFD25FCCCD700D97E7A /* CheckmarkButtonImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE60EFC25FCCCD700D97E7A /* CheckmarkButtonImage.swift */; };
0EEA957B265FE11400689E78 /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = 0EEA957A265FE11400689E78 /* Introspect */; };
0EF10F6626330F29004D6538 /* HollowDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF10F6526330F29004D6538 /* HollowDetailViewController.swift */; };
0EFA3DDE25D3A03D0003C76B /* LoadingLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFA3DDD25D3A03D0003C76B /* LoadingLabel.swift */; };
0EFB4F222639790000530B5F /* ImageTitledStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFB4F212639790000530B5F /* ImageTitledStack.swift */; };
Expand Down Expand Up @@ -651,6 +652,7 @@
0E42905C263A742D008DA046 /* WaterfallGrid in Frameworks */,
0E429070263A8557008DA046 /* ImageScrollView in Frameworks */,
0E429067263A84CA008DA046 /* AppCenterAnalytics in Frameworks */,
0EEA957B265FE11400689E78 /* Introspect in Frameworks */,
0E429065263A84CA008DA046 /* AppCenterCrashes in Frameworks */,
0E42906D263A853E008DA046 /* Connectivity in Frameworks */,
);
Expand Down Expand Up @@ -1388,6 +1390,7 @@
0E42906C263A853E008DA046 /* Connectivity */,
0E42906F263A8557008DA046 /* ImageScrollView */,
0E429072263A8572008DA046 /* Cache */,
0EEA957A265FE11400689E78 /* Introspect */,
);
productName = Hollow;
productReference = 0E415A7025CD769B00351672 /* Hollow.app */;
Expand Down Expand Up @@ -1481,6 +1484,7 @@
0E42906B263A853E008DA046 /* XCRemoteSwiftPackageReference "Connectivity" */,
0E42906E263A8557008DA046 /* XCRemoteSwiftPackageReference "ImageScrollView" */,
0E429071263A8572008DA046 /* XCRemoteSwiftPackageReference "Cache" */,
0EEA9579265FE11400689E78 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
);
productRefGroup = 0E415A7125CD769B00351672 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2048,7 +2052,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 54;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand All @@ -2074,7 +2078,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 54;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand All @@ -2099,7 +2103,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 54;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = C5UH93T368;
INFOPLIST_FILE = HollowWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand Down Expand Up @@ -2127,7 +2131,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 54;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = C5UH93T368;
INFOPLIST_FILE = HollowWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand Down Expand Up @@ -2306,6 +2310,14 @@
minimumVersion = 6.0.1;
};
};
0EEA9579265FE11400689E78 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/siteline/SwiftUI-Introspect.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.1.3;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -2404,6 +2416,11 @@
package = 0E429060263A7568008DA046 /* XCRemoteSwiftPackageReference "Alamofire" */;
productName = Alamofire;
};
0EEA957A265FE11400689E78 /* Introspect */ = {
isa = XCSwiftPackageProductDependency;
package = 0EEA9579265FE11400689E78 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
productName = Introspect;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 0E415A6825CD769B00351672 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
"version": "1.8.1"
}
},
{
"package": "Introspect",
"repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git",
"state": {
"branch": null,
"revision": "2e09be8af614401bc9f87d40093ec19ce56ccaf2",
"version": "0.1.3"
}
},
{
"package": "WaterfallGrid",
"repositoryURL": "https://github.com/paololeonardi/WaterfallGrid.git",
Expand Down
2 changes: 0 additions & 2 deletions Source/Hollow/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
Defaults[.customColorSet] = Defaults[.tempCustomColorSet]
Defaults[.applyCustomColorSet] = Defaults[.customColorSet] != nil
setupApplication(application)
let appearance = UITableView.appearance(whenContainedInInstancesOf: [HollowDetailViewController.self, HollowDetailViewController_iPad.self])
appearance.backgroundColor = UIColor(Color.hollowCardBackground)
return true
}

Expand Down
3 changes: 3 additions & 0 deletions Source/Hollow/View/Components/MyTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct MyTextField<Content>: View where Content: View {
var footer: String? = nil
var isSecureContent = false
var backgroundColor: Color = .hollowCardBackground
var disabled = false
var content: (() -> Content)? = nil

var body: some View {
Expand All @@ -36,6 +37,8 @@ struct MyTextField<Content>: View where Content: View {
.autocapitalization(.none)
.disableAutocorrection(true)
.dynamicFont(size: 16)
.foregroundColor(disabled ? .secondary : nil)
.disabled(disabled)
Spacer()
if let content = content {
content()
Expand Down
2 changes: 1 addition & 1 deletion Source/Hollow/View/Components/SearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct SearchBar: View {
var body: some View {
Button(action:{
// Navigate to search view
withAnimation(.defaultSpring) {
withAnimation {
isSearching = true
}
}) {
Expand Down
7 changes: 3 additions & 4 deletions Source/Hollow/View/Components/Toast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct Toast: View {
.lineSpacing(2)
.lineLimit(4)
}
.animation(.none)
.foregroundColor(configuration.style.fontColor)
.padding()
.padding(.horizontal, 5)
Expand All @@ -94,13 +95,11 @@ struct Toast: View {
.opacity(opacity)
.padding()
.padding(.horizontal)
.animation(.default)
.transition(.move(edge: .bottom))

.onClickGesture(perform: configuration.onTap ?? dismiss)

.onAppear {
withAnimation(.spring()) {
withAnimation(.easeInOut) {
opacity = 1
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5, execute: dismiss)
Expand All @@ -110,7 +109,7 @@ struct Toast: View {

func dismiss() {
guard presented else { return }
withAnimation(.spring()) {
withAnimation(.easeInOut) {
self.opacity = 0
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
Expand Down
27 changes: 0 additions & 27 deletions Source/Hollow/View/Hierarchy/Account/SettingsSubViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,40 +497,13 @@ struct OtherSettingsView: View {
}

private struct ExperimentalFeaturesView: View {
@Default(.reduceImageQuality) var reduceImageQuality
@Default(.useListInDetail) var useListInDetail

var body: some View {
List {
ImageTitledStack(systemImageName: "curlybraces") {
Text("SETTINGSVIEW_OTHER_EXP_FEAT_DESCRIPTION")
}
.padding(.vertical)

Section(
footer: Text("SETTINGSVIEW_OTHER_EXP_REDUCE_IMG_QUALITY_FOOTER").padding(.horizontal)) {
HStack {
Text("SETTINGSVIEW_OTHER_EXP_REDUCE_IMG_QUALITY_LABEL")
Spacer()

Toggle("", isOn: $reduceImageQuality)
.defaultToggleStyle()
}

}

#if !targetEnvironment(macCatalyst)
Section(footer: Text("SETTINGSVIEW_OTHER_EXP_FIX_SCROLL_FOOTER").padding(.horizontal)) {
HStack {
Text("SETTINGSVIEW_OTHER_EXP_FIX_SCROLL_LABEL")
Spacer()

Toggle("", isOn: $useListInDetail)
.defaultToggleStyle()
}

}
#endif

}
.defaultListStyle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct HollowImageView: View {
}

@ScaledMetric private var reloadButtonSize: CGFloat = 50
@Default(.reduceImageQuality) var reduceImageQuality

var body: some View {
Group {
Expand All @@ -46,15 +45,15 @@ struct HollowImageView: View {
if imageAspectRatio >= aspectRatio - 0.001 {
Image(uiImage: image)
.resizable()
.interpolation(reduceImageQuality ? .none : .low)
.interpolation(.low)
.aspectRatio(contentMode: .fit)
.imageSaver(image: image, showSavePhotoAlert: $showSavePhotoAlert, savePhotoError: $savePhotoError)
} else {
ZStack {
Color.hollowCommentQuoteText.opacity(0.09).ignoresSafeArea()
Image(uiImage: image)
.resizable()
.interpolation(reduceImageQuality ? .none : .low)
.interpolation(.low)
.aspectRatio(contentMode: .fit)
.imageSaver(image: image, showSavePhotoAlert: $showSavePhotoAlert, savePhotoError: $savePhotoError)
}
Expand All @@ -63,7 +62,6 @@ struct HollowImageView: View {
}
}

.animation(.default)
.contentShape(RoundedRectangle(cornerRadius: 4))
.onChange(of: showSavePhotoAlert) { show in
if show {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import SwiftUI
import Defaults
import Introspect

struct HollowTextView: View {
var text: String
Expand Down Expand Up @@ -56,12 +57,15 @@ struct HollowTextView: View {
if highlight {
Text.highlightLinksAndCitation(text, modifiers: {
$0.underline()
.foregroundColor(.tint)
.foregroundColor(.hollowContentText)
})

} else {
Text(text)

}
}

.modifier(TextModifier(inDetail: inDetail, compactLineLimit: compactLineLimit))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ extension HollowDetailView {
.background(Color.hollowCardBackground)
.lineLimit(1)

ForEach(comments) { comment in
ForEach(comments, id: \.commentId) { comment in
commentView(for: comment)
.fixedSize(horizontal: false, vertical: true)
.id(comment.commentId)
}

if store.isLoading, postData.replyNumber > postData.comments.count {
Expand All @@ -66,6 +67,7 @@ extension HollowDetailView {
.padding(.horizontal)
.padding(.top, postData.comments.isEmpty ? 0 : 15)
.padding(.bottom, postData.comments.isEmpty ? 15 : 0)
.background(Color.hollowCardBackground)
}
}

Expand Down Expand Up @@ -114,11 +116,7 @@ extension HollowDetailView {
Group {
highlighted ? Color.background : Color.hollowCardBackground
}
.roundedCorner(highlighted ? 10 : 0)
.padding(.horizontal, highlighted ? 10 : 0)
// .transition(.opacity)
)
.contentShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.onClickGesture {
guard !store.isSendingComment && !store.isLoading else { return }
UIImpactFeedbackGenerator(style: .soft).impactOccurred()
Expand Down Expand Up @@ -175,8 +173,6 @@ extension HollowDetailView {
commentId: comment.commentId
)
}
.id(comment.commentId)

}}

}
Expand Down
Loading

0 comments on commit e6de27e

Please sign in to comment.