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
f79f305e
Commit
f79f305e
authored
Dec 02, 2018
by
Ben Getsug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attempt fixing ios background color
parent
a8ec8c5d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
57 deletions
+13
-57
ios/Classes/FluttertoastPlugin.m
+9
-52
lib/fluttertoast.dart
+4
-5
No files found.
ios/Classes/FluttertoastPlugin.m
View file @
f79f305e
...
@@ -20,24 +20,12 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -20,24 +20,12 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
}
}
-
(
unsigned
int
)
intFromHexString
:
(
NSString
*
)
hexStr
{
-
(
UIColor
*
)
getUIColorObjectFromInt
:
(
unsigned
int
)
value
{
unsigned
int
hexInt
=
0
;
NSScanner
*
scanner
=
[
NSScanner
scannerWithString
:
hexStr
];
[
scanner
setCharactersToBeSkipped
:[
NSCharacterSet
characterSetWithCharactersInString
:
@"#"
]];
[
scanner
scanHexInt
:
&
hexInt
];
return
hexInt
;
}
-
(
UIColor
*
)
getUIColorObjectFromHexString
:
(
NSString
*
)
hexStr
alpha
:
(
CGFloat
)
alpha
{
// Convert hex string to an integer
unsigned
int
hexint
=
[
self
intFromHexString
:
hexStr
];
// Create color object, specifying alpha as well
UIColor
*
color
=
UIColor
*
color
=
[
UIColor
colorWithRed
:((
CGFloat
)
((
hexint
&
0xFF0000
)
>>
16
))
/
255
[
UIColor
colorWithRed
:((
CGFloat
)
((
value
&
0xFF
)
<<
16
))
/
255
green
:((
CGFloat
)
((
hexint
&
0xFF00
)
>>
8
))
/
255
green
:((
CGFloat
)
((
value
&
0xFF
)
<<
8
))
/
255
blue
:
((
CGFloat
)
(
hexint
&
0xFF
))
/
255
blue
:
((
CGFloat
)
(
(
value
&
0xFF
)
<<
0
))
/
255
alpha
:
alpha
];
alpha
:
((
CGFloat
)
((
value
&
0xFF
)
<<
24
))
/
255
];
return
color
;
return
color
;
}
}
...
@@ -47,8 +35,8 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -47,8 +35,8 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString
*
msg
=
call
.
arguments
[
@"msg"
];
NSString
*
msg
=
call
.
arguments
[
@"msg"
];
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NS
String
*
bgcolor
=
call
.
arguments
[
@"bgcolor"
];
NS
Number
*
bgcolor
=
call
.
arguments
[
@"bgcolor"
];
NS
String
*
textcolor
=
call
.
arguments
[
@"textcolor"
];
NS
Number
*
textcolor
=
call
.
arguments
[
@"textcolor"
];
int
time
=
1
;
int
time
=
1
;
@try
{
@try
{
...
@@ -62,13 +50,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -62,13 +50,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
CSToastStyle
*
style
=
[[
CSToastStyle
alloc
]
initWithDefaultStyle
];
CSToastStyle
*
style
=
[[
CSToastStyle
alloc
]
initWithDefaultStyle
];
if
(
!
[
bgcolor
isEqualToString
:
@"null"
])
{
style
.
backgroundColor
=
[
self
getUIColorObjectFromHexString
:
bgcolor
alpha
:
1
.
0
];
}
if
(
!
[
textcolor
isEqualToString
:
@"null"
])
{
style
.
backgroundColor
=
[
self
getUIColorObjectFromInt
:
bgcolor
.
unsignedIntValue
];
style
.
messageColor
=
[
self
getUIColorObjectFromHexString
:
textcolor
alpha
:
1
.
0
];
style
.
messageColor
=
[
self
getUIColorObjectFromInt
:
textcolor
.
unsignedIntValue
];
}
if
([
gravity
isEqualToString
:
@"top"
])
{
if
([
gravity
isEqualToString
:
@"top"
])
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
...
@@ -93,31 +77,4 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -93,31 +77,4 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
}
}
}
}
// - (void)showToastView:(FlutterMethodCall*)call:(NSString*)msg {
// [[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg];
// }
// func hexStringToUIColor (hex:String) -> UIColor {
// var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
// if (cString.hasPrefix("#")) {
// cString.remove(at: cString.startIndex)
// }
// if ((cString.count) != 6) {
// return UIColor.gray
// }
// var rgbValue:UInt32 = 0
// Scanner(string: cString).scanHexInt32(&rgbValue)
// return UIColor(
// red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
// green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
// blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
// alpha: CGFloat(1.0)
// )
// }
@end
@end
lib/fluttertoast.dart
View file @
f79f305e
...
@@ -17,8 +17,8 @@ class Fluttertoast {
...
@@ -17,8 +17,8 @@ class Fluttertoast {
Toast
toastLength
,
Toast
toastLength
,
int
timeInSecForIos
=
1
,
int
timeInSecForIos
=
1
,
ToastGravity
gravity
,
ToastGravity
gravity
,
Color
backgroundColor
,
Color
backgroundColor
=
const
Color
.
fromARGB
(
255
,
0
,
0
,
0
)
,
Color
textColor
,
Color
textColor
=
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
)
,
})
async
{
})
async
{
String
toast
=
"short"
;
String
toast
=
"short"
;
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
...
@@ -39,9 +39,8 @@ class Fluttertoast {
...
@@ -39,9 +39,8 @@ class Fluttertoast {
'length'
:
toast
,
'length'
:
toast
,
'time'
:
timeInSecForIos
,
'time'
:
timeInSecForIos
,
'gravity'
:
gravityToast
,
'gravity'
:
gravityToast
,
'bgcolor'
:
'bgcolor'
:
backgroundColor
.
value
,
backgroundColor
!=
null
?
backgroundColor
.
value
.
toString
()
:
"null"
,
'textcolor'
:
textColor
.
value
,
'textcolor'
:
textColor
!=
null
?
textColor
.
value
.
toString
()
:
"null"
};
};
String
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
String
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
return
res
;
return
res
;
...
...
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