diff --git a/IDNYT.xcodeproj/project.pbxproj b/IDNYT.xcodeproj/project.pbxproj index 0ef55b8..d75e070 100644 --- a/IDNYT.xcodeproj/project.pbxproj +++ b/IDNYT.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ A3920BD9272E3C3300B51F9C /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = A3920BD8272E3C3300B51F9C /* GoogleService-Info.plist */; }; A3B71DDE2730A839008FB7F9 /* AccountInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B71DDD2730A839008FB7F9 /* AccountInfoController.swift */; }; A3CAE70527302A6400E42930 /* StoredInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3CAE70427302A6400E42930 /* StoredInformation.swift */; }; + A3EA33A327321BF0007FA93C /* DigitalCardController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3EA33A227321BF0007FA93C /* DigitalCardController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -35,6 +36,7 @@ A3920BD8272E3C3300B51F9C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; A3B71DDD2730A839008FB7F9 /* AccountInfoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInfoController.swift; sourceTree = ""; }; A3CAE70427302A6400E42930 /* StoredInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoredInformation.swift; sourceTree = ""; }; + A3EA33A227321BF0007FA93C /* DigitalCardController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitalCardController.swift; sourceTree = ""; }; DCF1E9F4523A71ED433E5F27 /* Pods_IDNYT.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IDNYT.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -98,6 +100,7 @@ isa = PBXGroup; children = ( A3B71DDD2730A839008FB7F9 /* AccountInfoController.swift */, + A3EA33A227321BF0007FA93C /* DigitalCardController.swift */, ); path = MainViewControllers; sourceTree = ""; @@ -233,6 +236,7 @@ A3920BC7272E3BEF00B51F9C /* SceneDelegate.swift in Sources */, A3CAE70527302A6400E42930 /* StoredInformation.swift in Sources */, A3B71DDE2730A839008FB7F9 /* AccountInfoController.swift in Sources */, + A3EA33A327321BF0007FA93C /* DigitalCardController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -309,7 +313,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -364,7 +368,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -385,6 +389,7 @@ DEVELOPMENT_TEAM = TNHS6765PZ; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = IDNYT/Info.plist; + INFOPLIST_KEY_NSCameraUsageDescription = "Please allow IDNYT to access your camera to scan your documents."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = LaunchScreen; @@ -416,6 +421,7 @@ DEVELOPMENT_TEAM = TNHS6765PZ; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = IDNYT/Info.plist; + INFOPLIST_KEY_NSCameraUsageDescription = "Please allow IDNYT to access your camera to scan your documents."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = LaunchScreen; diff --git a/IDNYT.xcodeproj/xcuserdata/prince.xcuserdatad/xcschemes/xcschememanagement.plist b/IDNYT.xcodeproj/xcuserdata/prince.xcuserdatad/xcschemes/xcschememanagement.plist index bea27e7..4baf8b6 100644 --- a/IDNYT.xcodeproj/xcuserdata/prince.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/IDNYT.xcodeproj/xcuserdata/prince.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ IDNYT.xcscheme_^#shared#^_ orderHint - 20 + 22 diff --git a/IDNYT/Assets.xcassets/AddImage.imageset/Contents.json b/IDNYT/Assets.xcassets/AddImage.imageset/Contents.json new file mode 100644 index 0000000..e6ea5b6 --- /dev/null +++ b/IDNYT/Assets.xcassets/AddImage.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "add_image.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/IDNYT/Assets.xcassets/AddImage.imageset/add_image.png b/IDNYT/Assets.xcassets/AddImage.imageset/add_image.png new file mode 100644 index 0000000..f5db7e8 Binary files /dev/null and b/IDNYT/Assets.xcassets/AddImage.imageset/add_image.png differ diff --git a/IDNYT/Base.lproj/Main.storyboard b/IDNYT/Base.lproj/Main.storyboard index e615dbd..183e8ab 100644 --- a/IDNYT/Base.lproj/Main.storyboard +++ b/IDNYT/Base.lproj/Main.storyboard @@ -7,6 +7,7 @@ + @@ -178,18 +179,88 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -383,6 +454,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -397,11 +585,15 @@ + + + + diff --git a/IDNYT/LoginViewController.swift b/IDNYT/LoginViewController.swift index 3b932bb..26872df 100644 --- a/IDNYT/LoginViewController.swift +++ b/IDNYT/LoginViewController.swift @@ -15,6 +15,19 @@ class LoginViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + + //sets 4 images to UserData for scanning cards later + // guard let data = UIImage(named: "AddImage")?.jpegData(compressionQuality: 0) else {return} + // let encoded = try! PropertyListEncoder().encode(data) + + let defaultImage = UIImage(named: "AddImage") + + let imageData = defaultImage?.jpegData(compressionQuality: 1.0) + UserDefaults.standard.set(imageData, forKey: "nyitFront") + UserDefaults.standard.set(imageData, forKey: "nyitBack") + UserDefaults.standard.set(imageData, forKey: "vaxFront") + UserDefaults.standard.set(imageData, forKey: "vaxBack") + } @IBAction func signInClick(_ sender: Any) { diff --git a/IDNYT/MainViewControllers/DigitalCardController.swift b/IDNYT/MainViewControllers/DigitalCardController.swift new file mode 100644 index 0000000..fbd7af4 --- /dev/null +++ b/IDNYT/MainViewControllers/DigitalCardController.swift @@ -0,0 +1,161 @@ +// +// DigitalCardController.swift +// IDNYT +// +// Created by Prince on 11/2/21. +// + + +// make names + keys for the default images, then if the keys dont have text ("") that means it has a picture of the card +import UIKit +import ImageSlideshow +import WeScan + +class DigitalCardController: UIViewController, ImageScannerControllerDelegate { + + @IBOutlet weak var titleLabel: UILabel! + @IBOutlet weak var nyitCardLabel: UILabel! + @IBOutlet weak var vaxCardLabel: UILabel! + @IBOutlet weak var nyitSlideShow: ImageSlideshow! + @IBOutlet weak var vaxSlideShow: ImageSlideshow! + + var nyitPosition = 0 + var vaxPosition = 0 + + override func viewDidLoad() { + super.viewDidLoad() + loadImages() + nyitSlideShow.zoomEnabled = true + nyitSlideShow.circular = false + nyitSlideShow.pageIndicator = nil + nyitSlideShow.zoomEnabled = false + nyitSlideShow.activityIndicator = DefaultActivityIndicator(style: .white, color: .yellow) + + vaxSlideShow.zoomEnabled = true + vaxSlideShow.circular = false + vaxSlideShow.pageIndicator = nil + vaxSlideShow.zoomEnabled = false + vaxSlideShow.activityIndicator = DefaultActivityIndicator(style: .white, color: .yellow) + + let gestureRec = UITapGestureRecognizer(target: self, action: #selector(DigitalCardController.didTapNYT)) + nyitSlideShow.addGestureRecognizer(gestureRec) + + let gestureRec2 = UITapGestureRecognizer(target: self, action: #selector(DigitalCardController.didTapVAX)) + vaxSlideShow.addGestureRecognizer(gestureRec2) + } + + + //****figure out a way for people to hold the image and show the full view + @objc func didTapNYT(){ + //nyitSlideShow.presentFullScreenController(from: self) + + nyitPosition = nyitSlideShow.currentPage + print(nyitPosition) + + let scannerViewController = ImageScannerController() + scannerViewController.imageScannerDelegate = self + present(scannerViewController, animated: true) + } + + @objc func didTapVAX(){ + //nyitSlideShow.presentFullScreenController(from: self) + + vaxPosition = vaxSlideShow.currentPage + print(vaxPosition) + + let scannerViewController = ImageScannerController() + scannerViewController.imageScannerDelegate = self + present(scannerViewController, animated: true) + } + + + func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) { + // You are responsible for carefully handling the error + print(error) + } + + func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) { + // The user successfully scanned an image, which is available in the ImageScannerResults + // You are responsible for dismissing the ImageScannerController + + //saves image to app locally + if(nyitPosition == 0){ + print("replacing nyitFront") + //sets first image + + let imageData = results.croppedScan.image.jpegData(compressionQuality: 1.0) + UserDefaults.standard.set(imageData, forKey: "nyitFront") + print("dismissing scanner") + scanner.dismiss(animated: true) + print("reloading images") + + }else if(nyitPosition == 1){ + print("replacing nyitBack") + //sets first image + let imageData = results.croppedScan.image.jpegData(compressionQuality: 1.0) + UserDefaults.standard.set(imageData, forKey: "nyitBack") + print("dismissing scanner") + scanner.dismiss(animated: true) + print("reloading images") + + }else if(vaxPosition == 0){ + print("replacing vaxFront") + //sets first image + let imageData = results.croppedScan.image.jpegData(compressionQuality: 1.0) + UserDefaults.standard.set(imageData, forKey: "vaxFront") + print("dismissing scanner") + scanner.dismiss(animated: true) + print("reloading images") + + }else if(vaxPosition == 1){ + print("replacing vaxBack") + //sets first image + let imageData = results.croppedScan.image.jpegData(compressionQuality: 1.0) + UserDefaults.standard.set(imageData, forKey: "vaxBack") + print("dismissing scanner") + scanner.dismiss(animated: true) + print("reloading images") + + }else{print("replaced nothing")} + + nyitPosition = -1 + vaxPosition = -1 + loadImages() + return + } + + func imageScannerControllerDidCancel(_ scanner: ImageScannerController) { + // The user tapped 'Cancel' on the scanner + // You are responsible for dismissing the ImageScannerController + scanner.dismiss(animated: true) + } + + func loadImages(){ + + print("getting image data") + guard let data = UserDefaults.standard.data(forKey: "nyitFront") else {return} + let nyitFrontImage = UIImage(data:data) + + guard let data2 = UserDefaults.standard.data(forKey: "nyitBack") else {return} + let nyitBackImage = UIImage(data:data2) + + guard let data3 = UserDefaults.standard.data(forKey: "vaxFront") else {return} + let vaxFrontImage = UIImage(data:data3) + + guard let data4 = UserDefaults.standard.data(forKey: "vaxBack") else {return} + let vaxBackImage = UIImage(data:data4) + + + print("loading images") + nyitSlideShow.setImageInputs([ + ImageSource(image: nyitFrontImage!), + ImageSource(image: nyitBackImage!) + ]) + + vaxSlideShow.setImageInputs([ + ImageSource(image: vaxFrontImage!), + ImageSource(image: vaxBackImage!) + ]) + } + +} diff --git a/Podfile b/Podfile index cb87f7e..d84dc7b 100644 --- a/Podfile +++ b/Podfile @@ -9,5 +9,7 @@ pod 'Firebase/Core' pod 'Firebase/Database' pod 'Firebase/Storage' pod 'GoogleSignIn' +pod 'WeScan' +pod 'ImageSlideshow' end