Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fluttertoast
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
fluttertoast
Commits
904930d7
Commit
904930d7
authored
Jan 18, 2019
by
Zac Chan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added did tap on ios need testing
parent
d4bba0db
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
ios/Classes/FluttertoastPlugin.m
+15
-1
ios/Classes/UIView+Toast.m
+5
-0
lib/fluttertoast.dart
+30
-1
No files found.
ios/Classes/FluttertoastPlugin.m
View file @
904930d7
...
...
@@ -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
...
...
ios/Classes/UIView+Toast.m
View file @
904930d7
...
...
@@ -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
];
...
...
lib/fluttertoast.dart
View file @
904930d7
...
...
@@ -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
(
""
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment