Skip to content

Commit

Permalink
Merge pull request #7 from TCVinNYC/main
Browse files Browse the repository at this point in the history
ID Tab Features + Layout
  • Loading branch information
TCVinNYC authored Nov 3, 2021
2 parents 43c2387 + 9b3e4a4 commit 784c96a
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 5 deletions.
10 changes: 8 additions & 2 deletions IDNYT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -35,6 +36,7 @@
A3920BD8272E3C3300B51F9C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
A3B71DDD2730A839008FB7F9 /* AccountInfoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInfoController.swift; sourceTree = "<group>"; };
A3CAE70427302A6400E42930 /* StoredInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoredInformation.swift; sourceTree = "<group>"; };
A3EA33A227321BF0007FA93C /* DigitalCardController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitalCardController.swift; sourceTree = "<group>"; };
DCF1E9F4523A71ED433E5F27 /* Pods_IDNYT.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IDNYT.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -98,6 +100,7 @@
isa = PBXGroup;
children = (
A3B71DDD2730A839008FB7F9 /* AccountInfoController.swift */,
A3EA33A227321BF0007FA93C /* DigitalCardController.swift */,
);
path = MainViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>IDNYT.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>20</integer>
<integer>22</integer>
</dict>
</dict>
</dict>
Expand Down
21 changes: 21 additions & 0 deletions IDNYT/Assets.xcassets/AddImage.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 194 additions & 2 deletions IDNYT/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions IDNYT/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
161 changes: 161 additions & 0 deletions IDNYT/MainViewControllers/DigitalCardController.swift
Original file line number Diff line number Diff line change
@@ -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!)
])
}

}
2 changes: 2 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Storage'
pod 'GoogleSignIn'
pod 'WeScan'
pod 'ImageSlideshow'

end

0 comments on commit 784c96a

Please sign in to comment.