Рамка вокруг сканнера iOS
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#include "AppDelegate.h"
|
||||
#include "GeneratedPluginRegistrant.h"
|
||||
#import "Autobonus-Swift.h"
|
||||
@import Firebase;
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
[FIRApp configure];
|
||||
|
||||
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||
|
||||
@@ -123,6 +125,8 @@
|
||||
result(buildSettings[@"showBonus"]);
|
||||
} else if ([@"getVersionName" isEqualToString:call.method]) {
|
||||
result([[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"]);
|
||||
} else if ([@"logError" isEqualToString:call.method]) {
|
||||
NSLog(@"%@", call.arguments[@"message"]);
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
|
||||
@@ -61,22 +61,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ import Flutter
|
||||
|
||||
settingButton.setImage(self.buttonState.icon, for: .normal)
|
||||
textField.placeholder = self.getInputHint()
|
||||
// textField.text = "79087654321"
|
||||
// textField.text = "79087654321"
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -115,12 +115,108 @@ import Flutter
|
||||
applyOrientation()
|
||||
}
|
||||
|
||||
// TODO: Вынести эту копипасту в методы, когда будет время
|
||||
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)
|
||||
|
||||
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 hideKeyboard() {
|
||||
@@ -134,7 +230,7 @@ import Flutter
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
print("User from manual input: \(textField.text)")
|
||||
print("User from manual input: \(textField.text!)")
|
||||
sendResult(textField.text!)
|
||||
return true
|
||||
}
|
||||
@@ -306,3 +402,4 @@ import Flutter
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user