-
Notifications
You must be signed in to change notification settings - Fork 6
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
10 changed files
with
260 additions
and
20 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
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
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
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,16 @@ | ||
// | ||
// Created by Frank Jia on 2019-05-29. | ||
// Copyright (c) 2019 Frank Jia. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class HomeViewModel { | ||
|
||
let test: [String] | ||
|
||
init(test: [String]) { | ||
self.test = test | ||
} | ||
|
||
} |
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,68 @@ | ||
// | ||
// Created by Frank Jia on 2019-05-28. | ||
// Copyright (c) 2019 Frank Jia. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import WeScan | ||
|
||
class NewScanController: UIViewController { | ||
|
||
private let store: AppStore | ||
private var newScanView: NewScanView! | ||
|
||
public init(store: AppStore = appStore) { | ||
self.store = store | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func loadView() { | ||
self.title = Text.NewScanTitle | ||
newScanView = NewScanView(newPageTapped: newPageTapped) | ||
self.view = newScanView | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
// Do any additional setup after loading the view. | ||
} | ||
|
||
private func newPageTapped() { | ||
// Create and launch a WeScan controller | ||
let scannerVC = ImageScannerController() | ||
scannerVC.navigationBar.backgroundColor = .white | ||
scannerVC.imageScannerDelegate = self | ||
present(scannerVC, animated: true) | ||
} | ||
|
||
} | ||
|
||
// Extension for WeScan | ||
extension NewScanController: ImageScannerControllerDelegate { | ||
|
||
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 | ||
newScanView.tempImageView.image = results.scannedImage | ||
if (results.doesUserPreferEnhancedImage), let enhancedImage = results.enhancedImage { | ||
newScanView.tempImageView.image = enhancedImage | ||
} | ||
scanner.dismiss(animated: true) | ||
} | ||
|
||
func imageScannerControllerDidCancel(_ scanner: ImageScannerController) { | ||
// The user tapped 'Cancel' on the scanner | ||
// You are responsible for dismissing the ImageScannerController | ||
scanner.dismiss(animated: true) | ||
} | ||
|
||
} |
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,48 @@ | ||
// | ||
// Created by Frank Jia on 2019-05-28. | ||
// Copyright (c) 2019 Frank Jia. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SnapKit | ||
import WeScan | ||
|
||
class NewScanView: UIView { | ||
|
||
private let newPageTapped: VoidCallback | ||
|
||
// Temp | ||
let tempImageView: UIImageView! | ||
|
||
init(newPageTapped: @escaping VoidCallback) { | ||
self.newPageTapped = newPageTapped | ||
self.tempImageView = UIImageView() | ||
super.init(frame: CGRect.zero) | ||
|
||
backgroundColor = Color.BodyBackground | ||
|
||
let tempButton = TextButton(text: "Add Page", onTap: newPageTapped) | ||
addSubview(tempButton) | ||
|
||
tempButton.snp.makeConstraints { (make) in | ||
make.top.equalTo(safeAreaLayoutGuide.snp.top) | ||
make.left.equalToSuperview() | ||
make.right.equalToSuperview() | ||
} | ||
|
||
addSubview(tempImageView) | ||
tempImageView.contentMode = .scaleAspectFit | ||
tempImageView.snp.makeConstraints { (make) in | ||
make.top.equalTo(tempButton.snp.bottom) | ||
make.bottom.equalToSuperview() | ||
make.left.equalToSuperview() | ||
make.right.equalToSuperview() | ||
} | ||
|
||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
} |