Menu in iOS

This commit is contained in:
Ivan Murashov
2018-05-20 13:44:15 +03:00
parent 23a3bf1a9c
commit d9400a3df9
34 changed files with 317 additions and 1218 deletions

Binary file not shown.

View File

@@ -48,7 +48,7 @@ FLUTTER_EXPORT
On the Dart side, messages are represented using `ByteData`.
*/
FLUTTER_EXPORT
@interface FlutterBinaryCodec : NSObject<FlutterMessageCodec>
@interface FlutterBinaryCodec : NSObject <FlutterMessageCodec>
@end
/**
@@ -59,7 +59,7 @@ FLUTTER_EXPORT
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
*/
FLUTTER_EXPORT
@interface FlutterStringCodec : NSObject<FlutterMessageCodec>
@interface FlutterStringCodec : NSObject <FlutterMessageCodec>
@end
/**
@@ -77,7 +77,57 @@ FLUTTER_EXPORT
package.
*/
FLUTTER_EXPORT
@interface FlutterJSONMessageCodec : NSObject<FlutterMessageCodec>
@interface FlutterJSONMessageCodec : NSObject <FlutterMessageCodec>
@end
/**
A writer of the Flutter standard binary encoding.
See `FlutterStandardMessageCodec` for details on the encoding.
The encoding is extensible via subclasses overriding `writeValue`.
*/
FLUTTER_EXPORT
@interface FlutterStandardWriter : NSObject
- (instancetype)initWithData:(NSMutableData*)data;
- (void)writeByte:(UInt8)value;
- (void)writeBytes:(const void*)bytes length:(NSUInteger)length;
- (void)writeData:(NSData*)data;
- (void)writeSize:(UInt32)size;
- (void)writeAlignment:(UInt8)alignment;
- (void)writeUTF8:(NSString*)value;
- (void)writeValue:(id)value;
@end
/**
A reader of the Flutter standard binary encoding.
See `FlutterStandardMessageCodec` for details on the encoding.
The encoding is extensible via subclasses overriding `readValueOfType`.
*/
FLUTTER_EXPORT
@interface FlutterStandardReader : NSObject
- (instancetype)initWithData:(NSData*)data;
- (BOOL)hasMore;
- (UInt8)readByte;
- (void)readBytes:(void*)destination length:(NSUInteger)length;
- (NSData*)readData:(NSUInteger)length;
- (UInt32)readSize;
- (void)readAlignment:(UInt8)alignment;
- (NSString*)readUTF8;
- (id)readValue;
- (id)readValueOfType:(UInt8)type;
@end
/**
A factory of compatible reader/writer instances using the Flutter standard
binary encoding or extensions thereof.
*/
FLUTTER_EXPORT
@interface FlutterStandardReaderWriter : NSObject
- (FlutterStandardWriter*)writerWithData:(NSMutableData*)data;
- (FlutterStandardReader*)readerWithData:(NSData*)data;
@end
/**
@@ -113,7 +163,8 @@ FLUTTER_EXPORT
instead.
*/
FLUTTER_EXPORT
@interface FlutterStandardMessageCodec : NSObject<FlutterMessageCodec>
@interface FlutterStandardMessageCodec : NSObject <FlutterMessageCodec>
+ (instancetype)codecWithReaderWriter:(FlutterStandardReaderWriter*)readerWriter;
@end
/**
@@ -359,7 +410,7 @@ FLUTTER_EXPORT
those supported as top-level or leaf values by `FlutterJSONMessageCodec`.
*/
FLUTTER_EXPORT
@interface FlutterJSONMethodCodec : NSObject<FlutterMethodCodec>
@interface FlutterJSONMethodCodec : NSObject <FlutterMethodCodec>
@end
/**
@@ -373,7 +424,8 @@ FLUTTER_EXPORT
`FlutterStandardMessageCodec`.
*/
FLUTTER_EXPORT
@interface FlutterStandardMethodCodec : NSObject<FlutterMethodCodec>
@interface FlutterStandardMethodCodec : NSObject <FlutterMethodCodec>
+ (instancetype)codecWithReaderWriter:(FlutterStandardReaderWriter*)readerWriter;
@end
NS_ASSUME_NONNULL_END

View File

@@ -23,6 +23,26 @@ FLUTTER_EXPORT
- (instancetype)initFromDefaultSourceForConfiguration;
/**
Returns the file name for the given asset.
The returned file name can be used to access the asset in the application's main bundle.
- Parameter asset: The name of the asset. The name can be hierarchical.
- Returns: the file name to be used for lookup in the main bundle.
*/
+ (NSString*)lookupKeyForAsset:(NSString*)asset;
/**
Returns the file name for the given asset which originates from the specified package.
The returned file name can be used to access the asset in the application's main bundle.
- Parameters:
- asset: The name of the asset. The name can be hierarchical.
- package: The name of the package from which the asset originates.
- Returns: the file name to be used for lookup in the main bundle.
*/
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
@end
#endif // FLUTTER_FLUTTERDARTPROJECT_H_

