snapshot of https://github.com/flutter/samples.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
This commit is contained in:
37
platform_view_swift/ios/Runner/PlatformViewController.swift
Normal file
37
platform_view_swift/ios/Runner/PlatformViewController.swift
Normal 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()
|
||||
}
|
||||
|
||||
@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