Showing
4 changed files
with
58 additions
and
65 deletions
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; }; | 15 | 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; }; |
| 16 | 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; | 16 | 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; |
| 17 | 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; }; | 17 | 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; }; |
| 18 | + 1EBB036F281BE3610062F663 /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBB036E281BE3610062F663 /* RSBarcodes_Swift */; }; | ||
| 18 | 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; }; | 19 | 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; }; |
| 19 | 1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; }; | 20 | 1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; }; |
| 20 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; }; | 21 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; }; |
| ... | @@ -292,6 +293,7 @@ | ... | @@ -292,6 +293,7 @@ |
| 292 | isa = PBXFrameworksBuildPhase; | 293 | isa = PBXFrameworksBuildPhase; |
| 293 | buildActionMask = 2147483647; | 294 | buildActionMask = 2147483647; |
| 294 | files = ( | 295 | files = ( |
| 296 | + 1EBB036F281BE3610062F663 /* RSBarcodes_Swift in Frameworks */, | ||
| 295 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */, | 297 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */, |
| 296 | ); | 298 | ); |
| 297 | runOnlyForDeploymentPostprocessing = 0; | 299 | runOnlyForDeploymentPostprocessing = 0; |
| ... | @@ -671,6 +673,9 @@ | ... | @@ -671,6 +673,9 @@ |
| 671 | dependencies = ( | 673 | dependencies = ( |
| 672 | ); | 674 | ); |
| 673 | name = WarplySDKFrameworkIOS; | 675 | name = WarplySDKFrameworkIOS; |
| 676 | + packageProductDependencies = ( | ||
| 677 | + 1EBB036E281BE3610062F663 /* RSBarcodes_Swift */, | ||
| 678 | + ); | ||
| 674 | productName = WarplySDKFrameworkIOS; | 679 | productName = WarplySDKFrameworkIOS; |
| 675 | productReference = E6D8DE6827A942010006A3A9 /* WarplySDKFrameworkIOS.framework */; | 680 | productReference = E6D8DE6827A942010006A3A9 /* WarplySDKFrameworkIOS.framework */; |
| 676 | productType = "com.apple.product-type.framework"; | 681 | productType = "com.apple.product-type.framework"; |
| ... | @@ -699,6 +704,9 @@ | ... | @@ -699,6 +704,9 @@ |
| 699 | Base, | 704 | Base, |
| 700 | ); | 705 | ); |
| 701 | mainGroup = E6D8DE5E27A942000006A3A9; | 706 | mainGroup = E6D8DE5E27A942000006A3A9; |
| 707 | + packageReferences = ( | ||
| 708 | + 1EBB036D281BE3610062F663 /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */, | ||
| 709 | + ); | ||
| 702 | productRefGroup = E6D8DE6927A942010006A3A9 /* Products */; | 710 | productRefGroup = E6D8DE6927A942010006A3A9 /* Products */; |
| 703 | projectDirPath = ""; | 711 | projectDirPath = ""; |
| 704 | projectRoot = ""; | 712 | projectRoot = ""; |
| ... | @@ -1045,6 +1053,25 @@ | ... | @@ -1045,6 +1053,25 @@ |
| 1045 | defaultConfigurationName = Release; | 1053 | defaultConfigurationName = Release; |
| 1046 | }; | 1054 | }; |
| 1047 | /* End XCConfigurationList section */ | 1055 | /* End XCConfigurationList section */ |
| 1056 | + | ||
| 1057 | +/* Begin XCRemoteSwiftPackageReference section */ | ||
| 1058 | + 1EBB036D281BE3610062F663 /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */ = { | ||
| 1059 | + isa = XCRemoteSwiftPackageReference; | ||
| 1060 | + repositoryURL = "https://github.com/yeahdongcn/RSBarcodes_Swift"; | ||
| 1061 | + requirement = { | ||
| 1062 | + kind = upToNextMajorVersion; | ||
| 1063 | + minimumVersion = 5.0.0; | ||
| 1064 | + }; | ||
| 1065 | + }; | ||
| 1066 | +/* End XCRemoteSwiftPackageReference section */ | ||
| 1067 | + | ||
| 1068 | +/* Begin XCSwiftPackageProductDependency section */ | ||
| 1069 | + 1EBB036E281BE3610062F663 /* RSBarcodes_Swift */ = { | ||
| 1070 | + isa = XCSwiftPackageProductDependency; | ||
| 1071 | + package = 1EBB036D281BE3610062F663 /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */; | ||
| 1072 | + productName = RSBarcodes_Swift; | ||
| 1073 | + }; | ||
| 1074 | +/* End XCSwiftPackageProductDependency section */ | ||
| 1048 | }; | 1075 | }; |
| 1049 | rootObject = E6D8DE5F27A942010006A3A9 /* Project object */; | 1076 | rootObject = E6D8DE5F27A942010006A3A9 /* Project object */; |
| 1050 | } | 1077 | } | ... | ... |
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcshareddata/swiftpm/Package.resolved
0 → 100644
| 1 | +{ | ||
| 2 | + "object": { | ||
| 3 | + "pins": [ | ||
| 4 | + { | ||
| 5 | + "package": "RSBarcodes_Swift", | ||
| 6 | + "repositoryURL": "https://github.com/yeahdongcn/RSBarcodes_Swift", | ||
| 7 | + "state": { | ||
| 8 | + "branch": null, | ||
| 9 | + "revision": "86d8b1a1439e7edb19793d17732b15fd784a0a15", | ||
| 10 | + "version": "5.1.1" | ||
| 11 | + } | ||
| 12 | + } | ||
| 13 | + ] | ||
| 14 | + }, | ||
| 15 | + "version": 1 | ||
| 16 | +} |
No preview for this file type
| ... | @@ -10,8 +10,8 @@ import SwiftUI | ... | @@ -10,8 +10,8 @@ import SwiftUI |
| 10 | import Combine | 10 | import Combine |
| 11 | import Foundation | 11 | import Foundation |
| 12 | import UIKit | 12 | import UIKit |
| 13 | -// import RSBarcodes_Swift | 13 | +import RSBarcodes_Swift |
| 14 | -// import AVFoundation | 14 | +import AVFoundation |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| ... | @@ -95,35 +95,6 @@ extension CouponBarcodeView { | ... | @@ -95,35 +95,6 @@ extension CouponBarcodeView { |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | - func generateBarcode(from string: String) -> Image? { | ||
| 99 | - | ||
| 100 | - let data = string.data(using: String.Encoding.ascii) | ||
| 101 | - | ||
| 102 | - if let filter = CIFilter(name: "CICode128BarcodeGenerator") { | ||
| 103 | - filter.setValue(data, forKey: "inputMessage") | ||
| 104 | -// let transform = CGAffineTransform(scaleX: 3, y: 3) | ||
| 105 | - | ||
| 106 | - | ||
| 107 | -// if let output = filter.outputImage?.transformed(by: transform) { | ||
| 108 | - if let output = filter.outputImage { | ||
| 109 | - | ||
| 110 | -// // Change the color using CIFilter | ||
| 111 | -// let colorParameters = [ | ||
| 112 | -// "inputColor0": CIColor(color: UIColor.black), // Foreground | ||
| 113 | -// "inputColor1": CIColor(color: UIColor.clear) // Background | ||
| 114 | -// ] | ||
| 115 | -// let colored = output.applyingFilter("CIFalseColor", parameters: colorParameters) | ||
| 116 | - let image = Image(uiImage: UIImage(ciImage: output)) | ||
| 117 | - | ||
| 118 | -// return UIImage(ciImage: output) | ||
| 119 | - return image | ||
| 120 | - } | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - return nil | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - | ||
| 127 | func constructBarcode() -> String? { | 98 | func constructBarcode() -> String? { |
| 128 | // EAN 13 barcode construction | 99 | // EAN 13 barcode construction |
| 129 | let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] | 100 | let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] |
| ... | @@ -161,6 +132,7 @@ extension CouponBarcodeView { | ... | @@ -161,6 +132,7 @@ extension CouponBarcodeView { |
| 161 | 132 | ||
| 162 | var body: some View { | 133 | var body: some View { |
| 163 | let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] | 134 | let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] |
| 135 | + let barcodeString = constructBarcode() ?? "" | ||
| 164 | 136 | ||
| 165 | GeometryReader { geometry in | 137 | GeometryReader { geometry in |
| 166 | ScrollView(showsIndicators: false) { | 138 | ScrollView(showsIndicators: false) { |
| ... | @@ -222,45 +194,23 @@ extension CouponBarcodeView { | ... | @@ -222,45 +194,23 @@ extension CouponBarcodeView { |
| 222 | .frame(maxWidth: .infinity) | 194 | .frame(maxWidth: .infinity) |
| 223 | .padding(.top, self.uiscreen.height * 0.015) | 195 | .padding(.top, self.uiscreen.height * 0.015) |
| 224 | 196 | ||
| 225 | - // TODO: Add the barcode | 197 | +// let isValid = RSUnifiedCodeValidator.shared.isValid(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue) |
| 226 | -// Image(uiImage: UIImage(ciImage: output)) | ||
| 227 | 198 | ||
| 228 | -// let isValid = RSUnifiedCodeValidator.shared.isValid("1234567891234", machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue) | 199 | + if let barcodeImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.1)) { |
| 229 | - | ||
| 230 | -// if let barcodeImage = RSUnifiedCodeGenerator.shared.generateCode("1234567891234", machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: 300, height: 300)) { | ||
| 231 | 200 | ||
| 232 | -// VStack(alignment: .center) { | ||
| 233 | -// Image(uiImage: image) | ||
| 234 | -// .resizable() | ||
| 235 | -// .aspectRatio(contentMode: .fit) | ||
| 236 | -// .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.05) | ||
| 237 | // | 201 | // |
| 238 | -// } | 202 | + VStack(alignment: .center) { |
| 239 | -// .frame(maxWidth: .infinity) | 203 | + Image(uiImage: barcodeImage) |
| 240 | -// .padding(.top, self.uiscreen.height * 0.01) | 204 | + .resizable() |
| 241 | - | 205 | + .aspectRatio(contentMode: .fit) |
| 242 | -// Image(uiImage: UIImage(named: "ic_back")!) | 206 | + .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.1) |
| 243 | -// .renderingMode(.original) | 207 | + } |
| 244 | -// .resizable() | 208 | + .frame(maxWidth: .infinity) |
| 245 | -// .aspectRatio(contentMode: .fit) | 209 | + .padding(.top, self.uiscreen.height * 0.01) |
| 246 | -// .frame(width: 300, height: 300) | 210 | + } |
| 247 | - | ||
| 248 | - | ||
| 249 | -// Image(uiImage: barcodeImage) | ||
| 250 | -// .renderingMode(.original) | ||
| 251 | -// .resizable() | ||
| 252 | -// .aspectRatio(contentMode: .fit) | ||
| 253 | -// .frame(width: 300, height: 300) | ||
| 254 | -// .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.05) | ||
| 255 | -// } | ||
| 256 | 211 | ||
| 257 | -// generateBarcode(from: "1234567891234") | ||
| 258 | -// ? | ||
| 259 | -// .resizable() | ||
| 260 | -// .aspectRatio(contentMode: .fit) | ||
| 261 | -// .frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1) | ||
| 262 | 212 | ||
| 263 | - Text(constructBarcode() ?? "") | 213 | + Text(barcodeString) |
| 264 | .fontWeight(.regular) | 214 | .fontWeight(.regular) |
| 265 | .font(.system(size: 22)) | 215 | .font(.system(size: 22)) |
| 266 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 216 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | ... | ... |
-
Please register or login to post a comment