-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
550a156
commit c927ba5
Showing
10 changed files
with
1,497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
MemoryChainKit/Sources/UI Component/ScanQRCode/ARIPermission.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// ARIPermission.swift | ||
// ARIScanCodeKit | ||
// | ||
// Created by marc zhao on 2022/4/7. | ||
// | ||
|
||
|
||
|
||
import UIKit | ||
import AVFoundation | ||
import Photos | ||
import AssetsLibrary | ||
|
||
|
||
|
||
class ARIPermissions: NSObject { | ||
|
||
//MARK: ----获取相册权限 | ||
static func authorizePhotoWith(comletion: @escaping (Bool) -> Void) { | ||
let granted = PHPhotoLibrary.authorizationStatus() | ||
switch granted { | ||
case PHAuthorizationStatus.authorized: | ||
comletion(true) | ||
case PHAuthorizationStatus.denied, PHAuthorizationStatus.restricted: | ||
comletion(false) | ||
case PHAuthorizationStatus.notDetermined: | ||
PHPhotoLibrary.requestAuthorization({ status in | ||
DispatchQueue.main.async { | ||
comletion(status == PHAuthorizationStatus.authorized) | ||
} | ||
}) | ||
case .limited: | ||
comletion(true) | ||
@unknown default: | ||
comletion(false) | ||
} | ||
} | ||
|
||
//MARK: ---相机权限 | ||
static func authorizeCameraWith(completion: @escaping (Bool) -> Void) { | ||
let granted = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) | ||
switch granted { | ||
case .authorized: | ||
completion(true) | ||
case .denied: | ||
completion(false) | ||
case .restricted: | ||
completion(false) | ||
case .notDetermined: | ||
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { (granted: Bool) in | ||
DispatchQueue.main.async { | ||
completion(granted) | ||
} | ||
}) | ||
@unknown default: | ||
completion(false) | ||
} | ||
} | ||
|
||
//MARK: 跳转到APP系统设置权限界面 | ||
static func jumpToSystemPrivacySetting() { | ||
guard let appSetting = URL(string: UIApplication.openSettingsURLString) else { | ||
return | ||
} | ||
if #available(iOS 10, *) { | ||
UIApplication.shared.open(appSetting, options: [:], completionHandler: nil) | ||
} else { | ||
UIApplication.shared.openURL(appSetting) | ||
} | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
MemoryChainKit/Sources/UI Component/ScanQRCode/ARIScanLineAnimation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// ARIScanLineAnimation.swift | ||
// ARIScanCodeKit | ||
// | ||
// Created by marc zhao on 2022/4/7. | ||
// | ||
|
||
import UIKit | ||
|
||
class ARIScanLineAnimation: UIImageView { | ||
|
||
var isAnimationing = false | ||
var animationRect = CGRect.zero | ||
|
||
func startAnimatingWithRect(animationRect: CGRect, parentView: UIView, image: UIImage?) { | ||
self.image = image | ||
self.animationRect = animationRect | ||
parentView.addSubview(self) | ||
|
||
isHidden = false | ||
isAnimationing = true | ||
if image != nil { | ||
stepAnimation() | ||
} | ||
} | ||
|
||
@objc func stepAnimation() { | ||
guard isAnimationing else { | ||
return | ||
} | ||
var frame = animationRect | ||
let hImg = image!.size.height * animationRect.size.width / image!.size.width | ||
|
||
frame.origin.y -= hImg | ||
frame.size.height = hImg | ||
self.frame = frame | ||
alpha = 0.0 | ||
|
||
UIView.animate(withDuration: 1.4, animations: { | ||
self.alpha = 1.0 | ||
var frame = self.animationRect | ||
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width | ||
frame.origin.y += (frame.size.height - hImg) | ||
frame.size.height = hImg | ||
self.frame = frame | ||
}, completion: { _ in | ||
self.perform(#selector(ARIScanLineAnimation.stepAnimation), with: nil, afterDelay: 0.3) | ||
}) | ||
} | ||
|
||
func stopStepAnimating() { | ||
isHidden = true | ||
isAnimationing = false | ||
} | ||
|
||
public static func instance() -> ARIScanLineAnimation { | ||
return ARIScanLineAnimation() | ||
} | ||
|
||
deinit { | ||
stopStepAnimating() | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
MemoryChainKit/Sources/UI Component/ScanQRCode/ARIScanNetAnimation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// ARIScanNetAnimation.swift | ||
// ARIScanCodeKit | ||
// | ||
// Created by marc zhao on 2022/4/7. | ||
// | ||
|
||
import UIKit | ||
|
||
|
||
|
||
|
||
class ARIScanNetAnimation: UIImageView { | ||
|
||
var isAnimationing = false | ||
var animationRect = CGRect.zero | ||
|
||
public static func instance() -> ARIScanNetAnimation { | ||
return ARIScanNetAnimation() | ||
} | ||
|
||
func startAnimatingWithRect(animationRect: CGRect, parentView: UIView, image: UIImage?) { | ||
self.image = image | ||
self.animationRect = animationRect | ||
parentView.addSubview(self) | ||
|
||
isHidden = false | ||
|
||
isAnimationing = true | ||
|
||
if image != nil { | ||
stepAnimation() | ||
} | ||
} | ||
|
||
@objc func stepAnimation() { | ||
guard isAnimationing else { | ||
return | ||
} | ||
var frame = animationRect | ||
|
||
let hImg = image!.size.height * animationRect.size.width / image!.size.width | ||
|
||
frame.origin.y -= hImg | ||
frame.size.height = hImg | ||
self.frame = frame | ||
|
||
alpha = 0.0 | ||
|
||
UIView.animate(withDuration: 1.2, animations: { | ||
self.alpha = 1.0 | ||
|
||
var frame = self.animationRect | ||
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width | ||
|
||
frame.origin.y += (frame.size.height - hImg) | ||
frame.size.height = hImg | ||
|
||
self.frame = frame | ||
|
||
}, completion: { _ in | ||
self.perform(#selector(ARIScanNetAnimation.stepAnimation), with: nil, afterDelay: 0.3) | ||
}) | ||
} | ||
|
||
func stopStepAnimating() { | ||
isHidden = true | ||
isAnimationing = false | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
MemoryChainKit/Sources/UI Component/ScanQRCode/ARIScanResult.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// ARIScanResult.swift | ||
// ARIScanCodeKit | ||
// | ||
// Created by marc zhao on 2022/4/19. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
|
||
public struct ARIScanResult { | ||
|
||
/// 码内容 | ||
public var strScanned: String? | ||
|
||
/// 扫描图像 | ||
public var imgScanned: UIImage? | ||
|
||
/// 码的类型 | ||
public var strBarCodeType: String? | ||
|
||
/// 码在图像中的位置 | ||
public var arrayCorner: [AnyObject]? | ||
|
||
public init(str: String?, img: UIImage?, barCodeType: String?, corner: [AnyObject]?) { | ||
strScanned = str | ||
imgScanned = img | ||
strBarCodeType = barCodeType | ||
arrayCorner = corner | ||
} | ||
} |
Oops, something went wrong.