Ensure all pages have padding around the status bar

This commit is contained in:
Nat 2021-04-19 10:24:18 -03:00
parent 077a55f4a7
commit 468381207f
6 changed files with 55 additions and 20 deletions

View File

@ -1,26 +1,34 @@
import React from "react"; import React from "react";
import { View } from "react-native"; import { SafeAreaView } from "react-native";
import { ScrollView } from "react-native-gesture-handler"; import { ScrollView } from "react-native-gesture-handler";
import { StatusBarSpace } from "src/interface/rendering";
import BackBarJsx from "./back-bar"; import BackBarJsx from "./back-bar";
import TrayJsx from "src/components/navigation/tray"; import TrayJsx from "src/components/navigation/tray";
export const ScreenWithTrayJsx = (props) => { export const ScreenWithTrayJsx = (props) => {
return ( return (
<View style = { { flex: 1 } }> <SafeAreaView style = { { flex: 1 } }>
<ScrollView> <ScrollView>
<StatusBarSpace
color = {
props.statusBarColor
? props.statusBarColor
: "transparent"
}/>
{ props.children } { props.children }
</ScrollView> </ScrollView>
<TrayJsx <TrayJsx
active = { props.active } active = { props.active }
navigation = { props.navigation } /> navigation = { props.navigation } />
</View> </SafeAreaView>
); );
}; };
export const ScreenWithBackBarJsx = (props) => { export const ScreenWithBackBarJsx = (props) => {
return ( return (
<View style = { { flex: 1 } }> <SafeAreaView style = { { flex: 1 } }>
<StatusBarSpace color = "white"/>
<BackBarJsx navigation = { props.navigation }> <BackBarJsx navigation = { props.navigation }>
{ props.renderBackBar != undefined { props.renderBackBar != undefined
? props.renderBackBar() ? props.renderBackBar()
@ -30,13 +38,14 @@ export const ScreenWithBackBarJsx = (props) => {
<ScrollView> <ScrollView>
{ props.children } { props.children }
</ScrollView> </ScrollView>
</View> </SafeAreaView>
); );
}; };
export const ScreenWithFullNavigationJsx = (props) => { export const ScreenWithFullNavigationJsx = (props) => {
return ( return (
<View style = { { flex: 1 } }> <SafeAreaView style = { { flex: 1 } }>
<StatusBarSpace color = "white"/>
<BackBarJsx navigation = { props.navigation }> <BackBarJsx navigation = { props.navigation }>
{ props.renderBackBar != undefined { props.renderBackBar != undefined
? props.renderBackBar() ? props.renderBackBar()
@ -49,6 +58,6 @@ export const ScreenWithFullNavigationJsx = (props) => {
<TrayJsx <TrayJsx
active = { props.active } active = { props.active }
navigation = { props.navigation } /> navigation = { props.navigation } />
</View> </SafeAreaView>
); );
}; };

View File

@ -1,6 +1,7 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { import {
View, View,
SafeAreaView,
Text, Text,
Image, Image,
TextInput, TextInput,
@ -24,8 +25,7 @@ import {
const { SlideInMenu } = renderers; const { SlideInMenu } = renderers;
import BackBarJsx from "src/components/navigation/back-bar"; import BackBarJsx from "src/components/navigation/back-bar";
import { timeToAge, StatusBarSpace } from "src/interface/rendering";
import { timeToAge } from "src/interface/rendering";
const TEST_IMAGE_1 = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg"; const TEST_IMAGE_1 = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg";
const TEST_IMAGE_2 = "https://natureproducts.net/Forest_Products/Cutflowers/Musella_cut.jpg"; const TEST_IMAGE_2 = "https://natureproducts.net/Forest_Products/Cutflowers/Musella_cut.jpg";
@ -47,7 +47,8 @@ const TEST_MESSAGES = [
]; ];
const ConversationContainerJsx = (props) => ( const ConversationContainerJsx = (props) => (
<View style = { { flex: 1 } }> <SafeAreaView style = { { flex: 1 } }>
<StatusBarSpace color = "white"/>
<BackBarJsx navigation = { props.navigation }> <BackBarJsx navigation = { props.navigation }>
{ props.renderBackBar() } { props.renderBackBar() }
</BackBarJsx> </BackBarJsx>
@ -76,7 +77,7 @@ const ConversationContainerJsx = (props) => (
color = "black" /> color = "black" />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </SafeAreaView>
); );
const ComposeJsx = ({ navigation }) => { const ComposeJsx = ({ navigation }) => {

View File

@ -59,7 +59,8 @@ const DiscoverJsx = (props) => {
return ( return (
<ScreenWithTrayJsx <ScreenWithTrayJsx
active = "Discover" active = "Discover"
navigation = { props.navigation }> navigation = { props.navigation }
statusBarColor = "white">
<TouchableWithoutFeedback <TouchableWithoutFeedback
onPress = { () => props.navigation.navigate("Search") }> onPress = { () => props.navigation.navigate("Search") }>
<View style = { styles.form }> <View style = { styles.form }>

View File

@ -1,6 +1,9 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { View, TextInput, Text, Dimensions, Image } from "react-native"; import { View, TextInput, Text, Dimensions, Image } from "react-native";
import { StatusBarSpace } from "src/interface/rendering";
import { ScreenWithTrayJsx } from "src/components/navigation/navigators"; import { ScreenWithTrayJsx } from "src/components/navigation/navigators";
import { TouchableWithoutFeedback } from "react-native-gesture-handler"; import { TouchableWithoutFeedback } from "react-native-gesture-handler";
const TEST_IMAGE = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg"; const TEST_IMAGE = "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg";
@ -49,8 +52,9 @@ const SearchJsx = ({navigation}) => {
return ( return (
<ScreenWithTrayJsx <ScreenWithTrayJsx
active = "Discover" active = "Discover"
navigation = { navigation }> navigation = { navigation }>
<StatusBarSpace />
<View style = { styles.form }> <View style = { styles.form }>
<TextInput <TextInput
style = { styles.searchBar } style = { styles.searchBar }

View File

@ -1,9 +1,16 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Dimensions, View, Image, TextInput, Text } from "react-native"; import {
Dimensions,
View,
SafeAreaView,
Image,
TextInput,
Text
} from "react-native";
import { ScrollView } from "react-native-gesture-handler"; import { ScrollView } from "react-native-gesture-handler";
import AsyncStorage from "@react-native-async-storage/async-storage"; import AsyncStorage from "@react-native-async-storage/async-storage";
import { timeToAge } from "src/interface/rendering"; import { timeToAge, StatusBarSpace } from "src/interface/rendering";
import { activeOrNot } from "src/interface/interactions"; import { activeOrNot } from "src/interface/interactions";
import TimelineViewJsx from "src/components/posts/timeline-view"; import TimelineViewJsx from "src/components/posts/timeline-view";
@ -225,7 +232,8 @@ const ViewCommentsJsx = (props) => {
return ( return (
<> <>
{ state.loaded ? { state.loaded ?
<View style = { { flex: 1 } }> <SafeAreaView style = { { flex: 1 } }>
<StatusBarSpace color = "white"/>
<BackBarJsx navigation = { props.navigation }/> <BackBarJsx navigation = { props.navigation }/>
<ScrollView> <ScrollView>
{ state.loaded { state.loaded
@ -280,7 +288,7 @@ const ViewCommentsJsx = (props) => {
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
</View> </View>
</View> </View>
</View> </SafeAreaView>
: <></> : <></>
} }
</> </>

View File

@ -1,3 +1,15 @@
import React from "react";
import { View, StatusBar } from "react-native";
export function StatusBarSpace(props) {
return <View style = {
{
height: StatusBar.currentHeight,
backgroundColor: props.color ? props.color : "transparent",
}
}></View>;
};
export function withoutHTML(string) { export function withoutHTML(string) {
return string.replace(/<[^>]*>/ig, ""); return string.replace(/<[^>]*>/ig, "");
} }