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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
3 deletions
+51
-3
ios/Classes/FluttertoastPlugin.m
+16
-2
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 @@
...
@@ -4,9 +4,13 @@
static
NSString
*
const
CHANNEL_NAME
=
@"PonnamKarthik/fluttertoast"
;
static
NSString
*
const
CHANNEL_NAME
=
@"PonnamKarthik/fluttertoast"
;
@interface
FluttertoastPlugin
()
@property
(
nonatomic
,
retain
)
FluttertoastPlugin
*
channel
;
@end
@implementation
FluttertoastPlugin
{
@implementation
FluttertoastPlugin
{
FlutterResult
_result
;
FlutterResult
_result
;
}
}
+
(
void
)
registerWithRegistrar
:
(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
+
(
void
)
registerWithRegistrar
:
(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
...
@@ -16,6 +20,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -16,6 +20,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
UIViewController
*
viewController
=
UIViewController
*
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
FluttertoastPlugin
*
instance
=
[[
FluttertoastPlugin
alloc
]
init
];
FluttertoastPlugin
*
instance
=
[[
FluttertoastPlugin
alloc
]
init
];
instance
.
channel
=
channel
;
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
}
...
@@ -38,7 +43,8 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -38,7 +43,8 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NSNumber
*
bgcolor
=
call
.
arguments
[
@"bgcolor"
];
NSNumber
*
bgcolor
=
call
.
arguments
[
@"bgcolor"
];
NSNumber
*
textcolor
=
call
.
arguments
[
@"textcolor"
];
NSNumber
*
textcolor
=
call
.
arguments
[
@"textcolor"
];
NSNumber
*
size
=
call
.
arguments
[
@"size"
];
int
time
=
1
;
int
time
=
1
;
@try
{
@try
{
time
=
[
durationTime
intValue
];
time
=
[
durationTime
intValue
];
...
@@ -64,7 +70,15 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -64,7 +70,15 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
time
duration
:
time
position
:
CSToastPositionCenter
position
:
CSToastPositionCenter
style
:
style
];
style
:
style
completion
:^
(
BOOL
didTap
){
[
self
.
channel
invokeMethod
:
@"onTap"
arguments
:@{
@"didTao"
:
didTap
}];
}];
}
else
{
}
else
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
time
duration
:
time
...
...
ios/Classes/UIView+Toast.m
View file @
904930d7
...
@@ -80,6 +80,11 @@ static const NSString * CSToastQueueKey = @"CSToastQueueKey";
...
@@ -80,6 +80,11 @@ static const NSString * CSToastQueueKey = @"CSToastQueueKey";
[
self
showToast
:
toast
duration
:
duration
position
:
position
completion
:
nil
];
[
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
{
-
(
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
];
UIView
*
toast
=
[
self
toastViewForMessage
:
message
title
:
title
image
:
image
style
:
style
];
[
self
showToast
:
toast
duration
:
duration
position
:
position
completion
:
completion
];
[
self
showToast
:
toast
duration
:
duration
position
:
position
completion
:
completion
];
...
...
lib/fluttertoast.dart
View file @
904930d7
...
@@ -13,14 +13,33 @@ class Fluttertoast {
...
@@ -13,14 +13,33 @@ class Fluttertoast {
static
const
MethodChannel
_channel
=
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
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
,
@required
String
msg
,
Toast
toastLength
,
Toast
toastLength
,
int
timeInSecForIos
=
1
,
int
timeInSecForIos
=
1
,
ToastGravity
gravity
,
ToastGravity
gravity
,
Color
backgroundColor
,
Color
backgroundColor
,
Color
textColor
,
Color
textColor
,
Function
(
bool
)
didTap
,
})
async
{
})
async
{
this
.
didTap
=
didTap
;
String
toast
=
"short"
;
String
toast
=
"short"
;
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
toast
=
"long"
;
toast
=
"long"
;
...
@@ -53,4 +72,14 @@ class Fluttertoast {
...
@@ -53,4 +72,14 @@ class Fluttertoast {
String
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
String
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
return
res
;
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