Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add customview, support lotties #180

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ProgressHUD/Podfile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions ProgressHUD/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions ProgressHUD/Sources/ProgressHUD+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 61 additions & 1 deletion ProgressHUD/Sources/ProgressHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -97,6 +99,8 @@ extension ProgressHUD {
removeLiveIcon()
removeStaticImage()
removeAnimationView()
removeCustomView()

setupProgressView(value)

setupSizes(text, false)
Expand All @@ -121,6 +125,8 @@ extension ProgressHUD {
removeStaticImage()
removeProgressView()
removeAnimationView()
removeCustomView()

setupLiveIcon(icon)
setupDelayTimer(text, delay)

Expand All @@ -146,6 +152,8 @@ extension ProgressHUD {
removeLiveIcon()
removeProgressView()
removeAnimationView()
removeCustomView()

setupStaticImage(image)
setupDelayTimer(text, delay)

Expand All @@ -169,8 +177,10 @@ extension ProgressHUD {
setupStatus(text)

removeLiveIcon()
removeCustomView()
removeStaticImage()
removeProgressView()

setupAnimationView()

setupSizes(text, true)
Expand All @@ -180,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 {

Expand Down Expand Up @@ -371,6 +408,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
Expand Down Expand Up @@ -591,7 +650,8 @@ extension ProgressHUD {
removeStaticImage()
removeProgressView()
removeAnimationView()

removeCustomView()

removeStatus()
removeToolbar()
removeBackground()
Expand Down
83 changes: 81 additions & 2 deletions ProgressHUD/app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
295B8480248C1C5B003E8AE6 /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = "<group>"; };
295B8481248C1C5B003E8AE6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
298F5A0A2BE4CA2D00656A68 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
Expand Down Expand Up @@ -80,13 +83,17 @@
29FD93C52AD9781A0054B585 /* ProgressHUD+HorizontalDotScaling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+HorizontalDotScaling.swift"; sourceTree = "<group>"; };
29FD93C62AD9781A0054B585 /* ProgressHUD+CircleStrokeSpin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+CircleStrokeSpin.swift"; sourceTree = "<group>"; };
29FD93C72AD9781A0054B585 /* ProgressHUD+CircleRippleSingle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+CircleRippleSingle.swift"; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 */
29D29EEE1D9A59E4006CA074 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CAF5AA041269A8891489AEE2 /* Pods_app.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -142,6 +149,8 @@
299876D9248FCB290025E297 /* Sources */,
29D29EF31D9A59E4006CA074 /* app */,
29D29EF21D9A59E4006CA074 /* Products */,
CBC0927ABF953A397BA5C651 /* Pods */,
3F82EB75273A1DAE3A67593B /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -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 */,
Expand All @@ -167,16 +177,35 @@
path = app;
sourceTree = "<group>";
};
3F82EB75273A1DAE3A67593B /* Frameworks */ = {
isa = PBXGroup;
children = (
D1876D4225324BCCA14CCEBC /* Pods_app.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
CBC0927ABF953A397BA5C651 /* Pods */ = {
isa = PBXGroup;
children = (
63B31EA55A04817F9970D9AC /* Pods-app.debug.xcconfig */,
B27FB696386167C4C8D0198F /* Pods-app.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
29D29EF01D9A59E4006CA074 /* app */ = {
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 = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -415,6 +488,7 @@
};
29D29F091D9A59E4006CA074 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 63B31EA55A04817F9970D9AC /* Pods-app.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = NO;
Expand All @@ -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;
Expand All @@ -447,6 +523,7 @@
};
29D29F0A1D9A59E4006CA074 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B27FB696386167C4C8D0198F /* Pods-app.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = NO;
Expand All @@ -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;
Expand Down
Loading