DualFlutterViewController.m 1.73 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Dan Field's avatar
Dan Field committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>

#import "DualFlutterViewController.h"

@interface DualFlutterViewController ()

@end

@implementation DualFlutterViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.title = @"Dual Flutter Views";
18 19 20 21 22
  self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
                                              initWithTitle:@"Back"
                                                      style:UIBarButtonItemStylePlain
                                                     target:nil
                                                     action:nil];
Dan Field's avatar
Dan Field committed
23 24 25 26 27 28 29 30

  UIStackView* stackView = [[UIStackView alloc] initWithFrame:self.view.frame];
  stackView.axis = UILayoutConstraintAxisVertical;
  stackView.distribution = UIStackViewDistributionFillEqually;
  stackView.layoutMargins = UIEdgeInsetsMake(0, 0, 50, 0);
  stackView.layoutMarginsRelativeArrangement = YES;
  [self.view addSubview:stackView];

31 32 33 34 35 36 37 38 39 40 41 42
  _topFlutterViewController = [[FlutterViewController alloc] init];
  _bottomFlutterViewController= [[FlutterViewController alloc] init];

  [_topFlutterViewController setInitialRoute:@"marquee_green"];
  [self addChildViewController:_topFlutterViewController];
  [stackView addArrangedSubview:_topFlutterViewController.view];
  [_topFlutterViewController didMoveToParentViewController:self];

  [_bottomFlutterViewController setInitialRoute:@"marquee_purple"];
  [self addChildViewController:_bottomFlutterViewController];
  [stackView addArrangedSubview:_bottomFlutterViewController.view];
  [_bottomFlutterViewController didMoveToParentViewController:self];
Dan Field's avatar
Dan Field committed
43 44 45
}

@end