我正在开发我的第一个React原生应用程序,我正在尝试为主屏幕设计页脚。为此,我创建了一个视图,并将其放在scrollView下。然后,我尝试使用borderTopColor将页脚与页面的其余部分分开,但没有成功。
home.js
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, Text, View, FlatList, Image, Button, Pressable, ScrollView } from 'react-native';
import React, {useState, useEffect} from 'react'
import { TextInput } from 'react-native-gesture-handler';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faUser } from '@fortawesome/free-regular-svg-icons';
import { faAlignJustify, faUser as solidUser} from '@fortawesome/free-solid-svg-icons'
import { faComments as solidComment } from '@fortawesome/free-solid-svg-icons';
import { faComments } from '@fortawesome/free-regular-svg-icons';
export default function Home(props) {
const [ current, setCurrent ] = useState("profile")
const [ user, setUser ] = useState("")
const curr = (cur) => {
setCurrent(cur)
}
const getData = async () => {
try {
const value = await AsyncStorage.getItem('@userauthkey')
if (value !== null) {
return value
} else {
return false
}
} catch (e) {
console.log(e)
}
}
useEffect(() => {
const ch = async () => {
const c = await getData();
if (c) {
setUser(c)
}
};
ch();
}, []);
const gprof = (user) => {
fetch(`http://192.168.5.223:8000/home/checkprofile/`,{
method: 'POST',
headers: {
"Content-Type": 'application/json',
},
body: JSON.stringify({'user':user}),
} )
.then( res => res.json())
.then( res => {
console.log(res.profile)
console.log(res.sets)
if (res.sets === false){
props.navigation.navigate('Profile')
}
})
.catch( error => console.log(error))
}
const logout = async () => {
try {
await AsyncStorage.removeItem('@userauthkey')
props.navigation.navigate('Login')
} catch(e){
console.log(e)
}
}
if(current === "profile"){
return (
<View style={styles.container}>
<ScrollView style={styles.scroll} >
<Text> profile {user} </Text>
<Pressable onPress={ () => logout()}>
<Text>Logout</Text>
</Pressable>
</ScrollView>
<View style={styles.footer}>
<Pressable onPress={() => curr('messanger')}>
<View style={{ borderWidth: 2, borderStyle: 'solid', borderColor: "white", borderRadius: 20, padding: 3, }}>
<FontAwesomeIcon icon={faComments} style={{color: 'white',}} size={25} />
</View>
</Pressable>
<Pressable onPress={() => curr('profile')}>
<View style={{ borderWidth: 2, borderStyle: 'solid', borderColor: "white", backgroundColor: 'white', borderRadius: 20, padding: 3, }}>
<FontAwesomeIcon icon={solidUser} style={{color: 'black', alignContent:"center", } } size={25} />
</View>
</Pressable>
</View>
<StatusBar style="auto"/>
</View>
)
} else if(current === "posts"){
return (
<View style={styles.container}>
<ScrollView style={styles.scroll} >
<Text> posts {user} </Text>
</ScrollView>
<View style={styles.footer}>
</View>
<StatusBar style="auto"/>
</View>
)
} else if (current === "messanger"){
return (
<View style={styles.container}>
<ScrollView style={styles.scroll} >
<Text> messanger {user} </Text>
</ScrollView>
<View style={styles.footer}>
<Pressable onPress={() => curr('messanger')}>
<View style={{ borderWidth: 2, borderStyle: 'solid', borderColor: "white", backgroundColor:"white", borderRadius: 20, padding: 3}}>
<FontAwesomeIcon icon={solidComment} style={{color: 'black',}} size={25} />
</View>
</Pressable>
<Pressable onPress={() => curr('profile')}>
<View style={{ borderWidth: 2, borderStyle: 'solid', borderColor: "white", borderRadius: 20, padding: 3}}>
<FontAwesomeIcon icon={faUser} style={{color: 'white', borderStyle: 'solid', borderColor: "white", borderRadius: 20}} size={25} />
</View>
</Pressable>
</View>
<StatusBar style="auto"/>
</View>
)
}
}
Home.navigationOptions = screenProps => ({
headerLeft: () => null,
gestureEnabled: false,
headerStyle: {
backgroundColor: 'black'
},
headerTintColor: 'white',
})
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'black',
},
scroll: {
backgroundColor:'#'
},
footer: {
backgroundColor: 'black',
borderTopColor: 'dark-gray',
borderTopWidth: .5 ,
borderStyle: 'solid',
padding:50,
paddingTop:18,
paddingLeft: 18,
paddingRight: 18,
flexDirection: 'row',
alignContent: "space-between",
alignItems: "space-between",
justifyContent: "space-between",
},
label: {
fontSize: 24,
color: "white",
padding: 10,
},
input: {
fontSize: 24,
backgroundColor: "white",
padding: 10,
margin: 10,
borderRadius: 5,
},
});
我该如何解决这个问题?
1条答案
按热度按时间polhcujo1#
dark-gray
不是React Native中可识别的颜色关键字。您可能会想到darkgray
。您可以在此处找到支持的颜色关键字的完整列表:https://reactnative.dev/docs/colors#color-keywords