From fa441c0d0ab526f2ba6c60d54d1eedd79f794049 Mon Sep 17 00:00:00 2001 From: parth0072 Date: Tue, 6 Feb 2018 13:24:44 +0530 Subject: [PATCH 1/3] - added image cache - change alpa of notification view --- InAppNotify/InAppNotify.swift | 29 +++++++++++++++++++++------ InAppNotify/NotificationFactory.swift | 6 +++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/InAppNotify/InAppNotify.swift b/InAppNotify/InAppNotify.swift index adb827f..674010d 100644 --- a/InAppNotify/InAppNotify.swift +++ b/InAppNotify/InAppNotify.swift @@ -8,6 +8,9 @@ import Foundation +let imageCache = NSCache() + + public class InAppNotify{ /// Notify current dislayed @@ -17,6 +20,8 @@ public class InAppNotify{ public static var theme:Theme = Themes.dark + + /// Function to show notify /// /// - Parameters: @@ -202,12 +207,13 @@ public struct NotificationSize { // MARK: - UIImageView extension UIImageView{ - + /// Set an image in UIImageView from remote URL /// /// - Parameter url: url of the image func setImageFromURL(stringImageUrl url: String){ + //Placeholder image image = #imageLiteral(resourceName: "user_blank") @@ -216,12 +222,23 @@ extension UIImageView{ if let url = URL(string: url) { do{ - let data = try Data.init(contentsOf: url) - - //Set image in the main thread - DispatchQueue.main.async { - self.image = UIImage(data: data) + //get from cache + if let cachedImage = imageCache.object(forKey: url.absoluteString as NSString) { + //Set image in the main thread + DispatchQueue.main.async { + self.image = cachedImage + } + + }else{ + let data = try Data.init(contentsOf: url) + + //Set image in the main thread + DispatchQueue.main.async { + self.image = UIImage(data: data) + imageCache.setObject(self.image!, forKey: url.absoluteString as NSString) + } } + }catch{ diff --git a/InAppNotify/NotificationFactory.swift b/InAppNotify/NotificationFactory.swift index 8f5deda..13cf182 100644 --- a/InAppNotify/NotificationFactory.swift +++ b/InAppNotify/NotificationFactory.swift @@ -25,7 +25,7 @@ open class NotificationFactory: UIView,UITextViewDelegate { let view = UIView() view.backgroundColor = InAppNotify.theme.backgroundColor - view.alpha = 0.8 + view.alpha = 1 view.clipsToBounds = true return view @@ -382,7 +382,7 @@ open class NotificationFactory: UIView,UITextViewDelegate { // MARK: - Handling screen orientation - @objc func orientationDidChange() { + func orientationDidChange() { rotated = true /// Get fixed size @@ -419,7 +419,7 @@ open class NotificationFactory: UIView,UITextViewDelegate { } /// MARK: - Gesture methods - @objc open func displayTimerDidFire() { + open func displayTimerDidFire() { //stop if user is dragging if panGestureActive { return } From 968e1f8c7fcdc201cd59fdc86d9a7c9b1c2b2d78 Mon Sep 17 00:00:00 2001 From: Parth Kshatriya Date: Wed, 7 Feb 2018 08:54:09 +0530 Subject: [PATCH 2/3] fixed @objc swift 4 support --- InAppNotify/NotificationFactory.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InAppNotify/NotificationFactory.swift b/InAppNotify/NotificationFactory.swift index 13cf182..07d4e60 100644 --- a/InAppNotify/NotificationFactory.swift +++ b/InAppNotify/NotificationFactory.swift @@ -382,7 +382,7 @@ open class NotificationFactory: UIView,UITextViewDelegate { // MARK: - Handling screen orientation - func orientationDidChange() { + @objc func orientationDidChange() { rotated = true /// Get fixed size @@ -419,7 +419,7 @@ open class NotificationFactory: UIView,UITextViewDelegate { } /// MARK: - Gesture methods - open func displayTimerDidFire() { + @objc open func displayTimerDidFire() { //stop if user is dragging if panGestureActive { return } From 4e5c4f43983c6e02acfff019a13ac1e6dfa16406 Mon Sep 17 00:00:00 2001 From: Parth Kshatriya Date: Sat, 12 Jun 2021 08:57:00 +0530 Subject: [PATCH 3/3] Create swift.yml --- .github/workflows/swift.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..5dbdb4f --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,19 @@ +name: Swift + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - name: Build + run: swift build -v + - name: Run tests + run: swift test -v