Skip to content

Commit

Permalink
Some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuz0u committed Mar 19, 2021
1 parent 4cbf062 commit 6a7138d
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 66 deletions.
22 changes: 11 additions & 11 deletions EhPanda.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
ABC3C78F2593699B00E0C11B /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC3C7762593699A00E0C11B /* ViewModifiers.swift */; };
ABC3C7962593699B00E0C11B /* Manga.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC3C7802593699A00E0C11B /* Manga.swift */; };
ABC3C79D259369FE00E0C11B /* Kanna in Frameworks */ = {isa = PBXBuildFile; productRef = ABC3C79C259369FE00E0C11B /* Kanna */; };
ABC5234D25D38D10000F38B0 /* TTProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = ABC5234C25D38D10000F38B0 /* TTProgressHUD */; };
ABCD2F0A259763FC008E5A20 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABCD2F09259763FC008E5A20 /* Request.swift */; };
ABCD2F0E25976B95008E5A20 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABCD2F0D25976B95008E5A20 /* Parser.swift */; };
ABCE3FD325FDECB800299A6F /* TTProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = ABCE3FD225FDECB800299A6F /* TTProgressHUD */; };
ABE0FA2F25D4CAEC00E52F18 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = ABE0FA2E25D4CAEC00E52F18 /* SDWebImageSwiftUI */; };
ABEA1FE625A9B40B002966B9 /* Setting.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABEA1FE525A9B40B002966B9 /* Setting.swift */; };
ABEE0AFA2595C6F800C997AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = ABEE0AFC2595C6F800C997AE /* Localizable.strings */; };
Expand Down Expand Up @@ -149,7 +149,7 @@
ABE0FA2F25D4CAEC00E52F18 /* SDWebImageSwiftUI in Frameworks */,
AB84F47525CAF56D00DAF1EC /* Kingfisher in Frameworks */,
ABC3C79D259369FE00E0C11B /* Kanna in Frameworks */,
ABC5234D25D38D10000F38B0 /* TTProgressHUD in Frameworks */,
ABCE3FD325FDECB800299A6F /* TTProgressHUD in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -267,10 +267,10 @@
isa = PBXGroup;
children = (
ABF45AC025F3313D00ECB568 /* Home */,
ABF45AC625F3313D00ECB568 /* Tools */,
ABF45ACF25F3313D00ECB568 /* Content */,
ABF45AD125F3313D00ECB568 /* Detail */,
ABF45ACF25F3313D00ECB568 /* Content */,
ABF45AD725F3313D00ECB568 /* Setting */,
ABF45AC625F3313D00ECB568 /* Tools */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -355,8 +355,8 @@
packageProductDependencies = (
ABC3C79C259369FE00E0C11B /* Kanna */,
AB84F47425CAF56D00DAF1EC /* Kingfisher */,
ABC5234C25D38D10000F38B0 /* TTProgressHUD */,
ABE0FA2E25D4CAEC00E52F18 /* SDWebImageSwiftUI */,
ABCE3FD225FDECB800299A6F /* TTProgressHUD */,
);
productName = EhPanda;
productReference = ABC3C7542593696C00E0C11B /* EhPanda.app */;
Expand Down Expand Up @@ -390,8 +390,8 @@
packageReferences = (
ABC3C79B259369FE00E0C11B /* XCRemoteSwiftPackageReference "Kanna" */,
AB84F47325CAF56D00DAF1EC /* XCRemoteSwiftPackageReference "Kingfisher" */,
ABC5234B25D38D0F000F38B0 /* XCRemoteSwiftPackageReference "TTProgressHUD" */,
ABE0FA2D25D4CAEC00E52F18 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */,
ABCE3FD125FDECB800299A6F /* XCRemoteSwiftPackageReference "TTProgressHUD" */,
);
productRefGroup = ABC3C7552593696C00E0C11B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -706,7 +706,7 @@
repositoryURL = "https://github.com/onevcat/Kingfisher.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.1.1;
minimumVersion = 6.2.1;
};
};
ABC3C79B259369FE00E0C11B /* XCRemoteSwiftPackageReference "Kanna" */ = {
Expand All @@ -717,7 +717,7 @@
minimumVersion = 5.2.4;
};
};
ABC5234B25D38D0F000F38B0 /* XCRemoteSwiftPackageReference "TTProgressHUD" */ = {
ABCE3FD125FDECB800299A6F /* XCRemoteSwiftPackageReference "TTProgressHUD" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/arakitatsuzou/TTProgressHUD.git";
requirement = {
Expand All @@ -730,7 +730,7 @@
repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
minimumVersion = 2.0.2;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand All @@ -746,9 +746,9 @@
package = ABC3C79B259369FE00E0C11B /* XCRemoteSwiftPackageReference "Kanna" */;
productName = Kanna;
};
ABC5234C25D38D10000F38B0 /* TTProgressHUD */ = {
ABCE3FD225FDECB800299A6F /* TTProgressHUD */ = {
isa = XCSwiftPackageProductDependency;
package = ABC5234B25D38D0F000F38B0 /* XCRemoteSwiftPackageReference "TTProgressHUD" */;
package = ABCE3FD125FDECB800299A6F /* XCRemoteSwiftPackageReference "TTProgressHUD" */;
productName = TTProgressHUD;
};
ABE0FA2E25D4CAEC00E52F18 /* SDWebImageSwiftUI */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/onevcat/Kingfisher.git",
"state": {
"branch": null,
"revision": "81dd1ce8401137637663046c7314e7c885bcc56d",
"version": "6.1.1"
"revision": "bbc4bc4def7eb05a7ba8e1219f80ee9be327334e",
"version": "6.2.1"
}
},
{
Expand All @@ -33,25 +33,25 @@
"repositoryURL": "https://github.com/SDWebImage/SDWebImageSwiftUI.git",
"state": {
"branch": null,
"revision": "6fcaa47f450f8696b19d6f037dcb582ff4deb544",
"version": "2.0.0"
"revision": "cd8625b7cf11a97698e180d28bb7d5d357196678",
"version": "2.0.2"
}
},
{
"package": "SwiftUIVisualEffects",
"repositoryURL": "https://github.com/lucasbrown/swiftui-visual-effects.git",
"state": {
"branch": "master",
"branch": null,
"revision": "b26f8cebd55ff60ed8953768aa818dfb005b5838",
"version": null
"version": "1.0.3"
}
},
{
"package": "TTProgressHUD",
"repositoryURL": "https://github.com/arakitatsuzou/TTProgressHUD.git",
"state": {
"branch": "master",
"revision": "566c8185340b017f3cd5f9a4670cd09c56f86338",
"revision": "6b661dc495cece2955c8986fb8d35da07b0e49b4",
"version": null
}
}
Expand Down
15 changes: 11 additions & 4 deletions EhPanda/App/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ public func isValidDetailURL(url: URL) -> Bool {
&& !url.pathComponents[3].isEmpty
}

