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
6e52d4a9
Commit
6e52d4a9
authored
Dec 02, 2018
by
Ben Getsug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attempt fixing ios background color
parent
da7609f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
41 deletions
+40
-41
ios/Classes/FluttertoastPlugin.m
+40
-41
No files found.
ios/Classes/FluttertoastPlugin.m
View file @
6e52d4a9
...
...
@@ -9,85 +9,84 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
}
+
(
void
)
registerWithRegistrar
:
(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName
:
CHANNEL_NAME
binaryMessenger
:[
registrar
messenger
]];
+
(
void
)
registerWithRegistrar
:
(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName
:
CHANNEL_NAME
binaryMessenger
:[
registrar
messenger
]];
UIViewController
*
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
FluttertoastPlugin
*
instance
=
[[
FluttertoastPlugin
alloc
]
init
];
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
FluttertoastPlugin
*
instance
=
[[
FluttertoastPlugin
alloc
]
init
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
-
(
unsigned
int
)
intFromHexString
:
(
NSString
*
)
hexStr
{
unsigned
int
hexInt
=
0
;
NSScanner
*
scanner
=
[
NSScanner
scannerWithString
:
hexStr
];
[
scanner
setCharactersToBeSkipped
:[
NSCharacterSet
characterSetWithCharactersInString
:
@"#"
]];
[
scanner
scanHexInt
:
&
hexInt
];
return
hexInt
;
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
{
-
(
UIColor
*
)
getUIColorObjectFromHexString
:
(
NSString
*
)
hexStr
alpha
:
(
CGFloat
)
alpha
{
// Convert hex string to an integer
unsigned
int
hexint
=
[
self
intFromHexString
:
hexStr
];
unsigned
int
hexint
=
[
self
intFromHexString
:
hexStr
];
// Create color object, specifying alpha as well
UIColor
*
color
=
[
UIColor
colorWithRed
:((
CGFloat
)
((
hexint
&
0xFF0000
)
>>
16
))
/
255
green
:((
CGFloat
)
((
hexint
&
0xFF00
)
>>
8
))
/
255
blue
:
((
CGFloat
)
(
hexint
&
0xFF
))
/
255
alpha
:
alpha
];
UIColor
*
color
=
[
UIColor
colorWithRed
:((
CGFloat
)
((
hexint
&
0xFF0000
)
>>
16
))
/
255
green
:((
CGFloat
)
((
hexint
&
0xFF00
)
>>
8
))
/
255
blue
:
((
CGFloat
)
(
hexint
&
0xFF
))
/
255
alpha
:
alpha
];
return
color
;
return
color
;
}
-
(
void
)
handleMethodCall
:
(
FlutterMethodCall
*
)
call
result
:
(
FlutterResult
)
result
{
-
(
void
)
handleMethodCall
:
(
FlutterMethodCall
*
)
call
result
:
(
FlutterResult
)
result
{
if
([
@"showToast"
isEqualToString
:
call
.
method
])
{
NSString
*
msg
=
call
.
arguments
[
@"msg"
];
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NSString
*
bgcolor
=
call
.
arguments
[
@"bgcolor"
];
NSString
*
textcolor
=
call
.
arguments
[
@"textcolor"
];
int
time
=
1
;
@try
{
@try
{
time
=
[
durationTime
intValue
];
}
@catch
(
NSException
*
e
)
{
}
@catch
(
NSException
*
e
)
{
time
=
3
;
}
if
(
time
>
10
)
time
=
10
;
else
if
(
time
<
1
)
time
=
1
;
if
(
time
>
10
)
time
=
10
;
else
if
(
time
<
1
)
time
=
1
;
CSToastStyle
*
style
=
[[
CSToastStyle
alloc
]
initWithDefaultStyle
];
if
(
!
[
bgcolor
isEqualToString
:
@"null"
])
{
style
.
self
.
backgroundColor
=
[
self
getUIColorObjectFromHexString
:
bgcolor
alpha
:
1
.
0
];
if
(
!
[
bgcolor
isEqualToString
:
@"null"
])
{
style
.
backgroundColor
=
[
self
getUIColorObjectFromHexString
:
bgcolor
alpha
:
1
.
0
];
}
if
(
!
[
textcolor
isEqualToString
:
@"null"
])
{
if
(
!
[
textcolor
isEqualToString
:
@"null"
])
{
style
.
messageColor
=
[
self
getUIColorObjectFromHexString
:
textcolor
alpha
:
1
.
0
];
}
if
([
gravity
isEqualToString
:
@"top"
])
{
if
([
gravity
isEqualToString
:
@"top"
])
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
time
duration
:
time
position
:
CSToastPositionTop
style
:
style
];
}
else
if
([
gravity
isEqualToString
:
@"center"
])
{
style
:
style
];
}
else
if
([
gravity
isEqualToString
:
@"center"
])
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
time
duration
:
time
position
:
CSToastPositionCenter
style
:
style
];
style
:
style
];
}
else
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
time
duration
:
time
position
:
CSToastPositionBottom
style
:
style
];
style
:
style
];
}
result
(
@"done"
);
}
else
{
result
(
FlutterMethodNotImplemented
);
...
...
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