You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/add_to_app/multiple_flutters/multiple_flutters_ios/MultipleFluttersIos/DoubleFlutterViewController...

30 lines
1.2 KiB

// Copyright 2021 The Flutter team. 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
/// A UIViewController that hosts two instances of SingleFlutterViewController, splitting the screen
/// between them.
class DoubleFlutterViewController: UIViewController {
private let topFlutter: SingleFlutterViewController = SingleFlutterViewController(
withEntrypoint: "topMain")
private let bottomFlutter: SingleFlutterViewController = SingleFlutterViewController(
withEntrypoint: "bottomMain")
override func viewDidLoad() {
addChild(topFlutter)
addChild(bottomFlutter)
let safeFrame = self.view.safeAreaLayoutGuide.layoutFrame
let halfHeight = safeFrame.height / 2.0
topFlutter.view.frame = CGRect(
x: safeFrame.minX, y: safeFrame.minY, width: safeFrame.width, height: halfHeight)
bottomFlutter.view.frame = CGRect(
x: safeFrame.minX, y: topFlutter.view.frame.maxY, width: safeFrame.width, height: halfHeight)
self.view.addSubview(topFlutter.view)
self.view.addSubview(bottomFlutter.view)
topFlutter.didMove(toParent: self)
bottomFlutter.didMove(toParent: self)
}
}