Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
practiceTask
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
李彥志
practiceTask
Commits
8a554815
Commit
8a554815
authored
Nov 07, 2018
by
李彥志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload index
parent
ee51b5eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
147 additions
and
0 deletions
+147
-0
src/Dialog/index.js
src/Dialog/index.js
+147
-0
No files found.
src/Dialog/index.js
0 → 100644
View file @
8a554815
import
React
from
'
react
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
Modal
,
View
,
Text
,
ScrollView
,
TouchableOpacity
}
from
'
react-native
'
;
import
*
as
Animatable
from
'
react-native-animatable
'
;
import
styles
from
'
./styles
'
;
class
Dialog
extends
React
.
Component
{
static
propTypes
=
{
payload
:
PropTypes
.
object
,
show
:
PropTypes
.
bool
,
customDesign
:
PropTypes
.
array
,
title
:
PropTypes
.
string
,
content
:
PropTypes
.
string
,
buttonTxt
:
PropTypes
.
string
,
cancelTxt
:
PropTypes
.
string
,
confirmFun
:
PropTypes
.
func
,
cancelFun
:
PropTypes
.
func
,
showCancel
:
PropTypes
.
bool
,
contentStyle
:
PropTypes
.
object
,
titleStyle
:
PropTypes
.
object
,
};
static
defaultProps
=
{
payload
:
{},
show
:
false
,
customDesign
:
[],
title
:
''
,
content
:
''
,
buttonTxt
:
'
登出
'
,
cancelTxt
:
'
取消
'
,
confirmFun
:
()
=>
{},
cancelFun
:
()
=>
{},
showCancel
:
false
,
contentStyle
:
{},
titleStyle
:
{}
};
constructor
(
props
)
{
super
(
props
);
const
{
show
,
title
,
content
,
buttonTxt
,
cancelTxt
,
showCancel
,
payload
,
customDesign
}
=
this
.
props
;
this
.
state
=
{
show
,
title
,
content
,
buttonTxt
,
cancelTxt
,
showCancel
,
customDesign
};
this
.
payload
=
payload
;
this
.
doConfirm
=
this
.
doConfirm
.
bind
(
this
);
this
.
doCancel
=
this
.
doCancel
.
bind
(
this
);
}
componentWillReceiveProps
(
nextProps
)
{
const
{
show
,
title
,
content
,
payload
}
=
nextProps
;
if
(
show
!==
this
.
props
.
show
)
{
this
.
payload
=
payload
;
this
.
setState
({
show
,
title
,
content
});
}
}
doConfirm
()
{
this
.
setState
({
show
:
false
},
()
=>
this
.
props
.
confirmFun
(
this
.
payload
));
}
doCancel
()
{
this
.
setState
({
show
:
false
},
()
=>
this
.
props
.
cancelFun
());
}
render
()
{
const
{
showCancel
,
show
,
title
,
cancelTxt
,
customDesign
}
=
this
.
state
;
const
{
contentStyle
,
titleStyle
}
=
this
.
props
;
if
(
!
this
.
props
.
show
&&
!
show
)
{
return
null
;
}
const
buttonStyle
=
(
showCancel
)
?
{
borderLeftWidth
:
1
,
borderLeftColor
:
'
#BCBBC1
'
}
:
{};
return
(
<
Modal
transparent
visible
=
{
this
.
state
.
show
}
onRequestClose
=
{()
=>
{
this
.
doCancel
();
}}
>
<
View
style
=
{
styles
.
modalContainer
}
>
{
customDesign
&&
customDesign
.
length
>
0
?
customDesign
:
(
<
Animatable
.
View
animation
=
"
bounceIn
"
duration
=
{
300
}
style
=
{
styles
.
modalContent
}
useNativeDriver
>
{
title
!==
''
?
(
<
View
style
=
{
styles
.
modalTitle
}
>
<
Text
style
=
{[
styles
.
modalTitle_txt
,
titleStyle
]}
>
{
title
}
<
/Text
>
<
/View
>
)
:
[]}
<
ScrollView
keyboardShouldPersistTaps
=
"
always
"
>
<
View
style
=
{
styles
.
modalMessage
}
>
<
Text
style
=
{[
styles
.
modalMessage_txt
,
contentStyle
]}
>
{
this
.
state
.
content
}
<
/Text
>
<
/View
>
<
/ScrollView
>
<
View
style
=
{
styles
.
modalFooter
}
>
{(
showCancel
)
?
(
<
TouchableOpacity
style
=
{
styles
.
modalFooter_btn
}
onPress
=
{()
=>
this
.
doCancel
()}
>
<
Text
style
=
{
styles
.
modalFooter_txt
}
>
{
cancelTxt
}
<
/Text
>
<
/TouchableOpacity
>
)
:
[]
}
<
TouchableOpacity
style
=
{[
styles
.
modalFooter_btn
,
buttonStyle
]}
onPress
=
{()
=>
this
.
doConfirm
()}
>
<
Text
style
=
{[
styles
.
modalFooter_txt
,
{
fontWeight
:
'
bold
'
}]}
>
{
this
.
state
.
buttonTxt
}
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
<
/Animatable.View>
)
}
<
/View
>
<
/Modal
>
);
}
}
export
default
Dialog
;
\ No newline at end of file
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