就像Facebook,Instagram和任何其他移动应用程序一样,我想实现'回到Stacknavigator中的初始屏幕'
如果您不理解这个用例,请发表评论,我将为您绘制其状态流程
主TabNavigator上的图标代码.
navigationOptions: ({ navigation }) => ({
header: null,
tabBarIcon: ({ focused }) => {
const { routeName } = navigation.state;
....
return (
<TochableWithoutFeedback onPress={()=>{navigation.goback(iconName)}>
// undefined is not a function when I press the Button
// deeper screen. (not getting any error on Main)
<Ionicons
name={iconName}
size={30}
style={{ marginBottom: -3 }}
color={focused ? Colors.tabIconSelected : Colors.tabIconDefault}
/>
<TochableWithoutFeedback>
);
},
Run Code Online (Sandbox Code Playgroud) 我正在使用'react-navigation'中的TabNavigator.我想隐藏或删除图标下的文字.
这是TabNavigator的一部分.(我正在使用世博会)
Camera: {
screen: CameraScreen,
},
Noti: {
screen: NotificationScreen,
},
Menu: {
screen: MenuStackNavigator,
},
},
{
navigationOptions: ({ navigation }) => ({
header: null, <<<
tabBarIcon: ({ focused }) => {
...
},
}),
header: null, <<<-
headerMode: 'none', <<--
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom',
animationEnabled: false,
swipeEnabled: false,
backBehavior: 'none',
Run Code Online (Sandbox Code Playgroud)
这是CamaraScreen
class CameraScreen extends Component {
static navigationOptions = {
title: 'Camera'
}
Run Code Online (Sandbox Code Playgroud) 我正在构建多个选择模式。当用户按下该项目时,该项目应标记为“已检查”。
问题我从 id 数组中添加/删除了 id。当我打开并检查模态时,它没有显示“检查”标志。但是当我再次关闭并打开模态时,它显示“检查”标志。
为了跟踪所选项目,我在模态组件的状态中定义了这些项目。
state = {
selectedSeasonIds: this.props.selectedSeasonIds,
}
Run Code Online (Sandbox Code Playgroud)
这是我用来在屏幕上显示模态的 react-native-modal
<Modal
isVisible={isSelectorVisible}
onBackdropPress = {() => this.props.hideSelector()}>
<View style={styles.modalContainer}>
<FlatList
style={styles.root}
data={this.props.items}
ItemSeparatorComponent={this._renderSeparator}
keyExtractor={this._keyExtractor}
renderItem={this._renderItemForMultiple}/>
</View>
</Modal>
Run Code Online (Sandbox Code Playgroud)
这是每个项目的渲染功能
_renderItemForMultiple = ({item}) => {
return (
<TouchableOpacity
style={styles.itemStyle}
onPress={() => {this._handleMultipleItemPress(item.id)}}>
<RkText>{item.value}</RkText>
{ this._renderCheck(item.id) } <<< Here is the problem
</TouchableOpacity>
);
}
Run Code Online (Sandbox Code Playgroud)
当用户单击该项目时,FlatList 的项目调用 _handleMultipleitemPress
_handleMultipleItemPress = (id) => {
let { selectionType } = this.props;
let { selectedSeasonIds, selectedSizeIds, selectedColorIds } = this.state;
if(selectionType===2) …Run Code Online (Sandbox Code Playgroud) 标签工作正常.但是我不能<Tabs>像下面的图像那样改变下划线和高度
我正在使用Native-Base来处理标签.但我想不出任何改变其默认高度的方法.
<Tabs initialPage={0}
tabBarUnderlineStyle={styles.tabBarUnderlineStyle}
style={{height:40}}
>
<Tab
heading="Following"
tabStyle={styles.tabStyle}
activeTabStyle={styles.activeTabStyle}
activeTextStyle={styles.activeTextStyle}
textStyle={styles.textStyle}
>
<FeedScreen navigation={this.props.navigation}/>
</Tab>
Run Code Online (Sandbox Code Playgroud)
我应该使用其他导航吗?原生基地很难定制.. :(
更新请求,我分享我的风格
tabStyle : {
// backgroundColor: theme.colors.navbar,
backgroundColor: 'white',
justifyContent: 'center',
width: 120,
height: 40,
},
activeTabStyle: {
backgroundColor: 'white',
height: 40,
},
textStyle: {
// color: 'white',
color: "#968D8A"
},
activeTextStyle: {
// color: 'white',
color: theme.colors.navbar
},
tabBarUnderlineStyle: {
backgroundColor: theme.colors.navbar,
height: 2
}
Run Code Online (Sandbox Code Playgroud) 我正在使用所有身份验证(所有身份验证休息)进行基本授权/身份验证。默认情况下,当用户注册时,Django all-auth尝试发送验证电子邮件。
如何禁用它以防止其发送验证电子邮件?
RetrieveUpdateAPIView的url与特定字段一起使用。(例如。/profile/update/<pk>)
我正在从HTTP标头中的令牌获取用户帐户,因此很难将用户的pk包含到URL中。
该视图是我的RetrieveUpdateAPIView。
class ProfileRetrieveAndUpdateProfile(generics.RetrieveUpdateAPIView):
serializer_class = ProfileRetrieveAndUpdateSerializer
# lookup_field = 'pk'
def get_queryset(self):
qs = Profile.objects.all()
logged_in_user_profile = qs.filter(user=self.request.user)
return logged_in_user_profile
Run Code Online (Sandbox Code Playgroud)
我应该只使用views.APIView来实现此功能吗?
我正在构建相册 React Native 移动应用程序。因为我想将作为宽图像(1)的一部分的方形图像显示为图像(2)。
所以问题是,如何在 React Native 中正确缩放图像的中间?我可以用 StyleSheet(CSS) 来做吗?或者有图书馆吗?
我正在使用FontAwesome.ttf和/ <p>String.fromCharCode(61444)</p>或<Text>String.fromCharCode</Text>打印心脏图标.
61444来自哪里??? 我该如何编码或解码?(心脏图标是)
谢谢!
ps如果你想更好地理解,你可以在这里查看确切的代码:https://github.com/akveo/kittenTricks/blob/master/app/assets/icons.js
我将我的整数数组设置为selectedStyleIds。为什么我的this.props.navigaion.setParams无法正常工作?
_setSelectedStyleIds = (selectedStyleIds) => {
const action = NavigationActions.setParams({
params: {selectedStyleIds},
key: 'id-1509842157447-6' <- got this from console
});
this.props.navigation.dispatch(action);
this.props.navigation.setParams({styleIds:selectedStyleIds});
this.setState({selectedStyleIds});
}
onCheck = ({selectedStyleIds}) => {
console.log('onCheck');
console.log(selectedStyleIds); <- [1,2,3,4,5]
this.props._setSelectedStyleIds(selectedStyleIds);
this.setState({selectedStyleIds}); <- working
}
_handleTagStylePress = () => {
this.props.navigation.navigate('TagStyle', {onCheck: this.onCheck, selectedStyleIds: this.state.selectedStyleIds});
}
Run Code Online (Sandbox Code Playgroud)
在onNavigatioOptions上(仅用于调试)
onPress={() => {
let {image, text, ..., selectedSeasonIds,
gender, selectedSizeIds, selectedColorIds, selectedStyleIds,
brand, ..., base64 } = navigation.state.params;
console.log('onsave')
console.log(navigation.state.params.selectedStyleIds) <<-- []
Run Code Online (Sandbox Code Playgroud)
我已经检查了这些行超过50次,但显然this.props.navigation.setParams({selectedStyleIds});无法正常工作。
其他所有设置状态和参数都没有问题,但只能将selectedStyleIds设置为navigation.state.params。
我花了几个小时来解决这个问题.问题是我无法发送POST的正文数据.我从服务器得到500错误.
这是我对React Native的HTTP请求(我想我可能有错误的axios请求).http正文可能有问题吗?
export const createCloth = (token, hType, clothObject) => async dispatch => {
let headers = { 'Authorization': `JWT ${token}`};
if(hType==1) {
headers = { 'Authorization': `JWT ${token}`};
} else if (hType==2) {
headers = { 'Authorization': `Bearer ${token}`};
}
let {image, text, clothType, ... , onlyMe} = clothObject;
console.log(text); <- printing ok
console.log(bigType); <- printing ok
let response = await axios.post(`${ROOT_URL}/clothes/create/`, {
text, clothType, ..., onlyMe
}, {headers});
console.log(response.data); <<< 500 HTTP error
Run Code Online (Sandbox Code Playgroud)
这是我的Backend API的一部分.
class ClothCreateAPIView(APIView): …Run Code Online (Sandbox Code Playgroud) react-native ×6
django ×3
javascript ×3
django-views ×2
http ×2
reactjs ×2
axios ×1
css ×1
font-awesome ×1
html ×1
image ×1
native-base ×1