public func hideKeyboard() {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder),
to: nil, from: nil, for: nil
)
}

// MARK: UserDefaults
public func setEntry(_ token: String?) {
UserDefaults.standard.set(token, forKey: "entry")
Expand Down Expand Up @@ -257,10 +264,10 @@ public func postAppWidthDidChangeNotification () {


// MARK: Storage Management
public func readableUnit(bytes: Int64) -> String {
public func readableUnit<I: BinaryInteger>(bytes: I) -> String {
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useAll]
return formatter.string(fromByteCount: bytes)
return formatter.string(fromByteCount: Int64(bytes))
}

public func browsingCaches() -> String {
Expand All @@ -279,7 +286,7 @@ public func browsingCaches() -> String {
)
else { return "0 KB" }

return readableUnit(bytes: Int64(data.count))
return readableUnit(bytes: data.count)
}

public func clearCookies() {
Expand All @@ -301,7 +308,7 @@ public func executeMainAsync(_ closure: @escaping (()->())) {
}
}

public func executeMainAsync(_ delay: Double, _ closure: @escaping (()->())) {
public func executeMainAsync(_ delay: DispatchTimeInterval, _ closure: @escaping (()->())) {
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
closure()
}
Expand Down
13 changes: 1 addition & 12 deletions EhPanda/App/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ extension String {
}

func capitalizingFirstLetter() -> String {
return prefix(1).capitalized + dropFirst()
}

mutating func capitalizeFirstLetter() {
self = self.capitalizingFirstLetter()
prefix(1).capitalized + dropFirst()
}

func trimmedTitle() -> String {
Expand Down Expand Up @@ -161,13 +157,6 @@ extension View {
.imageScale(.small)
}
}

func hideKeyboard() {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder),
to: nil, from: nil, for: nil
)
}
}

