forked from mintware-de/flutter_barcode_reader
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
24 changed files
with
427 additions
and
87 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
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,53 @@ | ||
// | ||
// Common.swift | ||
// SwiftScanner | ||
// | ||
// Created by Jason on 2018/11/29. | ||
// Copyright © 2018 Jason. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
let bundle = Bundle(for: BarcodeScannerViewController.self) | ||
|
||
let screenWidth = UIScreen.main.bounds.width | ||
|
||
let screenHeight = UIScreen.main.bounds.height | ||
|
||
let statusHeight = UIApplication.shared.statusBarFrame.height | ||
|
||
|
||
public func imageNamed(_ name:String)-> UIImage{ | ||
guard let image = UIImage(named: name, in: bundle, compatibleWith: nil) else{ | ||
return UIImage() | ||
} | ||
return image | ||
} | ||
|
||
|
||
extension UIImage{ | ||
|
||
/// 更改图片颜色 | ||
public func changeColor(_ color : UIColor) -> UIImage{ | ||
|
||
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale) | ||
|
||
color.setFill() | ||
|
||
let bounds = CGRect.init(x: 0, y: 0, width: self.size.width, height: self.size.height) | ||
|
||
UIRectFill(bounds) | ||
|
||
self.draw(in: bounds, blendMode: CGBlendMode.destinationIn, alpha: 1.0) | ||
|
||
let tintedImage = UIGraphicsGetImageFromCurrentImageContext() | ||
UIGraphicsEndImageContext() | ||
|
||
guard let image = tintedImage else { | ||
return UIImage() | ||
} | ||
|
||
return image | ||
} | ||
|
||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ios/Classes/Media.xcassets/ScanLine.imageset/Contents.json
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,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
ios/Classes/Media.xcassets/backArrow.imageset/Contents.json
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Rectangle 19.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "backArrow-1.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "Rectangle [email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+555 Bytes
ios/Classes/Media.xcassets/backArrow.imageset/Rectangle [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
ios/Classes/Media.xcassets/hand_input.imageset/Contents.json
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Mask.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Mask.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,82 @@ | ||
// | ||
// ScanAnimation.swift | ||
// SwiftScanner | ||
// | ||
// Created by Jason on 2018/12/3. | ||
// Copyright © 2018 Jason. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class ScanAnimation:NSObject{ | ||
|
||
static let shared:ScanAnimation = { | ||
|
||
let instance = ScanAnimation() | ||
|
||
return instance | ||
}() | ||
|
||
lazy var animationImageView = UIImageView() | ||
|
||
var displayLink:CADisplayLink? | ||
|
||
var tempFrame:CGRect? | ||
|
||
var contentHeight:CGFloat? | ||
|
||
func startWith(_ rect:CGRect, _ parentView:UIView, imageView:UIImageView) { | ||
|
||
tempFrame = rect | ||
|
||
imageView.frame = tempFrame ?? CGRect.zero | ||
|
||
animationImageView = imageView | ||
|
||
contentHeight = parentView.bounds.height | ||
|
||
parentView.addSubview(imageView) | ||
|
||
setupDisplayLink() | ||
|
||
} | ||
|
||
|
||
@objc func animation() { | ||
|
||
if animationImageView.frame.maxY > contentHeight! + 20 { | ||
animationImageView.frame = tempFrame ?? CGRect.zero | ||
} | ||
|
||
animationImageView.transform = CGAffineTransform(translationX: 0, y: 2).concatenating(animationImageView.transform) | ||
|
||
} | ||
|
||
|
||
func setupDisplayLink() { | ||
|
||
displayLink = CADisplayLink(target: self, selector: #selector(animation)) | ||
|
||
displayLink?.add(to: .current, forMode: .common) | ||
|
||
displayLink?.isPaused = true | ||
|
||
} | ||
|
||
|
||
func startAnimation() { | ||
|
||
displayLink?.isPaused = false | ||
|
||
} | ||
|
||
|
||
func stopAnimation() { | ||
|
||
displayLink?.invalidate() | ||
|
||
displayLink = nil | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.