罗广聪

准备引入toast

... ... @@ -7,6 +7,8 @@ import {
Dimensions,
ScrollView,
Text,
Clipboard,
TouchableOpacity
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
... ... @@ -15,8 +17,12 @@ export default class Discover extends Component {
super(props);
this.state = {
image: "",
word: "",
};
}
handleCopyPress(string) {
Clipboard.setString(string);
}
componentWillMount() {
this.getImages();
}
... ... @@ -32,7 +38,7 @@ export default class Discover extends Component {
}
})
.then(resp => {
console.log("大爷",resp);
console.log("大爷", resp);
if (resp.status === 200) {
return resp.json();
} else {
... ... @@ -44,23 +50,28 @@ export default class Discover extends Component {
alert(respJson.cnmsg);
} else {
that.setState({
image: respJson.data.image
image: respJson.data.image,
word: respJson.data.word
});
console.log("图片文章", respJson.data);
}
});
}
render() {
const { image } = this.state;
const { image,word } = this.state;
return (
<View style={styles.container}>
{/* <Text>图片首页</Text> */}
<Image
style={styles.image}
source={{uri: image}}
source={{ uri: image }}
resizeMode="contain"
>
<Text>中央文案</Text>
<Text selectable={true} style={styles.word}>
{word}
</Text>
<TouchableOpacity style={styles.button} onPress={() => {this.handleCopyPress(word)}}>
<Text style={styles.buttonText}>复制文案</Text>
</TouchableOpacity>
</Image>
</View>
);
... ... @@ -76,6 +87,26 @@ const styles = StyleSheet.create({
width: Dimensions.get("window").width,
height: Dimensions.get("window").height,
justifyContent: "center",
alignItems: "center"
},
word: {
marginLeft: 15,
marginRight: 15,
fontSize: 15,
lineHeight: 25,
color: "white",
backgroundColor: "rgba(0,0,0,0)"
},
button: {
width: 80,
height: 40,
marginTop: 20,
backgroundColor: "rgba(0,0,0,0.2)",
justifyContent: "center",
alignItems: "center",
borderRadius: 5,
},
buttonText: {
color: "white",
}
});
... ...