extension Bundle {
Expand Down
8 changes: 4 additions & 4 deletions EhPanda/View/Content/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private struct ImageContainer: View {
interval: .seconds(0.5)
)
.onProgress(onWebImageProgress)
.loadImmediately()
.resizable()
.scaledToFit()
.onTapGesture(perform: onTap)
Expand All @@ -223,10 +224,9 @@ private struct ImageContainer: View {
)
}

func onWebImageProgress<
Integer : SignedInteger & FixedWidthInteger
> (_ received: Integer, _ total: Integer)
{
func onWebImageProgress<I: BinaryInteger>(
_ received: I, _ total: I
) {
percentage = Float(received) / Float(total)
}
func onTap() {
Expand Down
14 changes: 7 additions & 7 deletions EhPanda/View/Detail/ArchiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ArchiveView: View {
hapticsEnabled: false
)
var loadingHUDConfig = TTProgressHUDConfig(
type: .Loading,
type: .loading,
title: "Communicating...".lString(),
hapticsEnabled: false
)
Expand Down Expand Up @@ -134,32 +134,32 @@ struct ArchiveView: View {
if let sending = value as? Bool,
sending == false
{
var type: TTProgressHUDType = .Warning
var type: TTProgressHUDType = .warning
var title: String?
var caption: String?

if !detailInfo.downloadCommandFailed,
let response = detailInfo.downloadCommandResponse
{
type = .Success
type = .success
title = "Success".lString()
caption = processResponse(response).lString()
} else if detailInfo.downloadCommandFailed {
if let response = detailInfo.downloadCommandResponse {
type = .Error
type = .error
title = "Error".lString()
caption = response.lString()
} else {
type = .Error
type = .error
title = "Error".lString()
caption = nil
}
}

switch type {
case .Success:
case .success:
notificFeedback(style: .success)
case .Error:
case .error:
notificFeedback(style: .error)
default:
print(type)
Expand Down
11 changes: 8 additions & 3 deletions EhPanda/View/Detail/AssociatedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ struct AssociatedView: View {
})
}
}
.transition(
AnyTransition
.opacity
.animation(.default)
)
if moreLoadingFlag {
LoadingView(isCompact: true)
.padding()
Expand All @@ -97,12 +102,12 @@ struct AssociatedView: View {
} else if loadingFlag {
LoadingView()
.padding(.top, 30)
} else if loadFailedFlag {
NetworkErrorView(retryAction: retryAction)
.padding(.top, 30)
} else if notFoundFlag {
NotFoundView(retryAction: retryAction)
.padding(.top, 30)
} else {
NetworkErrorView(retryAction: retryAction)
.padding(.top, 30)
}
}
.padding()
Expand Down
8 changes: 7 additions & 1 deletion EhPanda/View/Detail/CommentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct CommentView: View {

func showHUD() {
hudConfig = TTProgressHUDConfig(
type: .Loading,
type: .loading,
title: "Loading...".lString()
)
hudVisible = true
Expand Down Expand Up @@ -343,13 +343,15 @@ private struct CommentCell: View {
let secondLink = secondLink
{
KFImage(URL(string: imgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 4)
.onTapGesture {
linkAction(link.safeURL())
}
KFImage(URL(string: secondImgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 4)
Expand All @@ -358,10 +360,12 @@ private struct CommentCell: View {
}
} else {
KFImage(URL(string: imgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 4)
KFImage(URL(string: secondImgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 4)
Expand All @@ -372,6 +376,7 @@ private struct CommentCell: View {
else if let imgURL = imgURL {
if let link = link {
KFImage(URL(string: imgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 2)
Expand All @@ -380,6 +385,7 @@ private struct CommentCell: View {
}
} else {
KFImage(URL(string: imgURL))
.loadImmediately()
.resizable()
.scaledToFit()
.frame(width: screenW / 2)
Expand Down
Loading

0 comments on commit 6a7138d

Please sign in to comment.