Skip to content

Commit 241de72

Browse files
authored
Merge pull request #145 from pvieito/master
Added Mac Catalyst support
2 parents 86d8b1a + cb7cd1f commit 241de72

15 files changed

+29
-4
lines changed

RSBarcodesSample/RSBarcodesSample/BarcodeDisplayViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import RSBarcodes
1616
class BarcodeDisplayViewController: UIViewController {
1717
@IBOutlet weak var imageDisplayed: UIImageView!
1818

19-
var contents: String = "https://github.com/VMwareFusion/nautilus"
19+
var contents: String = "https://github.com/yeahdongcn/"
2020

2121
override func viewDidLoad() {
2222
super.viewDidLoad()

Source/RSCode128Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum RSCode128GeneratorCodeTable: Int {
1515

1616
// http://www.barcodeisland.com/code128.phtml
1717
// http://courses.cs.washington.edu/courses/cse370/01au/minirproject/BarcodeBattlers/barcodes.html
18+
@available(macCatalyst 14.0, *)
1819
open class RSCode128Generator: RSAbstractCodeGenerator, RSCheckDigitGenerator {
1920
class RSCode128GeneratorAutoCodeTable {
2021
var startCodeTable = RSCode128GeneratorCodeTable.auto

Source/RSCode39Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ let CODE39_ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"
1212

1313
// http://www.barcodesymbols.com/code39.htm
1414
// http://www.barcodeisland.com/code39.phtml
15+
@available(macCatalyst 14.0, *)
1516
open class RSCode39Generator: RSAbstractCodeGenerator {
1617
let CODE39_CHARACTER_ENCODINGS = [
1718
"1010011011010",

Source/RSCode39Mod43Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import UIKit
1010

1111
// http://www.barcodesymbols.com/code39.htm
1212
// http://www.barcodeisland.com/code39.phtml
13+
@available(macCatalyst 14.0, *)
1314
open class RSCode39Mod43Generator: RSCode39Generator, RSCheckDigitGenerator {
1415

1516
// MARK: RSAbstractCodeGenerator

Source/RSCode93Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import UIKit
1010

1111
// http://www.barcodeisland.com/code93.phtml
12+
@available(macCatalyst 14.0, *)
1213
open class RSCode93Generator: RSAbstractCodeGenerator, RSCheckDigitGenerator {
1314
let CODE93_ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*"
1415

Source/RSCodeDataMatrixGenerator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

11+
@available(macCatalyst 14.0, *)
1112
class RSCodeDataMatrixGenerator: RSAbstractCodeGenerator {
1213

1314
}

Source/RSCodeGenerator.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public enum InputCorrectionLevel: String {
2424
}
2525

2626
// Code generators are required to provide these two functions.
27+
@available(macCatalyst 14.0, *)
2728
public protocol RSCodeGenerator {
2829
/** The fill (background) color of the generated barcode. */
2930
var fillColor: UIColor {get set}
@@ -55,6 +56,7 @@ public protocol RSCheckDigitGenerator {
5556
}
5657

5758
// Abstract code generator, provides default functions for validations and generations.
59+
@available(macCatalyst 14.0, *)
5860
open class RSAbstractCodeGenerator : RSCodeGenerator {
5961

6062
open var fillColor: UIColor = UIColor.white
@@ -112,7 +114,7 @@ open class RSAbstractCodeGenerator : RSCodeGenerator {
112114
height = Int(targetSize.height / targetSize.width * CGFloat(width))
113115
}
114116
let size = CGSize(width: CGFloat(width), height: CGFloat(height))
115-
UIGraphicsBeginImageContextWithOptions(size, false, 0)
117+
UIGraphicsBeginImageContextWithOptions(size, false, 1)
116118
if let context = UIGraphicsGetCurrentContext() {
117119
context.setShouldAntialias(false)
118120

@@ -247,7 +249,7 @@ open class RSAbstractCodeGenerator : RSCodeGenerator {
247249
return target
248250
}
249251

250-
open class func resizeImage(_ source:UIImage, targetSize:CGSize, contentMode:UIView.ContentMode) -> UIImage? {
252+
open class func resizeImage(_ source:UIImage, targetSize:CGSize, contentMode:UIView.ContentMode, scale:CGFloat? = nil) -> UIImage? {
251253
var x: CGFloat = 0
252254
var y: CGFloat = 0
253255
var width = targetSize.width
@@ -298,7 +300,7 @@ open class RSAbstractCodeGenerator : RSCodeGenerator {
298300
}
299301
}
300302

301-
UIGraphicsBeginImageContextWithOptions(targetSize, false, 0)
303+
UIGraphicsBeginImageContextWithOptions(targetSize, false, scale ?? 0)
302304
guard let context = UIGraphicsGetCurrentContext() else { return nil }
303305
context.interpolationQuality = CGInterpolationQuality.none
304306
source.draw(in: CGRect(x: x, y: y, width: width, height: height))

Source/RSCodeReaderViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import AVFoundation
1010
import UIKit
1111

12+
@available(macCatalyst 14.0, *)
13+
@available(iOSApplicationExtension, unavailable)
1214
open class RSCodeReaderViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
1315
@objc open var device = AVCaptureDevice.default(for: AVMediaType.video)
1416
@objc open var output = AVCaptureMetadataOutput()

Source/RSEANGenerator.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public let RSBarcodesTypeISBN13Code = "com.pdq.rsbarcodes.isbn13"
1212
public let RSBarcodesTypeISSN13Code = "com.pdq.rsbarcodes.issn13"
1313

1414
// http://blog.sina.com.cn/s/blog_4015406e0100bsqk.html
15+
@available(macCatalyst 14.0, *)
1516
open class RSEANGenerator: RSAbstractCodeGenerator {
1617
var length = 0
1718
// 'O' for odd and 'E' for even
@@ -100,25 +101,29 @@ open class RSEANGenerator: RSAbstractCodeGenerator {
100101
}
101102
}
102103

104+
@available(macCatalyst 14.0, *)
103105
class RSEAN8Generator: RSEANGenerator {
104106
init() {
105107
super.init(length: 8)
106108
}
107109
}
108110

111+
@available(macCatalyst 14.0, *)
109112
class RSEAN13Generator: RSEANGenerator {
110113
init() {
111114
super.init(length: 13)
112115
}
113116
}
114117

118+
@available(macCatalyst 14.0, *)
115119
class RSISBN13Generator: RSEAN13Generator {
116120
override func isValid(_ contents: String) -> Bool {
117121
// http://www.appsbarcode.com/ISBN.php
118122
return super.isValid(contents) && contents.substring(0, length: 3) == "978"
119123
}
120124
}
121125

126+
@available(macCatalyst 14.0, *)
122127
class RSISSN13Generator: RSEAN13Generator {
123128
override func isValid(_ contents: String) -> Bool {
124129
// http://www.appsbarcode.com/ISSN.php

Source/RSExtendedCode39Generator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public let RSBarcodesTypeExtendedCode39Code = "com.pdq.rsbarcodes.code39.ext"
1212

1313
// http://www.barcodesymbols.com/code39.htm
1414
// http://www.barcodeisland.com/code39.phtml
15+
@available(macCatalyst 14.0, *)
1516
open class RSExtendedCode39Generator: RSCode39Generator {
1617
func encodeContents(_ contents: String) -> String {
1718
var encodedContents = ""

0 commit comments

Comments
 (0)