AppDelegate.m 1.47 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1 2 3 4
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
#import "AppDelegate.h"
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#import "MainViewController.h"

@interface AppDelegate ()

@end

static NSString *_kReloadChannelName = @"reload";

@implementation AppDelegate {
  MainViewController *_mainViewController;
  UINavigationController *_navigationController;
  FlutterEngine *_engine;
  FlutterBasicMessageChannel *_reloadMessageChannel;
}

- (FlutterEngine *)engine {
  return _engine;
}

25
- (FlutterBasicMessageChannel *)reloadMessageChannel {
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  return _reloadMessageChannel;
}

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

  _mainViewController = [[MainViewController alloc] init];
  _navigationController = [[UINavigationController alloc]
      initWithRootViewController:_mainViewController];

  _navigationController.navigationBar.translucent = NO;

  _engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
  [_engine runWithEntrypoint:nil];

  _reloadMessageChannel = [[FlutterBasicMessageChannel alloc]
         initWithName:_kReloadChannelName
      binaryMessenger:_engine.binaryMessenger
                codec:[FlutterStringCodec sharedInstance]];

  self.window.rootViewController = _navigationController;
  [self.window makeKeyAndVisible];

  return YES;
}
52 53

@end