1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Add platform_view_swift based on platform_view example (#10)

This commit is contained in:
Mike Laughton
2018-08-10 16:39:22 -05:00
committed by Andrew Brogdon
parent 370a72caa5
commit c02d0208fa
34 changed files with 1230 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2018, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import UIKit
import Foundation
protocol PlatformViewControllerDelegate {
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;
}
}