Menu for ios
This commit is contained in:
10
ios/Podfile
10
ios/Podfile
@@ -1,6 +1,5 @@
|
|||||||
# Uncomment this line to define a global platform for your project
|
# Uncomment this line to define a global platform for your project
|
||||||
# platform :ios, '9.0'
|
# platform :ios, '9.0'
|
||||||
pod 'ZXingObjC', '~> 3.2.2'
|
|
||||||
|
|
||||||
if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
|
if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
|
||||||
abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
|
abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
|
||||||
@@ -9,6 +8,9 @@ end
|
|||||||
target ‘Runner’ do
|
target ‘Runner’ do
|
||||||
# Pods for Runner
|
# Pods for Runner
|
||||||
pod 'Firebase'
|
pod 'Firebase'
|
||||||
|
pod 'DropDown'
|
||||||
|
pod 'ZXingObjC'
|
||||||
|
use_frameworks!
|
||||||
|
|
||||||
# Flutter Pods
|
# Flutter Pods
|
||||||
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
||||||
@@ -31,6 +33,9 @@ end
|
|||||||
target ‘Dinect’ do
|
target ‘Dinect’ do
|
||||||
# Pods for Dinect
|
# Pods for Dinect
|
||||||
pod 'Firebase'
|
pod 'Firebase'
|
||||||
|
pod 'DropDown'
|
||||||
|
pod 'ZXingObjC'
|
||||||
|
use_frameworks!
|
||||||
|
|
||||||
# Flutter Pods
|
# Flutter Pods
|
||||||
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
||||||
@@ -53,6 +58,9 @@ end
|
|||||||
target ‘Crypto’ do
|
target ‘Crypto’ do
|
||||||
# Pods for Crypto
|
# Pods for Crypto
|
||||||
pod 'Firebase'
|
pod 'Firebase'
|
||||||
|
pod 'DropDown'
|
||||||
|
pod 'ZXingObjC'
|
||||||
|
use_frameworks!
|
||||||
|
|
||||||
# Flutter Pods
|
# Flutter Pods
|
||||||
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<key>BioChecker.xcscheme</key>
|
<key>BioChecker.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>14</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Dinect INT.xcscheme_^#shared#^_</key>
|
<key>Dinect INT.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<key>Dinect-Crypto.xcscheme_^#shared#^_</key>
|
<key>Dinect-Crypto.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>5</integer>
|
<integer>3</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Dinect.xcscheme</key>
|
<key>Dinect.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<key>Dinect.xcscheme_^#shared#^_</key>
|
<key>Dinect.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>13</integer>
|
<integer>12</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Runner.xcscheme_^#shared#^_</key>
|
<key>Runner.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
|||||||
Binary file not shown.
23
ios/Runner/Assets.xcassets/more.imageset/Contents.json
vendored
Normal file
23
ios/Runner/Assets.xcassets/more.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "more.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "more@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "more@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
ios/Runner/Assets.xcassets/more.imageset/more.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/more.imageset/more.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 617 B |
BIN
ios/Runner/Assets.xcassets/more.imageset/more@2x.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/more.imageset/more@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
ios/Runner/Assets.xcassets/more.imageset/more@3x.png
vendored
Normal file
BIN
ios/Runner/Assets.xcassets/more.imageset/more@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,5 +1,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Flutter
|
import Flutter
|
||||||
|
import DropDown
|
||||||
|
import ZXingObjC
|
||||||
|
|
||||||
@objc class ScannerViewController: UIViewController, ZXCaptureDelegate, UITextFieldDelegate {
|
@objc class ScannerViewController: UIViewController, ZXCaptureDelegate, UITextFieldDelegate {
|
||||||
|
|
||||||
@@ -28,28 +30,18 @@ import Flutter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @IBOutlet weak var decodedLabel: UILabel!
|
var captureSizeTransform: CGAffineTransform?
|
||||||
|
|
||||||
private var captureSizeTransform: CGAffineTransform?
|
|
||||||
|
|
||||||
var buttonState: ButtonState = .card
|
var buttonState: ButtonState = .card
|
||||||
|
|
||||||
var platformChannel: FlutterMethodChannel?
|
var platformChannel: FlutterMethodChannel?
|
||||||
|
|
||||||
// Квадрат для наведения на цель (надеюсь)
|
|
||||||
let scanRectView = UIView()
|
|
||||||
|
|
||||||
//Вьюшка для верхнего меню
|
|
||||||
let topView = UIView()
|
|
||||||
|
|
||||||
//Окно ввода кода
|
|
||||||
let textField = UITextField()
|
|
||||||
|
|
||||||
//Кнопка настроек
|
|
||||||
var settingButton: UIButton!
|
|
||||||
|
|
||||||
var strings = [String:String]()
|
var strings = [String:String]()
|
||||||
|
|
||||||
|
let scanRectView = UIView()
|
||||||
|
let header = UIView()
|
||||||
|
let textField = UITextField()
|
||||||
|
let settingsButton = UIButton(type: .system)
|
||||||
|
let searchType = UIButton(type: .system)
|
||||||
|
let dropDown = DropDown()
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
}
|
}
|
||||||
@@ -84,32 +76,78 @@ import Flutter
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
capture.camera = capture.back()
|
|
||||||
capture.focusMode = .continuousAutoFocus
|
|
||||||
view.layer.addSublayer((capture.layer)!)
|
view.layer.addSublayer((capture.layer)!)
|
||||||
view.addSubview(scanRectView)
|
view.addSubview(scanRectView)
|
||||||
|
view.addSubview(header)
|
||||||
|
view.bringSubview(toFront: header)
|
||||||
|
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ScannerViewController.hideKeyboard)))
|
||||||
|
|
||||||
settingButton = UIButton(type: .system)
|
initCamera()
|
||||||
settingButton.addTarget(self, action: #selector(ScannerViewController.buttonTouch), for: .touchUpInside)
|
initSearchTypeButton()
|
||||||
|
initTextFIeld()
|
||||||
|
initSettingsButton()
|
||||||
|
initDropDown()
|
||||||
|
initHeader()
|
||||||
|
}
|
||||||
|
|
||||||
topView.addSubview(textField)
|
private func initCamera() {
|
||||||
topView.addSubview(settingButton)
|
capture.camera = capture.back()
|
||||||
view.addSubview(topView)
|
capture.focusMode = .continuousAutoFocus
|
||||||
view.bringSubview(toFront: topView)
|
}
|
||||||
|
|
||||||
|
private func initHeader() {
|
||||||
|
header.addSubview(textField)
|
||||||
|
header.addSubview(searchType)
|
||||||
|
header.addSubview(settingsButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func initTextFIeld() {
|
||||||
textField.delegate = self
|
textField.delegate = self
|
||||||
|
|
||||||
let tap = UITapGestureRecognizer(target: self, action: #selector(ScannerViewController.hideKeyboard))
|
|
||||||
view.addGestureRecognizer(tap)
|
|
||||||
|
|
||||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
|
||||||
textField.placeholder = self.getInputHint()
|
textField.placeholder = self.getInputHint()
|
||||||
// textField.text = "79087654321"
|
}
|
||||||
|
|
||||||
|
private func initSearchTypeButton() {
|
||||||
|
searchType.setImage(self.buttonState.icon, for: .normal)
|
||||||
|
searchType.addTarget(self, action: #selector(ScannerViewController.buttonTouch), for: .touchUpInside)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func initDropDown() {
|
||||||
|
dropDown.anchorView = settingsButton
|
||||||
|
dropDown.dataSource = [strings["settings"]!, strings["faq"]!]
|
||||||
|
dropDown.selectionAction = { (index: Int, item: String) in
|
||||||
|
if index == 0 {
|
||||||
|
self.platformChannel?.invokeMethod("settings", arguments: nil)
|
||||||
|
} else if index == 1 {
|
||||||
|
self.platformChannel?.invokeMethod("faq", arguments: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.dismiss(animated: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func initSettingsButton() {
|
||||||
|
settingsButton.setImage(UIImage(named: "more")!, for: .normal)
|
||||||
|
settingsButton.addTarget(self, action: #selector(ScannerViewController.settingsTouch), for: .touchUpInside)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hideKeyboard() {
|
||||||
|
view.endEditing(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buttonTouch() {
|
||||||
|
setButtonState()
|
||||||
|
searchType.setImage(self.buttonState.icon, for: .normal)
|
||||||
|
textField.placeholder = self.getInputHint()
|
||||||
|
}
|
||||||
|
|
||||||
|
func settingsTouch() {
|
||||||
|
dropDown.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
topView.backgroundColor = UIColor.white
|
header.backgroundColor = UIColor.white
|
||||||
textField.borderStyle = .roundedRect
|
textField.borderStyle = .roundedRect
|
||||||
capture.delegate = self
|
capture.delegate = self
|
||||||
applyOrientation()
|
applyOrientation()
|
||||||
@@ -118,11 +156,12 @@ import Flutter
|
|||||||
// TODO: Вынести эту копипасту в методы, когда будет время
|
// TODO: Вынести эту копипасту в методы, когда будет время
|
||||||
override func viewWillLayoutSubviews() {
|
override func viewWillLayoutSubviews() {
|
||||||
|
|
||||||
|
// TODO: Надо бы уйти от констант, переписать на отступы какие-нибудь
|
||||||
scanRectView.frame = view.bounds
|
scanRectView.frame = view.bounds
|
||||||
topView.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: 56)
|
header.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: 56)
|
||||||
settingButton.frame = CGRect(x: 8, y: 26, width: 20, height: 20)
|
searchType.frame = CGRect(x: 8, y: 26, width: 20, height: 20)
|
||||||
textField.frame = CGRect(x: settingButton.frame.maxX + 8, y: 21,
|
textField.frame = CGRect(x: searchType.frame.maxX + 8, y: 21, width: view.frame.size.width - searchType.frame.maxX - 48, height: 30)
|
||||||
width: view.frame.size.width - settingButton.frame.maxX - 16, height: 30)
|
settingsButton.frame = CGRect(x: view.frame.size.width - 30, y: 26, width: 20, height: 20)
|
||||||
|
|
||||||
var path = UIBezierPath()
|
var path = UIBezierPath()
|
||||||
path.move(to: CGPoint(x: 32, y: view.frame.size.height / 2))
|
path.move(to: CGPoint(x: 32, y: view.frame.size.height / 2))
|
||||||
@@ -219,16 +258,6 @@ import Flutter
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hideKeyboard() {
|
|
||||||
view.endEditing(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func buttonTouch(){
|
|
||||||
setButtonState()
|
|
||||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
|
||||||
textField.placeholder = self.getInputHint()
|
|
||||||
}
|
|
||||||
|
|
||||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||||
print("User from manual input: \(textField.text!)")
|
print("User from manual input: \(textField.text!)")
|
||||||
sendResult(textField.text!)
|
sendResult(textField.text!)
|
||||||
|
|||||||
Reference in New Issue
Block a user