mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Add flutter_view sample * Removed platform_services files * Addressed comments * update README.md * Addressed comments.
49 lines
1.4 KiB
Objective-C
49 lines
1.4 KiB
Objective-C
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.Copyright © 2017 The Chromium Authors. All rights reserved.
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import "MainViewController.h"
|
|
#import "NativeViewController.h"
|
|
|
|
@interface MainViewController ()
|
|
|
|
@property (strong, nonatomic) NativeViewController* nativeViewController;
|
|
@property (strong, nonatomic) FlutterViewController* flutterViewController;
|
|
@end
|
|
|
|
static NSString* const emptyString = @"";
|
|
static NSString* const channel = @"increment";
|
|
|
|
@implementation MainViewController
|
|
|
|
- (NSString*) messageName {
|
|
return channel;
|
|
}
|
|
|
|
- (NSString*)didReceiveString:(NSString*)message {
|
|
[self.nativeViewController didReceiveIncrement];
|
|
return emptyString;
|
|
}
|
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender {
|
|
|
|
if ([segue.identifier isEqualToString: @"NativeViewControllerSegue"]) {
|
|
self.nativeViewController = segue.destinationViewController;
|
|
self.nativeViewController.delegate = self;
|
|
}
|
|
|
|
if ([segue.identifier isEqualToString:@"FlutterViewControllerSegue"]) {
|
|
self.flutterViewController = segue.destinationViewController;
|
|
[self.flutterViewController addMessageListener:self];
|
|
}
|
|
}
|
|
|
|
- (void)didTapIncrementButton {
|
|
[self.flutterViewController sendString:emptyString withMessageName:self.messageName];
|
|
}
|
|
|
|
@end
|