-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
DoubleFlutterViewController.swift
29 lines (26 loc) · 1.19 KB
/
DoubleFlutterViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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)
}
}