From 37d275c380b4e5d3caa9a6266ce03f8e35f19ecc Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Fri, 25 Oct 2024 22:07:46 +0100 Subject: [PATCH 1/7] feat: add buttons to hide/show ui --- packages/react-native-ui/src/Layout.tsx | 32 +++++++++++++++++-- .../src/icon/CloseFullscreenIcon.tsx | 19 +++++++++++ .../src/icon/FullscreenIcon.tsx | 21 ++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 packages/react-native-ui/src/icon/CloseFullscreenIcon.tsx create mode 100644 packages/react-native-ui/src/icon/FullscreenIcon.tsx diff --git a/packages/react-native-ui/src/Layout.tsx b/packages/react-native-ui/src/Layout.tsx index 8bcfd8deba..b3f2a56ec6 100644 --- a/packages/react-native-ui/src/Layout.tsx +++ b/packages/react-native-ui/src/Layout.tsx @@ -4,7 +4,7 @@ import { type API_IndexHash, type Args, type StoryContext } from '@storybook/cor import type { ReactRenderer } from '@storybook/react'; import { styled, useTheme } from '@storybook/react-native-theming'; import { ReactNode, useRef, useState } from 'react'; -import { Platform, ScrollView, Text, View } from 'react-native'; +import { Platform, ScrollView, Text, TouchableOpacity, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { IconButton } from './IconButton'; import { useLayout } from './LayoutProvider'; @@ -16,6 +16,8 @@ import { BottomBarToggleIcon } from './icon/BottomBarToggleIcon'; import { DarkLogo } from './icon/DarkLogo'; import { Logo } from './icon/Logo'; import { MenuIcon } from './icon/MenuIcon'; +import { FullscreenIcon } from './icon/FullscreenIcon'; +import { CloseFullscreenIcon } from './icon/CloseFullscreenIcon'; export const Layout = ({ storyHash, @@ -38,6 +40,8 @@ export const Layout = ({ const [desktopAddonsPanelOpen, setDesktopAddonsPanelOpen] = useState(true); + const [uiHidden, setUiHidden] = useState(false); + if (isDesktop) { return ( - {children} + + {children} + + setUiHidden(!uiHidden)} + > + {uiHidden ? ( + + ) : ( + + )} + + @@ -161,7 +187,7 @@ export const Layout = ({ - {(Platform.OS !== 'android' || (!menuOpen && !drawerOpen)) && ( + {!uiHidden && (Platform.OS !== 'android' || (!menuOpen && !drawerOpen)) && ( - )} + ) : null} ); }; From 1459bfa0dbac847795e3636b9f3cae04e1d92013 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 13 Jan 2025 18:43:13 +0000 Subject: [PATCH 3/7] fix: suggestions --- packages/react-native-ui/src/Layout.tsx | 2 +- packages/react-native-ui/src/icon/FullscreenIcon.tsx | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/react-native-ui/src/Layout.tsx b/packages/react-native-ui/src/Layout.tsx index b2b99f170e..4b3e4c29cc 100644 --- a/packages/react-native-ui/src/Layout.tsx +++ b/packages/react-native-ui/src/Layout.tsx @@ -149,7 +149,7 @@ export const Layout = ({ borderWidth: 1, borderColor: theme.appBorderColor, }} - onPress={() => setUiHidden(!uiHidden)} + onPress={() => setUiHidden((prev) => !prev)} > {uiHidden ? ( diff --git a/packages/react-native-ui/src/icon/FullscreenIcon.tsx b/packages/react-native-ui/src/icon/FullscreenIcon.tsx index a83daaabae..79cdcecb26 100644 --- a/packages/react-native-ui/src/icon/FullscreenIcon.tsx +++ b/packages/react-native-ui/src/icon/FullscreenIcon.tsx @@ -2,12 +2,7 @@ import * as React from 'react'; import Svg, { Path, SvgProps } from 'react-native-svg'; import { useTheme } from '@storybook/react-native-theming'; -export function FullscreenIcon({ - color, //= '#2E3438', - width = 14, - height = 14, - ...props -}: SvgProps) { +export function FullscreenIcon({ color, width = 14, height = 14, ...props }: SvgProps) { const theme = useTheme(); return ( From 9a48f6c7c7ec66b1b2988f8f586ed08fd0613166 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 13 Jan 2025 19:42:00 +0000 Subject: [PATCH 4/7] fix: reenable use of noSafeArea --- packages/react-native-ui/src/Layout.tsx | 32 +++++++------------------ 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/packages/react-native-ui/src/Layout.tsx b/packages/react-native-ui/src/Layout.tsx index 23ab6f7663..de5eac2441 100644 --- a/packages/react-native-ui/src/Layout.tsx +++ b/packages/react-native-ui/src/Layout.tsx @@ -136,7 +136,13 @@ export const Layout = ({ } return ( - + {children} @@ -161,28 +167,6 @@ export const Layout = ({ - - - - @@ -211,6 +195,7 @@ export const Layout = ({