From a2fcf05fb79478a673534da025efd84eaad8d527 Mon Sep 17 00:00:00 2001 From: Pablo Espinosa Date: Tue, 11 Feb 2020 18:42:16 +0000 Subject: [PATCH 1/3] StatusBar example updated using Expo and Hooks Fixed formatting --- docs/statusbar.md | 62 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/docs/statusbar.md b/docs/statusbar.md index cc41264edee..ae6d032e7e5 100644 --- a/docs/statusbar.md +++ b/docs/statusbar.md @@ -9,14 +9,60 @@ Component to control the app status bar. It is possible to have multiple `StatusBar` components mounted at the same time. The props will be merged in the order the `StatusBar` components were mounted. -```jsx - - - - - +```SnackPlayer name=StatusBar%20Android%20and%20iOS%20API%20Example&supportedPlatforms=android,ios +import React, { useState } from "react"; +import { View, StyleSheet, StatusBar, Button } from "react-native"; +import Constants from "expo-constants"; + +const App = () => { + const styleTypes = ['default', 'light-content', 'dark-content']; + const [visibleStatusBar, setVisibleStatusBar] = useState(false); + const [statusBarStyle, setstatusBarStyle] = useState(styleTypes[0]); + + const changeSBVisibility = () => { + setVisibleStatusBar(!visibleStatusBar); + }; + + const changeSBStyle = () => { + const idx = styleTypes.indexOf(statusBarStyle); + if(idx + 1 == styleTypes.length){ + setstatusBarStyle(styleTypes[0]); + return; + } + setstatusBarStyle(styleTypes[idx+1]); + return; + }; + + return ( + + + + + +