Improved status bar height fix
This commit is contained in:
parent
41eaaac350
commit
e157af57d1
8 changed files with 40 additions and 45 deletions
|
@ -4,7 +4,7 @@ import * as React from 'react';
|
||||||
import {ERROR_TYPE, readData} from "../../utils/WebData";
|
import {ERROR_TYPE, readData} from "../../utils/WebData";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import {Snackbar} from 'react-native-paper';
|
import {Snackbar} from 'react-native-paper';
|
||||||
import {Animated, Platform, RefreshControl, StatusBar, View} from "react-native";
|
import {Animated, RefreshControl, View} from "react-native";
|
||||||
import ErrorView from "../Custom/ErrorView";
|
import ErrorView from "../Custom/ErrorView";
|
||||||
import BasicLoadingScreen from "../Custom/BasicLoadingScreen";
|
import BasicLoadingScreen from "../Custom/BasicLoadingScreen";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
@ -205,12 +205,6 @@ class WebSectionList extends React.PureComponent<Props, State> {
|
||||||
dataset = this.props.createDataset(this.state.fetchedData);
|
dataset = this.props.createDataset(this.state.fetchedData);
|
||||||
const shouldRenderHeader = this.props.renderSectionHeader !== null;
|
const shouldRenderHeader = this.props.renderSectionHeader !== null;
|
||||||
const {containerPaddingTop, scrollIndicatorInsetTop, onScrollWithListener} = this.props.collapsibleStack;
|
const {containerPaddingTop, scrollIndicatorInsetTop, onScrollWithListener} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
const inset = Platform.OS === 'android'
|
|
||||||
? scrollIndicatorInsetTop - StatusBar.currentHeight
|
|
||||||
: scrollIndicatorInsetTop;
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{/*$FlowFixMe*/}
|
{/*$FlowFixMe*/}
|
||||||
|
@ -219,7 +213,7 @@ class WebSectionList extends React.PureComponent<Props, State> {
|
||||||
extraData={this.props.updateData}
|
extraData={this.props.updateData}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl
|
<RefreshControl
|
||||||
progressViewOffset={padding}
|
progressViewOffset={containerPaddingTop}
|
||||||
refreshing={this.state.refreshing}
|
refreshing={this.state.refreshing}
|
||||||
onRefresh={this.onRefresh}
|
onRefresh={this.onRefresh}
|
||||||
/>
|
/>
|
||||||
|
@ -241,10 +235,10 @@ class WebSectionList extends React.PureComponent<Props, State> {
|
||||||
// Animations
|
// Animations
|
||||||
onScroll={onScrollWithListener(this.props.onScroll)}
|
onScroll={onScrollWithListener(this.props.onScroll)}
|
||||||
contentContainerStyle={{
|
contentContainerStyle={{
|
||||||
paddingTop: padding,
|
paddingTop: containerPaddingTop,
|
||||||
minHeight: '100%'
|
minHeight: '100%'
|
||||||
}}
|
}}
|
||||||
scrollIndicatorInsets={{top: inset}}
|
scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}
|
||||||
/>
|
/>
|
||||||
<Snackbar
|
<Snackbar
|
||||||
visible={this.state.snackbarVisible}
|
visible={this.state.snackbarVisible}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import MaterialHeaderButtons, {Item} from '../Custom/HeaderButton';
|
||||||
import {HiddenItem} from "react-navigation-header-buttons";
|
import {HiddenItem} from "react-navigation-header-buttons";
|
||||||
import {Linking} from "expo";
|
import {Linking} from "expo";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import {Animated, BackHandler, Platform, StatusBar} from "react-native";
|
import {Animated, BackHandler} from "react-native";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -133,9 +133,6 @@ class WebViewScreen extends React.PureComponent<Props> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {containerPaddingTop, onScrollWithListener} = this.props.collapsibleStack;
|
const {containerPaddingTop, onScrollWithListener} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
return (
|
return (
|
||||||
<AnimatedWebView
|
<AnimatedWebView
|
||||||
ref={this.webviewRef}
|
ref={this.webviewRef}
|
||||||
|
@ -152,7 +149,7 @@ class WebViewScreen extends React.PureComponent<Props> {
|
||||||
this.canGoBack = navState.canGoBack;
|
this.canGoBack = navState.canGoBack;
|
||||||
}}
|
}}
|
||||||
onMessage={this.props.onMessage}
|
onMessage={this.props.onMessage}
|
||||||
onLoad={() => this.injectJavaScript(this.getJavascriptPadding(padding))}
|
onLoad={() => this.injectJavaScript(this.getJavascriptPadding(containerPaddingTop))}
|
||||||
// Animations
|
// Animations
|
||||||
onScroll={onScrollWithListener(this.props.onScroll)}
|
onScroll={onScrollWithListener(this.props.onScroll)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Animated, Platform, StatusBar} from "react-native";
|
import {Animated, Platform} from "react-native";
|
||||||
import {Chip, Searchbar, withTheme} from 'react-native-paper';
|
import {Chip, Searchbar, withTheme} from 'react-native-paper';
|
||||||
import AuthenticatedScreen from "../../../components/Amicale/AuthenticatedScreen";
|
import AuthenticatedScreen from "../../../components/Amicale/AuthenticatedScreen";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
|
@ -97,12 +97,6 @@ class ClubListScreen extends React.Component<Props, State> {
|
||||||
getScreen = (data: Object) => {
|
getScreen = (data: Object) => {
|
||||||
this.categories = data[0].categories;
|
this.categories = data[0].categories;
|
||||||
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
const inset = Platform.OS === 'android'
|
|
||||||
? scrollIndicatorInsetTop - StatusBar.currentHeight
|
|
||||||
: scrollIndicatorInsetTop;
|
|
||||||
return (
|
return (
|
||||||
//$FlowFixMe
|
//$FlowFixMe
|
||||||
<Animated.FlatList
|
<Animated.FlatList
|
||||||
|
@ -115,8 +109,8 @@ class ClubListScreen extends React.Component<Props, State> {
|
||||||
getItemLayout={this.itemLayout}
|
getItemLayout={this.itemLayout}
|
||||||
// Animations
|
// Animations
|
||||||
onScroll={onScroll}
|
onScroll={onScroll}
|
||||||
contentContainerStyle={{paddingTop: padding}}
|
contentContainerStyle={{paddingTop: containerPaddingTop}}
|
||||||
scrollIndicatorInsets={{top: inset}}
|
scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,6 @@ type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
route: Object,
|
route: Object,
|
||||||
theme: Object,
|
theme: Object,
|
||||||
collapsibleStack: Object,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Animated, Image, Platform, ScrollView, StatusBar, View} from "react-native";
|
import {Animated, Image, Platform, ScrollView, View} from "react-native";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import CustomModal from "../../components/Custom/CustomModal";
|
import CustomModal from "../../components/Custom/CustomModal";
|
||||||
import {RadioButton, Searchbar, Subheading, Text, Title, withTheme} from "react-native-paper";
|
import {RadioButton, Searchbar, Subheading, Text, Title, withTheme} from "react-native-paper";
|
||||||
|
@ -298,12 +298,6 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
const inset = Platform.OS === 'android'
|
|
||||||
? scrollIndicatorInsetTop - StatusBar.currentHeight
|
|
||||||
: scrollIndicatorInsetTop;
|
|
||||||
return (
|
return (
|
||||||
<View style={{
|
<View style={{
|
||||||
height: '100%'
|
height: '100%'
|
||||||
|
@ -323,8 +317,8 @@ class ProximoListScreen extends React.Component<Props, State> {
|
||||||
initialNumToRender={10}
|
initialNumToRender={10}
|
||||||
// Animations
|
// Animations
|
||||||
onScroll={onScroll}
|
onScroll={onScroll}
|
||||||
contentContainerStyle={{paddingTop: padding}}
|
contentContainerStyle={{paddingTop: containerPaddingTop}}
|
||||||
scrollIndicatorInsets={{top: inset}}
|
scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Alert, Platform, StatusBar, View} from 'react-native';
|
import {Alert, Platform, View} from 'react-native';
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import WebSectionList from "../../components/Lists/WebSectionList";
|
import WebSectionList from "../../components/Lists/WebSectionList";
|
||||||
import * as Notifications from "../../utils/Notifications";
|
import * as Notifications from "../../utils/Notifications";
|
||||||
|
@ -421,16 +421,13 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
render() {
|
render() {
|
||||||
const nav = this.props.navigation;
|
const nav = this.props.navigation;
|
||||||
const {containerPaddingTop} = this.props.collapsibleStack;
|
const {containerPaddingTop} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
return (
|
return (
|
||||||
<AnimatedFocusView
|
<AnimatedFocusView
|
||||||
{...this.props}
|
{...this.props}
|
||||||
>
|
>
|
||||||
<Banner
|
<Banner
|
||||||
style={{
|
style={{
|
||||||
marginTop: this.state.bannerVisible ? padding : 0,
|
marginTop: this.state.bannerVisible ? containerPaddingTop : 0,
|
||||||
}}
|
}}
|
||||||
visible={this.state.bannerVisible}
|
visible={this.state.bannerVisible}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -5,7 +5,7 @@ import ThemeManager from "../../managers/ThemeManager";
|
||||||
import WebViewScreen from "../../components/Screens/WebViewScreen";
|
import WebViewScreen from "../../components/Screens/WebViewScreen";
|
||||||
import {Avatar, Banner, withTheme} from "react-native-paper";
|
import {Avatar, Banner, withTheme} from "react-native-paper";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import {Platform, StatusBar, View} from "react-native";
|
import {View} from "react-native";
|
||||||
import AsyncStorageManager from "../../managers/AsyncStorageManager";
|
import AsyncStorageManager from "../../managers/AsyncStorageManager";
|
||||||
import AlertDialog from "../../components/Dialog/AlertDialog";
|
import AlertDialog from "../../components/Dialog/AlertDialog";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
@ -299,16 +299,13 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {containerPaddingTop} = this.props.collapsibleStack;
|
const {containerPaddingTop} = this.props.collapsibleStack;
|
||||||
const padding = Platform.OS === 'android' // Fix for android non translucent bar on expo
|
|
||||||
? containerPaddingTop - StatusBar.currentHeight
|
|
||||||
: containerPaddingTop;
|
|
||||||
return (
|
return (
|
||||||
<AnimatedFocusView
|
<AnimatedFocusView
|
||||||
{...this.props}
|
{...this.props}
|
||||||
>
|
>
|
||||||
<Banner
|
<Banner
|
||||||
style={{
|
style={{
|
||||||
marginTop: this.state.bannerVisible ? padding : 0,
|
marginTop: this.state.bannerVisible ? containerPaddingTop : 0,
|
||||||
}}
|
}}
|
||||||
visible={this.state.bannerVisible}
|
visible={this.state.bannerVisible}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -1,8 +1,31 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {StatusBar} from 'react-native';
|
||||||
import {useCollapsibleStack} from "react-navigation-collapsible";
|
import {useCollapsibleStack} from "react-navigation-collapsible";
|
||||||
|
|
||||||
export const withCollapsible = (Component: any) => {
|
export const withCollapsible = (Component: any) => {
|
||||||
return React.forwardRef((props: any, ref: any) => {
|
return React.forwardRef((props: any, ref: any) => {
|
||||||
return <Component collapsibleStack={useCollapsibleStack()} ref={ref} {...props} />;
|
|
||||||
|
const {
|
||||||
|
onScroll,
|
||||||
|
onScrollWithListener,
|
||||||
|
containerPaddingTop,
|
||||||
|
scrollIndicatorInsetTop,
|
||||||
|
translateY,
|
||||||
|
progress,
|
||||||
|
opacity,
|
||||||
|
} = useCollapsibleStack();
|
||||||
|
return <Component
|
||||||
|
collapsibleStack={{
|
||||||
|
onScroll,
|
||||||
|
onScrollWithListener,
|
||||||
|
containerPaddingTop: containerPaddingTop - StatusBar.currentHeight,
|
||||||
|
scrollIndicatorInsetTop: scrollIndicatorInsetTop - StatusBar.currentHeight,
|
||||||
|
translateY,
|
||||||
|
progress,
|
||||||
|
opacity,
|
||||||
|
}}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue