Commit 904930d7 by Zac Chan

Added did tap on ios need testing

parent d4bba0db
......@@ -4,9 +4,13 @@
static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
@interface FluttertoastPlugin ()
@property(nonatomic, retain) FluttertoastPlugin *channel;
@end
@implementation FluttertoastPlugin {
FlutterResult _result;
}
+ (void)registerWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
......@@ -16,6 +20,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
UIViewController *viewController =
[UIApplication sharedApplication].delegate.window.rootViewController;
FluttertoastPlugin *instance = [[FluttertoastPlugin alloc] init];
instance.channel = channel;
[registrar addMethodCallDelegate:instance channel:channel];
}
......@@ -38,6 +43,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString *durationTime = call.arguments[@"time"];
NSNumber *bgcolor = call.arguments[@"bgcolor"];
NSNumber *textcolor = call.arguments[@"textcolor"];
NSNumber *size = call.arguments[@"size"];
int time = 1;
@try {
......@@ -64,7 +70,15 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration:time
position:CSToastPositionCenter
style:style];
style:style
completion:^(BOOL didTap){
[self.channel invokeMethod:@"onTap" arguments:@{
@"didTao" : didTap
}];
}];
} else {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration:time
......
......@@ -80,6 +80,11 @@ static const NSString * CSToastQueueKey = @"CSToastQueueKey";
[self showToast:toast duration:duration position:position completion:nil];
}
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position style:(CSToastStyle *)style completion:(void(^)(BOOL didTap))completion {
UIView *toast = [self toastViewForMessage:message title:nil image:nil style:style];
[self showToast:toast duration:duration position:position completion:completion];
}
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title image:(UIImage *)image style:(CSToastStyle *)style completion:(void(^)(BOOL didTap))completion {
UIView *toast = [self toastViewForMessage:message title:title image:image style:style];
[self showToast:toast duration:duration position:position completion:completion];
......
......@@ -13,14 +13,33 @@ class Fluttertoast {
static const MethodChannel _channel =
const MethodChannel('PonnamKarthik/fluttertoast');
static Future<String> showToast({
Fluttertoast _instance;
Fluttertoast get instance {
if (_instance == null) {
}
}
Fluttertoast(){
_channel.setMethodCallHandler(_handleMethod);
}
Function(bool) didTap;
Future<String> showToast({
@required String msg,
Toast toastLength,
int timeInSecForIos = 1,
ToastGravity gravity,
Color backgroundColor,
Color textColor,
Function(bool) didTap,
}) async {
this.didTap = didTap;
String toast = "short";
if (toastLength == Toast.LENGTH_LONG) {
toast = "long";
......@@ -53,4 +72,14 @@ class Fluttertoast {
String res = await _channel.invokeMethod('showToast', params);
return res;
}
Future<dynamic> _handleMethod(MethodCall call) async {
switch(call.method) {
case "onTap":
didTap(true);
return new Future.value("");
}
}
}
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