Toggle navigation
Toggle navigation
This project
Loading...
Sign in
罗广聪
/
ProtectGod
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
罗广聪
2017-09-28 11:58:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e8984c2140277878ca22b2ed4e5a6fab76d4be89
e8984c21
1 parent
0c405c21
share
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
8 deletions
src/pages/Discover/index.js
src/pages/Discover/index.js
View file @
e8984c2
...
...
@@ -10,6 +10,7 @@ import {
TouchableOpacity
,
Clipboard
,
Alert
,
Share
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
}
from
"react-navigation"
;
...
...
@@ -17,9 +18,9 @@ export default class Discover extends Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
// image: "",
word
:
""
,
date
:
{}
date
:
{},
result
:
""
};
}
handleCopyPress
(
string
)
{
...
...
@@ -62,6 +63,38 @@ export default class Discover extends Component {
copyWords
(
string
)
{
Clipboard
.
setString
(
string
);
}
ShareSomething
()
{
const
that
=
this
;
console
.
log
(
"share"
)
Share
.
share
({
title
:
"保护神"
,
message
:
that
.
state
.
word
,
url
:
"http://www.baidu.com"
// url: `http://reactnative.cn/docs/0.48/share.html?userid=${1}&articleid=${2}`
},{
// dialogTitle: 'Share React Native website',
excludedActivityTypes
:
[
'com.apple.UIKit.activity.PostToTwitter'
],
tintColor
:
'green'
})
.
then
(
that
.
_showResult
)
.
catch
(
error
=>
this
.
setState
({
result
:
"error: "
+
error
.
message
}));
}
_showResult
(
result
)
{
if
(
result
.
action
===
Share
.
sharedAction
)
{
if
(
result
.
activityType
)
{
this
.
setState
({
result
:
"shared with an activityType: "
+
result
.
activityType
});
}
else
{
this
.
setState
({
result
:
"shared"
});
}
}
else
if
(
result
.
action
===
Share
.
dismissedAction
)
{
this
.
setState
({
result
:
"dismissed"
});
}
}
render
()
{
const
{
word
,
date
}
=
this
.
state
;
return
(
...
...
@@ -79,10 +112,26 @@ export default class Discover extends Component {
<
View
style
=
{
styles
.
wordConatier
}
>
<
Text
style
=
{
styles
.
word
}
>
{
word
}
<
/Text
>
<
/View
>
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{()
=>
{
this
.
copyWords
(
word
)}}
>
<
Image
style
=
{
styles
.
btnImg
}
source
=
{
require
(
"../../assets/discover/ic_copy.png"
)}
/
>
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{()
=>
{
this
.
copyWords
(
word
);
}}
>
<
Image
style
=
{
styles
.
btnImg
}
source
=
{
require
(
"../../assets/discover/ic_copy.png"
)}
/
>
<
Text
style
=
{
styles
.
btnText
}
>
复制文案
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
style
=
{
styles
.
shareContaier
}
onPress
=
{()
=>
{
this
.
ShareSomething
();
}}
>
<
Text
style
=
{
styles
.
shareText
}
>
分享
<
/Text
>
<
/TouchableOpacity
>
<
/Image
>
);
}
...
...
@@ -128,7 +177,7 @@ const styles = StyleSheet.create({
paddingLeft
:
22
,
paddingRight
:
22
,
paddingTop
:
28
,
paddingBottom
:
28
,
paddingBottom
:
28
},
word
:
{
fontSize
:
15
,
...
...
@@ -142,15 +191,29 @@ const styles = StyleSheet.create({
justifyContent
:
"center"
,
alignItems
:
"center"
,
position
:
"absolute"
,
bottom
:
150
,
bottom
:
150
},
btnImg
:
{
width
:
13
,
height
:
15
,
marginRight
:
5
,
marginRight
:
5
},
btnText
:
{
color
:
"white"
,
fontSize
:
15
,
fontSize
:
15
},
shareContaier
:
{
width
:
Dimensions
.
get
(
"window"
).
width
-
40
,
backgroundColor
:
"#1B9341"
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
marginVertical
:
20
,
paddingVertical
:
10
,
marginHorizontal
:
20
,
borderRadius
:
5
},
shareText
:
{
color
:
"white"
,
fontSize
:
15
}
});
...
...
Please
register
or
login
to post a comment