From 2d555ec3d1cca551b4a8a9ab0d34c050f449ac01 Mon Sep 17 00:00:00 2001 From: "hubin.h" Date: Thu, 21 Nov 2024 15:54:42 +0800 Subject: [PATCH 1/2] add customview, support lotties --- ProgressHUD/Podfile | 11 +++ ProgressHUD/Podfile.lock | 16 ++++ ProgressHUD/Sources/ProgressHUD+Public.swift | 6 ++ ProgressHUD/Sources/ProgressHUD.swift | 56 ++++++++++++- ProgressHUD/app.xcodeproj/project.pbxproj | 83 +++++++++++++++++++- ProgressHUD/app/ViewController.swift | 19 ++++- ProgressHUD/app/loading.json | 1 + 7 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 ProgressHUD/Podfile create mode 100644 ProgressHUD/Podfile.lock create mode 100644 ProgressHUD/app/loading.json diff --git a/ProgressHUD/Podfile b/ProgressHUD/Podfile new file mode 100644 index 0000000..4b4292c --- /dev/null +++ b/ProgressHUD/Podfile @@ -0,0 +1,11 @@ +# Uncomment the next line to define a global platform for your project +platform :ios, '13.0' + +target 'app' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + pod 'lottie-ios' + # Pods for app + +end diff --git a/ProgressHUD/Podfile.lock b/ProgressHUD/Podfile.lock new file mode 100644 index 0000000..55311e0 --- /dev/null +++ b/ProgressHUD/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - lottie-ios (4.5.0) + +DEPENDENCIES: + - lottie-ios + +SPEC REPOS: + trunk: + - lottie-ios + +SPEC CHECKSUMS: + lottie-ios: a881093fab623c467d3bce374367755c272bdd59 + +PODFILE CHECKSUM: a5ec38243dd262d4a40cd9c85bd06975d4a41560 + +COCOAPODS: 1.15.2 diff --git a/ProgressHUD/Sources/ProgressHUD+Public.swift b/ProgressHUD/Sources/ProgressHUD+Public.swift index 05cc9f0..d6b6e68 100644 --- a/ProgressHUD/Sources/ProgressHUD+Public.swift +++ b/ProgressHUD/Sources/ProgressHUD+Public.swift @@ -211,6 +211,12 @@ public extension ProgressHUD { shared.staticImage(text: error?.localizedDescription, image: image ?? imageError, interaction: interaction, delay: delay) } } + + class func custom(_ view: UIView, interaction: Bool = true, delay: TimeInterval? = nil) { + DispatchQueue.main.async { + shared.customView(view: view, interaction: interaction, delay: delay) + } + } } // MARK: - Animation diff --git a/ProgressHUD/Sources/ProgressHUD.swift b/ProgressHUD/Sources/ProgressHUD.swift index 135fe88..cd15ce4 100644 --- a/ProgressHUD/Sources/ProgressHUD.swift +++ b/ProgressHUD/Sources/ProgressHUD.swift @@ -46,6 +46,8 @@ public class ProgressHUD: UIView { var viewStaticImage: UIImageView? var viewAnimation: UIView? + var viewCustomView: UIView? + var animationType = AnimationType.activityIndicator var animationSymbol = "sun.max" @@ -97,6 +99,8 @@ extension ProgressHUD { removeLiveIcon() removeStaticImage() removeAnimationView() + removeCustomView() + setupProgressView(value) setupSizes(text, false) @@ -121,6 +125,8 @@ extension ProgressHUD { removeStaticImage() removeProgressView() removeAnimationView() + removeCustomView() + setupLiveIcon(icon) setupDelayTimer(text, delay) @@ -146,6 +152,8 @@ extension ProgressHUD { removeLiveIcon() removeProgressView() removeAnimationView() + removeCustomView() + setupStaticImage(image) setupDelayTimer(text, delay) @@ -154,6 +162,29 @@ extension ProgressHUD { setupPosition() displayHUD() } + + func customView(view: UIView, interaction: Bool, delay: TimeInterval?) { + + removeDelayTimer() + + setupWindow() + setupBackground(interaction) + setupToolbar() + //setupStatus(text) + + removeLiveIcon() + removeStaticImage() + removeProgressView() + removeAnimationView() + + setupCustomView(view) + setupDelayTimer(nil, delay) + + setupSizes(nil, false) + setupNotifications() + setupPosition() + displayHUD() + } } // MARK: - Animation @@ -371,6 +402,28 @@ extension ProgressHUD { viewStaticImage.image = image viewStaticImage.contentMode = .scaleAspectFit } + + private func removeCustomView() { + viewCustomView?.removeFromSuperview() + viewCustomView = nil + } + + private func setupCustomView(_ view: UIView) { + if (viewCustomView == nil) { + // Set the custom view size to the same as setupSizesTextNone + let width = mediaSize + 2 * marginSize + let height = mediaSize + 2 * marginSize + viewCustomView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height)) + } + + guard let viewCustomView = viewCustomView else { return } + + if (viewCustomView.superview == nil) { + toolbarHUD?.addSubview(viewCustomView) + } + viewCustomView.addSubview(view) + view.center = viewCustomView.center + } } // MARK: - Animation View @@ -591,7 +644,8 @@ extension ProgressHUD { removeStaticImage() removeProgressView() removeAnimationView() - + removeCustomView() + removeStatus() removeToolbar() removeBackground() diff --git a/ProgressHUD/app.xcodeproj/project.pbxproj b/ProgressHUD/app.xcodeproj/project.pbxproj index 180d532..73defb1 100644 --- a/ProgressHUD/app.xcodeproj/project.pbxproj +++ b/ProgressHUD/app.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 189C10292CEEE5F2000657A6 /* loading.json in Resources */ = {isa = PBXBuildFile; fileRef = 189C10282CEEE5F2000657A6 /* loading.json */; }; 295B8482248C1C5B003E8AE6 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 295B8480248C1C5B003E8AE6 /* ViewController.xib */; }; 295B8483248C1C5B003E8AE6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 295B8481248C1C5B003E8AE6 /* ViewController.swift */; }; 298F5A0B2BE4CA2D00656A68 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 298F5A0A2BE4CA2D00656A68 /* PrivacyInfo.xcprivacy */; }; @@ -41,9 +42,11 @@ 29FD93D92AD9781A0054B585 /* ProgressHUD+HorizontalDotScaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FD93C52AD9781A0054B585 /* ProgressHUD+HorizontalDotScaling.swift */; }; 29FD93DA2AD9781A0054B585 /* ProgressHUD+CircleStrokeSpin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FD93C62AD9781A0054B585 /* ProgressHUD+CircleStrokeSpin.swift */; }; 29FD93DB2AD9781A0054B585 /* ProgressHUD+CircleRippleSingle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FD93C72AD9781A0054B585 /* ProgressHUD+CircleRippleSingle.swift */; }; + CAF5AA041269A8891489AEE2 /* Pods_app.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1876D4225324BCCA14CCEBC /* Pods_app.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 189C10282CEEE5F2000657A6 /* loading.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = loading.json; sourceTree = ""; }; 295B8480248C1C5B003E8AE6 /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; 295B8481248C1C5B003E8AE6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 298F5A0A2BE4CA2D00656A68 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; @@ -80,6 +83,9 @@ 29FD93C52AD9781A0054B585 /* ProgressHUD+HorizontalDotScaling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+HorizontalDotScaling.swift"; sourceTree = ""; }; 29FD93C62AD9781A0054B585 /* ProgressHUD+CircleStrokeSpin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+CircleStrokeSpin.swift"; sourceTree = ""; }; 29FD93C72AD9781A0054B585 /* ProgressHUD+CircleRippleSingle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+CircleRippleSingle.swift"; sourceTree = ""; }; + 63B31EA55A04817F9970D9AC /* Pods-app.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app.debug.xcconfig"; path = "Target Support Files/Pods-app/Pods-app.debug.xcconfig"; sourceTree = ""; }; + B27FB696386167C4C8D0198F /* Pods-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app.release.xcconfig"; path = "Target Support Files/Pods-app/Pods-app.release.xcconfig"; sourceTree = ""; }; + D1876D4225324BCCA14CCEBC /* Pods_app.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_app.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -87,6 +93,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + CAF5AA041269A8891489AEE2 /* Pods_app.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -142,6 +149,8 @@ 299876D9248FCB290025E297 /* Sources */, 29D29EF31D9A59E4006CA074 /* app */, 29D29EF21D9A59E4006CA074 /* Products */, + CBC0927ABF953A397BA5C651 /* Pods */, + 3F82EB75273A1DAE3A67593B /* Frameworks */, ); sourceTree = ""; }; @@ -159,6 +168,7 @@ 29D29EF81D9A59E4006CA074 /* AppDelegate.swift */, 29D29F001D9A59E4006CA074 /* Assets.xcassets */, 29D29F051D9A59E4006CA074 /* Info.plist */, + 189C10282CEEE5F2000657A6 /* loading.json */, 29D29F021D9A59E4006CA074 /* LaunchScreen.storyboard */, 29D99E7D2AC4A3300073EE38 /* NavController.swift */, 295B8481248C1C5B003E8AE6 /* ViewController.swift */, @@ -167,6 +177,23 @@ path = app; sourceTree = ""; }; + 3F82EB75273A1DAE3A67593B /* Frameworks */ = { + isa = PBXGroup; + children = ( + D1876D4225324BCCA14CCEBC /* Pods_app.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + CBC0927ABF953A397BA5C651 /* Pods */ = { + isa = PBXGroup; + children = ( + 63B31EA55A04817F9970D9AC /* Pods-app.debug.xcconfig */, + B27FB696386167C4C8D0198F /* Pods-app.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -174,9 +201,11 @@ isa = PBXNativeTarget; buildConfigurationList = 29D29F081D9A59E4006CA074 /* Build configuration list for PBXNativeTarget "app" */; buildPhases = ( + 9A3A1EDF2EF118BFF05F60FD /* [CP] Check Pods Manifest.lock */, 29D29EED1D9A59E4006CA074 /* Sources */, 29D29EEE1D9A59E4006CA074 /* Frameworks */, 29D29EEF1D9A59E4006CA074 /* Resources */, + 226496D1E8590DB300D06B59 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -241,11 +270,55 @@ 295B8482248C1C5B003E8AE6 /* ViewController.xib in Resources */, 298F5A0B2BE4CA2D00656A68 /* PrivacyInfo.xcprivacy in Resources */, 29D29F011D9A59E4006CA074 /* Assets.xcassets in Resources */, + 189C10292CEEE5F2000657A6 /* loading.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 226496D1E8590DB300D06B59 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-app/Pods-app-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/lottie-ios/Lottie.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lottie.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-app/Pods-app-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9A3A1EDF2EF118BFF05F60FD /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-app-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 29D29EED1D9A59E4006CA074 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -415,6 +488,7 @@ }; 29D29F091D9A59E4006CA074 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 63B31EA55A04817F9970D9AC /* Pods-app.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = NO; @@ -425,7 +499,9 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YP9F4937J4; + ENABLE_APP_SANDBOX = NO; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = app/Info.plist; @@ -447,6 +523,7 @@ }; 29D29F0A1D9A59E4006CA074 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B27FB696386167C4C8D0198F /* Pods-app.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = NO; @@ -456,7 +533,9 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = YP9F4937J4; + ENABLE_APP_SANDBOX = NO; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = app/Info.plist; diff --git a/ProgressHUD/app/ViewController.swift b/ProgressHUD/app/ViewController.swift index 09ddafb..9bfe32a 100644 --- a/ProgressHUD/app/ViewController.swift +++ b/ProgressHUD/app/ViewController.swift @@ -10,6 +10,7 @@ // THE SOFTWARE. import UIKit +import Lottie // MARK: - AnimationType extension AnimationType { @@ -71,6 +72,13 @@ class ViewController: UITableViewController { var boolText = false + lazy var animationView: LottieAnimationView = { + let animationView = LottieAnimationView(name: "loading") + animationView.loopMode = .loop + animationView.play() + return animationView + }() + override func viewDidLoad() { super.viewDidLoad() title = "ProgressHUD" @@ -147,7 +155,7 @@ extension ViewController { extension ViewController { override func numberOfSections(in tableView: UITableView) -> Int { - return 8 + return 9 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { @@ -161,6 +169,8 @@ extension ViewController { if (section == 6) { return actions4.count } if (section == 7) { return actions5.count } + if (section == 8) { return 1 } + return 0 } @@ -180,6 +190,8 @@ extension ViewController { if (indexPath.section == 6) { return cellWithText(tableView, actions4[indexPath.row]) } if (indexPath.section == 7) { return cellWithText(tableView, actions5[indexPath.row]) } + if (indexPath.section == 8) && (indexPath.row == 0) { return cellWithText(tableView, "Custom view") } + return UITableViewCell() } @@ -199,6 +211,7 @@ extension ViewController { if (section == 5) { return "Progress" } if (section == 6) { return "Static Image" } if (section == 7) { return "Live Icon" } + if (section == 8) { return "Custom" } return nil } } @@ -265,6 +278,10 @@ extension ViewController { if (indexPath.row == 4) { ProgressHUD.added() } if (indexPath.row == 5) { ProgressHUD.added(textAdded) } } + + if (indexPath.section == 8) { + if (indexPath.row == 0) { ProgressHUD.custom(animationView, delay: TimeInterval(Int.max)) } + } } } diff --git a/ProgressHUD/app/loading.json b/ProgressHUD/app/loading.json new file mode 100644 index 0000000..226ffe0 --- /dev/null +++ b/ProgressHUD/app/loading.json @@ -0,0 +1 @@ +{"nm":"Main Scene","ddd":0,"h":100,"w":100,"meta":{"g":"@lottiefiles/creator 1.37.0"},"layers":[{"ty":0,"nm":"The Insides","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[250,238]},"s":{"a":0,"k":[20,20.000000000000004]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[50,48],"t":49},{"s":[49.99999999999999,47.80000000000001],"t":66}]},"r":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[0],"t":49},{"s":[540],"t":66}]},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"w":500,"h":500,"refId":"precomp_newScene_a35241a1-c35e-4a04-9e90-e328979695d1_de3807e3-a377-4fe0-ac61-06309fcf8fe2","ind":1},{"ty":0,"nm":"The Hourglass Case","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[250,238]},"s":{"a":0,"k":[20,20.000000000000004]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[50,47.70856],"t":49},{"s":[49.99999999999999,48.000000000000014],"t":66}]},"r":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[0],"t":49},{"s":[540],"t":66}]},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"w":500,"h":500,"refId":"precomp_newScene_f9eb9730-1bb1-4300-b8b8-9aaf5adc92d6_0f9edcda-55a9-431d-826d-994c4b717dd1","ind":2},{"ty":0,"nm":"The Hourglass Case","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[250,238]},"s":{"a":0,"k":[0,0]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[50,38.5428],"t":49},{"s":[49.99999999999997,40.00000000000003],"t":66}]},"r":{"a":1,"k":[{"o":{"x":0.65,"y":0},"i":{"x":0.36,"y":1},"s":[0],"t":49},{"s":[540],"t":66}]},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"w":500,"h":500,"refId":"precomp_newScene_f9eb9730-1bb1-4300-b8b8-9aaf5adc92d6_46cbe02f-3568-45ba-b571-27be3bcccc70","ind":3}],"v":"5.7.0","fr":30,"op":66,"ip":0,"assets":[{"nm":"Container","id":"precomp_newScene_f9eb9730-1bb1-4300-b8b8-9aaf5adc92d6_46cbe02f-3568-45ba-b571-27be3bcccc70","layers":[{"ty":4,"nm":"Top Bar","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,72]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Top Bar","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":8},"s":{"a":0,"k":[276,34]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.2275,0.5255,1]},"r":2,"o":{"a":0,"k":100}}],"ind":1},{"ty":4,"nm":"Bottom Bar","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,-0.0011999999999829924]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,406]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Bottom Bar","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":8},"s":{"a":0,"k":[276,34]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.2275,0.5255,1]},"r":2,"o":{"a":0,"k":100}}],"ind":2},{"ty":4,"nm":"Hourglass Top Cover","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[-5.684341886080802e-14,-29.74700314894099]},"s":{"a":0,"k":[118.4398,92.1616]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250.00000000000003,170]},"r":{"a":0,"k":-180},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Hourglass Top Cover","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.8392,0.9961,0.9451]},"r":2,"o":{"a":0,"k":100}}],"ind":3},{"ty":4,"nm":"Hourglass Bottom Cover","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[2.842170943040401e-14,-29.6603076054609]},"s":{"a":0,"k":[118.4398,92.1616]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250.00000000000003,308]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Hourglass Bottom Cover","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.8392,0.9961,0.9451]},"r":2,"o":{"a":0,"k":100}}],"ind":4}]},{"nm":"Content","id":"precomp_newScene_a35241a1-c35e-4a04-9e90-e328979695d1_de3807e3-a377-4fe0-ac61-06309fcf8fe2","layers":[{"ty":4,"nm":"Flow","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[111.6704,202.9398]},"s":{"a":0,"k":[100,22.5423]},"sk":{"a":0,"k":0},"p":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[250,214],"t":0},{"s":[250,214],"t":12}]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sh","bm":0,"hd":false,"nm":"Flow","d":1,"ks":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[{"c":false,"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[111.67037932559299,204.8788387073137],[111.67037932559299,255.45615318879766]]}],"t":0},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[{"c":false,"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[111.67037932559299,257.80217405157236],[111.67037932559299,927.6928640578246]]}],"t":12},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[{"c":false,"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[111.67037932559299,257.80217405157236],[111.67037932559299,927.6928640578246]]}],"t":46},{"s":[{"c":false,"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[111.67037932559299,368.66657070140855],[111.67037932559299,927.6928640578246]]}],"t":49}]}},{"ty":"st","bm":0,"hd":false,"nm":"Stroke","lc":2,"lj":2,"ml":1,"o":{"a":0,"k":100},"w":{"a":0,"k":4},"c":{"a":0,"k":[0,0.8667,0.702]}}],"ind":1},{"ty":4,"nm":"Top Content","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,-117.30744604145977]},"s":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[96.1842,74.8438],"t":7},{"s":[0,0],"t":49}]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,229.0483]},"r":{"a":0,"k":-180},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Top Content","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0,0.8667,0.702]},"r":2,"o":{"a":0,"k":100}}],"ind":2},{"ty":4,"nm":"Bottom Content","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,58.81121709429772]},"s":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[0.4304,0.3349],"t":13},{"s":[96.1734,75.4858],"t":49}]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,377.85]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Bottom Content","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0,0.8667,0.702]},"r":2,"o":{"a":0,"k":100}}],"ind":3},{"ty":4,"nm":"Top Container","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[5.684341886080802e-14,-29.123788878141]},"s":{"a":0,"k":[96.1842,74.8438]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[249.99999999999997,163]},"r":{"a":0,"k":-180},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Top Container","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[1,1,1]},"r":2,"o":{"a":0,"k":100}}],"ind":4},{"ty":4,"nm":"Bottom Container","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[-5.684341886080802e-14,-29.372440069021252]},"s":{"a":0,"k":[96.1842,74.8438]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[249.99999999999994,312]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Bottom Container","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[1,1,1]},"r":2,"o":{"a":0,"k":100}}],"ind":5}]},{"nm":"Container_1","id":"precomp_newScene_f9eb9730-1bb1-4300-b8b8-9aaf5adc92d6_0f9edcda-55a9-431d-826d-994c4b717dd1","layers":[{"ty":4,"nm":"Top Bar","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,72]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Top Bar","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":8},"s":{"a":0,"k":[276,34]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.2275,0.5255,1]},"r":2,"o":{"a":0,"k":100}}],"ind":1},{"ty":4,"nm":"Bottom Bar","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,-0.0011999999999829924]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250,406]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Bottom Bar","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":8},"s":{"a":0,"k":[276,34]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.2275,0.5255,1]},"r":2,"o":{"a":0,"k":100}}],"ind":2},{"ty":4,"nm":"Hourglass Top Cover","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[-5.684341886080802e-14,-29.74700314894099]},"s":{"a":0,"k":[118.4398,92.1616]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250.00000000000003,170]},"r":{"a":0,"k":-180},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Hourglass Top Cover","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.8392,0.9961,0.9451]},"r":2,"o":{"a":0,"k":100}}],"ind":3},{"ty":4,"nm":"Hourglass Bottom Cover","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[2.842170943040401e-14,-29.6603076054609]},"s":{"a":0,"k":[118.4398,92.1616]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[250.00000000000003,308]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"sr","bm":0,"hd":false,"nm":"Hourglass Bottom Cover","d":1,"pt":{"a":0,"k":3},"p":{"a":0,"k":[0,0]},"or":{"a":0,"k":117.20209868256958},"os":{"a":0,"k":0},"r":{"a":0,"k":0},"sy":2},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[0.8392,0.9961,0.9451]},"r":2,"o":{"a":0,"k":100}}],"ind":4}]}]} \ No newline at end of file From 93c1a9be33704c7f6a8f55f4a6205b030403005d Mon Sep 17 00:00:00 2001 From: "hubin.h" Date: Thu, 21 Nov 2024 16:24:31 +0800 Subject: [PATCH 2/2] code block structure adjustment --- ProgressHUD/Sources/ProgressHUD.swift | 52 +++++++++++++++------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/ProgressHUD/Sources/ProgressHUD.swift b/ProgressHUD/Sources/ProgressHUD.swift index cd15ce4..f0e5428 100644 --- a/ProgressHUD/Sources/ProgressHUD.swift +++ b/ProgressHUD/Sources/ProgressHUD.swift @@ -162,29 +162,6 @@ extension ProgressHUD { setupPosition() displayHUD() } - - func customView(view: UIView, interaction: Bool, delay: TimeInterval?) { - - removeDelayTimer() - - setupWindow() - setupBackground(interaction) - setupToolbar() - //setupStatus(text) - - removeLiveIcon() - removeStaticImage() - removeProgressView() - removeAnimationView() - - setupCustomView(view) - setupDelayTimer(nil, delay) - - setupSizes(nil, false) - setupNotifications() - setupPosition() - displayHUD() - } } // MARK: - Animation @@ -200,8 +177,10 @@ extension ProgressHUD { setupStatus(text) removeLiveIcon() + removeCustomView() removeStaticImage() removeProgressView() + setupAnimationView() setupSizes(text, true) @@ -211,6 +190,33 @@ extension ProgressHUD { } } +// MARK: - CustomView +extension ProgressHUD { + + func customView(view: UIView, interaction: Bool, delay: TimeInterval?) { + + removeDelayTimer() + + setupWindow() + setupBackground(interaction) + setupToolbar() + //setupStatus(text) + + removeLiveIcon() + removeStaticImage() + removeProgressView() + removeAnimationView() + + setupCustomView(view) + setupDelayTimer(nil, delay) + + setupSizes(nil, false) + setupNotifications() + setupPosition() + displayHUD() + } +} + // MARK: - Delay Timer extension ProgressHUD {