Commit 4cd5b4d1 by Ponnam Karthik

Added iOS code need to test

parent f9eb43fc
#import "FluttertoastPlugin.h"
#import <fluttertoast/fluttertoast-Swift.h>
#import "UIView+Toast.h"
// #import <fluttertoast/fluttertoast-Swift.h>
@interface QRCodeReaderPlugin()
@property (nonatomic, strong) UIView *toastview;
@property (nonatomic, retain) UIViewController *viewController;
@property (nonatomic, retain) UIViewController *toastViewController;
@end
@implementation FluttertoastPlugin {
FlutterResult _result;
UIViewController *_viewController;
}
@implementation FluttertoastPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
[SwiftFluttertoastPlugin registerWithRegistrar:registrar];
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:CHANNEL_NAME
binaryMessenger:[registrar messenger]];
// UIViewController *viewController = (UIViewController *)registrar.messenger;
UIViewController *viewController =
[UIApplication sharedApplication].delegate.window.rootViewController;
FluttertoastPlugin* instance = [[FluttertoastPlugin alloc] initWithViewController:viewController];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"showToast" isEqualToString:call.method]) {
[self showToastView:call];
_result = result;
} else {
result(FlutterMethodNotImplemented);
}
}
- (instancetype)initWithViewController:(UIViewController *)viewController {
self = [super init];
if (self) {
_viewController = viewController;
//_viewController.view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.0];
_viewController.view.backgroundColor = [UIColor clearColor];
_viewController.view.opaque = NO;
[[ NSNotificationCenter defaultCenter]addObserver: self selector:@selector(rotate:)
name:UIDeviceOrientationDidChangeNotification object:nil];
}
return self;
}
- (void)showToastView:(FlutterMethodCall*)call {
_toastViewController = [[UIViewController alloc] init];
[_viewController presentViewController:_toastViewController animated:NO completion:nil];
_toastview= [[UIView alloc] init];
_toastViewController.view = _toastview;
[self.view makeToast:@"This is a piece of toast."];
}
@end
import Flutter
import UIKit
import Toast_Swift
public class SwiftFluttertoastPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "PonnamKarthik/fluttertoast", binaryMessenger: registrar.messenger())
let instance = SwiftFluttertoastPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public class SwiftFluttertoastPlugin: NSObject {
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "showToast":
result(FlutterMethodNotImplemented)
default:
result(FlutterMethodNotImplemented)
}
}
}
......@@ -15,7 +15,6 @@ Toast Library for FLutter
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'Toast-Swift'
s.ios.deployment_target = '8.0'
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment