mirror of
https://github.com/flutter/samples.git
synced 2026-04-05 19:22:08 +00:00
Maintenance updates for platform_view_swift (#151)
This commit is contained in:
@@ -6,32 +6,32 @@ import UIKit
|
||||
import Foundation
|
||||
|
||||
protocol PlatformViewControllerDelegate {
|
||||
func didUpdateCounter(counter: Int)
|
||||
func didUpdateCounter(counter: Int)
|
||||
}
|
||||
|
||||
class PlatformViewController : UIViewController {
|
||||
var delegate: PlatformViewControllerDelegate? = nil
|
||||
var counter: Int = 0
|
||||
|
||||
@IBOutlet weak var incrementLabel: UILabel!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setIncrementLabelText()
|
||||
}
|
||||
|
||||
func handleIncrement(_ sender: Any) {
|
||||
self.counter += 1
|
||||
self.setIncrementLabelText()
|
||||
}
|
||||
|
||||
func switchToFlutterView(_ sender: Any) {
|
||||
self.delegate?.didUpdateCounter(counter: self.counter)
|
||||
dismiss(animated:false, completion:nil)
|
||||
}
|
||||
|
||||
func setIncrementLabelText() {
|
||||
let text = String(format: "Button tapped %d %@", self.counter, (self.counter == 1) ? "time" : "times")
|
||||
self.incrementLabel.text = text;
|
||||
}
|
||||
var delegate: PlatformViewControllerDelegate? = nil
|
||||
var counter: Int = 0
|
||||
|
||||
@IBOutlet weak var incrementLabel: UILabel!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setIncrementLabelText()
|
||||
}
|
||||
|
||||
@IBAction func handleIncrement(_ sender: Any) {
|
||||
self.counter += 1
|
||||
self.setIncrementLabelText()
|
||||
}
|
||||
|
||||
@IBAction func switchToFlutterView(_ sender: Any) {
|
||||
self.delegate?.didUpdateCounter(counter: self.counter)
|
||||
dismiss(animated:false, completion:nil)
|
||||
}
|
||||
|
||||
func setIncrementLabelText() {
|
||||
let text = String(format: "Button tapped %d %@", self.counter, (self.counter == 1) ? "time" : "times")
|
||||
self.incrementLabel.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user