以下是我要实现的演示屏幕。
因此,我想做的是,当我向上滑动绿色区域时,我希望黄色区域与之同时向上移动,以及下面的蓝色框区域(FlatList
在我的情况下)。
当黄色区域最终被隐藏时,我希望绿色区域停留在屏幕顶部,并且用户可以在下面的蓝色框区域中滚动。
如何使用API PanResponder
和Animated
API?据我所知,可以使用插值来完成,但是在这种情况下我无法获得逻辑。
reactjs react-native react-native-android react-native-animatable
我正在使用 react-router-dom 并且我想要的是能够在单击浏览器后退按钮时关闭模态。
此外,在我的场景中,模态组件不是Switch
. 那么我该如何关闭模态。
提前致谢 :)
我正在使用以下代码,它适用于 Chrome 和 Firefox,但不适用于 Safari。在 React js 中。它在 Safari 浏览器中的替代方案是什么?
navigator.permissions.query({name:'geolocation'}).then(function(result) {
if (result.state == 'granted') {
cb(true)
}else if(result.state == 'prompt'){
cb(false)
}
});
Run Code Online (Sandbox Code Playgroud) takePicture = async function() {
if (this.camera) {
const options = { quality: 0.5, base64: true, mirrorImage: true };
const data = await this.camera.takePictureAsync(options)
this.setState({path: data.uri})
}
}
Run Code Online (Sandbox Code Playgroud)
takePicture 是捕获图像的函数。现在我想保存捕获的图像并将其上传到 Firebase 存储。
this.setState({path: data.uri}) 更新单击图像位置的路径。
如何使用 React Native fetch Blob 将图像上传到 Firebase 存储中?请帮忙
我目前正在使用react-native-camera - ^1.6.3 和 firebase - ^5.0.3
我正在开发一个 React Native 应用程序,并且正在从 firebase 集合中获取配置文件。我想添加一个搜索功能,当我输入用户名的前 1 个或 2 个(或更多)字母并按下搜索按钮时。我应该能够获取以 1 或 2 个字母开头的用户名。
我确实检查了 Cloud Firestore 查询,但找不到适合我的问题的查询。
更新的问题:
在上面的代码中,我添加了 Renaud Tarnec 回答的以下代码。
let queries = hashes.map(hash => rangeQueryParams(hash))
.map(range => profiles.where('hash', '>=', range.start).where('hash', '<', range.end)
.orderBy('displayName') // displayName is the name of Field here
.startAt(searchString)
.endAt(searchString + '\uf8ff')
.get());
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用。我想这是因为范围过滤器 和orderBy
在这里位于不同的字段。
firebase google-cloud-platform react-native firebase-realtime-database google-cloud-firestore
当我在 中使用onEndReached
函数时FlatList
,它会被自动调用。
下面是这个问题的链接。
是否有可用的解决方案或 iOS 中的任何替代方案?
编辑:
下面是我试过的代码,但这似乎不起作用。
constructor(props){
super(props);
this.state = {
flatListReady:false
}
}
loadMore(){
if(!this.state.flatListReady){
return null;
}
else{
alert("End Reached")
}
}
_scrolled(){
this.setState({flatListReady:true});
}
render() {
return (
<Layout style={{ flex: 1 }}>
<FlatList
data={listData}
renderItem={({item}) => this._renderItem(item)}
keyExtractor={(item, index) => item.key}
onEndReached={() => this.loadMore()}
onEndReachedThreshold={0.5}
onScroll={() => this._scrolled()}
/>
</Layout>
Run Code Online (Sandbox Code Playgroud) 从上面的图像中,我有2个视图,当按下棕色或绿色按钮时可以更改。因此,当默认情况下已选择棕色按钮时,地图中就会有一个标记。当我按下绿色按钮时,我希望删除地图的标记。
所以我尝试的是在按下绿色按钮时设置一个异步变量,并在Map组件中获取该异步变量。
借助Map组件中的异步变量,我将让Map知道隐藏标记。但是问题是如何重新呈现地图组件?
更新的问题
丹的解决方案为我工作。但是现在我有一个小问题。当我this.setState
在下面使用时,componentWillMount
它给了我警告。那么,根据接收到的道具的价值,我还可以使用其他什么方法来显示/隐藏我的标记呢?
if(this.props.isMarkerVisible) {
this.setState({ showDots: true })
}
else {
this.setState({ showDots: false })
}
{ this.state.showDots === true &&
<Marker
ref={(mark) => { this.marker = mark; }}
coordinate={{ latitude, longitude }}
pinColor={colors.primaryColor}
image={require('../../../../assets/circle.png')}
/>
}
{ this.state.showDots === false && null }
Run Code Online (Sandbox Code Playgroud) 我的主屏幕上有5个标签。
AddPostTab就是这样。
const AddPostTab = createStackNavigator({
AddPost: {
screen: AddPost,
},
ImageDescription: {
screen: ImageDescription
},
},
{
headerMode:'none',
mode:'modal'
}
);
Run Code Online (Sandbox Code Playgroud)
当我从ImageDescription
屏幕返回主屏幕,然后AddPostTab
再次进入时,我将直接转到ImageDescription
屏幕。但我希望能够转到AddPost屏幕。
我也尝试过
const resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'AddPost' }),
],
});
this.props.navigation.dispatch(resetAction);
Run Code Online (Sandbox Code Playgroud)
但这只将我带到AddPost屏幕。但是,如果我使用Home而不是AddPost,则无法使用。我该如何重设堆栈以进入主屏幕?