View File

@@ -183,6 +183,26 @@ NS_ASSUME_NONNULL_BEGIN
- Parameters delegate: The receiving object, such as the plugin's main class.
*/
- (void)addApplicationDelegate:(NSObject<FlutterPlugin>*)delegate;
/**
Returns the file name for the given asset.
The returned file name can be used to access the asset in the application's main bundle.
- Parameter asset: The name of the asset. The name can be hierarchical.
- Returns: the file name to be used for lookup in the main bundle.
*/
- (NSString*)lookupKeyForAsset:(NSString*)asset;
/**
Returns the file name for the given asset which originates from the specified package.
The returned file name can be used to access the asset in the application's main bundle.
- Parameters:
- asset: The name of the asset. The name can be hierarchical.
- package: The name of the package from which the asset originates.
- Returns: the file name to be used for lookup in the main bundle.
*/
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
@end
/**

View File

@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
FLUTTER_EXPORT
@protocol FlutterTexture<NSObject>
- (CVPixelBufferRef)copyPixelBuffer;
- (CVPixelBufferRef _Nullable)copyPixelBuffer;
@end
FLUTTER_EXPORT

View File

@@ -22,6 +22,26 @@ FLUTTER_EXPORT
- (void)handleStatusBarTouches:(UIEvent*)event;
/**
Returns the file name for the given asset.
The returned file name can be used to access the asset in the application's main bundle.
- Parameter asset: The name of the asset. The name can be hierarchical.
- Returns: the file name to be used for lookup in the main bundle.
*/
- (NSString*)lookupKeyForAsset:(NSString*)asset;
/**
Returns the file name for the given asset which originates from the specified package.
The returned file name can be used to access the asset in the application's main bundle.
- Parameters:
- asset: The name of the asset. The name can be hierarchical.
- package: The name of the package from which the asset originates.
- Returns: the file name to be used for lookup in the main bundle.
*/
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
/**
Sets the first route that the Flutter app shows. The default is "/".

View File

@@ -1,8 +1,9 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/dinect/projects/flutter
FLUTTER_APPLICATION_PATH=/Users/dinect/projects/checker
FLUTTER_ROOT=/Users/kifio/flutter
FLUTTER_APPLICATION_PATH=/Users/kifio/Desktop/AndroidStudioProjects/checker
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_MODE=release
FLUTTER_BUILD_MODE=debug
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_FRAMEWORK_DIR=/Users/dinect/projects/flutter/bin/cache/artifacts/engine/ios-release
FLUTTER_FRAMEWORK_DIR=/Users/kifio/flutter/bin/cache/artifacts/engine/ios
PREVIEW_DART_2=true

View File

@@ -1377,7 +1377,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 926V94K5Q8;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -1414,7 +1414,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 926V94K5Q8;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",

View File

@@ -4,6 +4,11 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>BioChecker.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>13</integer>
</dict>
<key>Dinect INT.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
@@ -12,13 +17,18 @@
<key>Dinect-Crypto.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>7</integer>
<integer>2</integer>
</dict>
<key>Dinect.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>11</integer>
</dict>
<key>Dinect.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>Runner.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>

View File

@@ -1,5 +1,7 @@
import UIKit
import Flutter
import DropDown
import ZXingObjC
@objc class ScannerViewController: UIViewController, ZXCaptureDelegate, UITextFieldDelegate {
@@ -28,28 +30,18 @@ import Flutter
}
}
// @IBOutlet weak var decodedLabel: UILabel!
private var captureSizeTransform: CGAffineTransform?
var captureSizeTransform: CGAffineTransform?
var buttonState: ButtonState = .card
var platformChannel: FlutterMethodChannel?
// Квадрат для наведения на цель (надеюсь)
let scanRectView = UIView()
//Вьюшка для верхнего меню
let topView = UIView()
//Окно ввода кода
let textField = UITextField()
//Кнопка настроек
var settingButton: UIButton!
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) {
super.init(coder: aDecoder)
}
@@ -61,22 +53,22 @@ import Flutter
func getInputHint() -> String {
switch self.buttonState {
case .card: return strings["enter_manual"]!
case .phone: return strings["enter_phone"]!
case .card: return strings["enter_manual"]!
case .phone: return strings["enter_phone"]!
}
}
func getErrorText() -> String {
switch self.buttonState {
case .card: return strings["user_card_not_found"]!
case .phone: return strings["user_phone_not_found"]!
case .card: return strings["user_card_not_found"]!
case .phone: return strings["user_phone_not_found"]!
}
}
func setButtonState() {
switch self.buttonState {
case .card: self.buttonState = .phone
case .phone: self.buttonState = .card
case .card: self.buttonState = .phone
case .phone: self.buttonState = .card
}
}
@@ -84,57 +76,190 @@ import Flutter
override func viewDidLoad() {
super.viewDidLoad()
capture.camera = capture.back()
capture.focusMode = .continuousAutoFocus
view.layer.addSublayer((capture.layer)!)
view.addSubview(scanRectView)
view.addSubview(header)
view.bringSubview(toFront: header)
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ScannerViewController.hideKeyboard)))
settingButton = UIButton(type: .system)
settingButton.addTarget(self, action: #selector(ScannerViewController.buttonTouch), for: .touchUpInside)
topView.addSubview(textField)
topView.addSubview(settingButton)
view.addSubview(topView)
view.bringSubview(toFront: topView)
initCamera()
initSearchTypeButton()
initTextFIeld()
initSettingsButton()
initDropDown()
initHeader()
}
private func initCamera() {
capture.camera = capture.back()
capture.focusMode = .continuousAutoFocus
}
private func initHeader() {
header.addSubview(textField)
header.addSubview(searchType)
header.addSubview(settingsButton)
}
private func initTextFIeld() {
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.text = "79087654321"
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
topView.backgroundColor = UIColor.white
textField.borderStyle = .roundedRect
capture.delegate = self
applyOrientation()
private func initSearchTypeButton() {
searchType.setImage(self.buttonState.icon, for: .normal)
searchType.addTarget(self, action: #selector(ScannerViewController.buttonTouch), for: .touchUpInside)
}
override func viewWillLayoutSubviews() {
scanRectView.frame = view.bounds
topView.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: 56)
settingButton.frame = CGRect(x: 8, y: 26, width: 20, height: 20)
textField.frame = CGRect(x: settingButton.frame.maxX + 8, y: 21,
width: view.frame.size.width - settingButton.frame.maxX - 16, height: 30)
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(){
func buttonTouch() {
setButtonState()
settingButton.setImage(self.buttonState.icon, for: .normal)
searchType.setImage(self.buttonState.icon, for: .normal)
textField.placeholder = self.getInputHint()
}
func settingsTouch() {
dropDown.show()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
header.backgroundColor = UIColor.white
textField.borderStyle = .roundedRect
capture.delegate = self
applyOrientation()
}
// TODO: Вынести эту копипасту в методы, когда будет время
override func viewWillLayoutSubviews() {
// TODO: Надо бы уйти от констант, переписать на отступы какие-нибудь
scanRectView.frame = view.bounds
header.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: 56)
searchType.frame = CGRect(x: 8, y: 26, width: 20, height: 20)
textField.frame = CGRect(x: searchType.frame.maxX + 8, y: 21, width: view.frame.size.width - searchType.frame.maxX - 48, height: 30)
settingsButton.frame = CGRect(x: view.frame.size.width - 30, y: 26, width: 20, height: 20)
var path = UIBezierPath()
path.move(to: CGPoint(x: 32, y: view.frame.size.height / 2))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: view.frame.size.height / 2))
var shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.red.cgColor
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.lineWidth = 2
view.layer.addSublayer(shapeLayer)
path = UIBezierPath()
path.move(to: CGPoint(x: 32, y: (view.frame.size.height / 2) - 32))
path.addLine(to: CGPoint(x: 32, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: 64, y: (view.frame.size.height / 2) - 64))
path.move(to: CGPoint(x: view.frame.size.width - 64, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) - 32))
path.move(to: CGPoint(x: 32, y: (view.frame.size.height / 2) + 32))
path.addLine(to: CGPoint(x: 32, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: 64, y: (view.frame.size.height / 2) + 64))
path.move(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) + 32))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: view.frame.size.width - 64, y: (view.frame.size.height / 2) + 64))
shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.green.cgColor
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.lineWidth = 2
view.layer.addSublayer(shapeLayer)
path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 56))
path.addLine(to: CGPoint(x: view.frame.size.width, y: 56))
path.addLine(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: 0, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: 0, y: 56))
path.close()
shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor
view.layer.addSublayer(shapeLayer)
path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: 32, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: 32, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: 0, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: 0, y: (view.frame.size.height / 2) - 64))
path.close()
shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor
view.layer.addSublayer(shapeLayer)
path = UIBezierPath()
path.move(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) - 64))
path.addLine(to: CGPoint(x: view.frame.size.width - 32, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) - 64))
path.close()
shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor
view.layer.addSublayer(shapeLayer)
path = UIBezierPath()
path.move(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: 0, y: (view.frame.size.height / 2) + 64))
path.addLine(to: CGPoint(x: 0, y: view.frame.size.height))
path.addLine(to: CGPoint(x: view.frame.size.width, y: view.frame.size.height))
path.addLine(to: CGPoint(x: view.frame.size.width, y: (view.frame.size.height / 2) + 64))
path.close()
shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor
view.layer.addSublayer(shapeLayer)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
print("User from manual input: \(textField.text)")
print("User from manual input: \(textField.text!)")
sendResult(textField.text!)
return true
}