This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Suraj
authored and
Suraj
committed
Jun 2, 2023
1 parent
9e4d60d
commit b109acc
Showing
3 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
example/storybook/src/api/MultipleProvder/MultipleProvider.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { ComponentMeta } from '@storybook/react-native'; | ||
import { MultipleProvider } from './MultipleProvider'; | ||
const MyMultipleProviderMeta: ComponentMeta<typeof MultipleProvider> = { | ||
title: 'api/stories/MultipleProvider', | ||
component: MultipleProvider, | ||
}; | ||
|
||
export { MultipleProvider } from './MultipleProvider'; | ||
// | ||
export default MyMultipleProviderMeta; |
49 changes: 49 additions & 0 deletions
49
example/storybook/src/api/MultipleProvder/MultipleProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { memo } from 'react'; | ||
import { View, Pressable, Text } from 'react-native'; | ||
import { styled } from '@gluestack-style/react'; | ||
import { Wrapper } from '../../components/Wrapper'; | ||
import { get, set } from '@gluestack-style/react'; | ||
|
||
const StyleView = memo( | ||
styled( | ||
View, | ||
{ | ||
w: 100, | ||
h: 100, | ||
bg: '$red500', | ||
|
||
_dark: { | ||
bg: '$info600', | ||
}, | ||
}, | ||
{} | ||
) | ||
); | ||
|
||
export function MultipleProvider() { | ||
const [currentColorMode, setCurrentColorMode] = React.useState(get()); | ||
|
||
return ( | ||
<Wrapper colorMode={currentColorMode}> | ||
<Wrapper> | ||
<Pressable | ||
style={{ | ||
backgroundColor: 'gray', | ||
padding: 12, | ||
marginBottom: 12, | ||
}} | ||
onPress={() => { | ||
// set(get() === 'dark' ? 'light' : 'dark'); | ||
setCurrentColorMode(currentColorMode === 'dark' ? 'light' : 'dark'); | ||
}} | ||
> | ||
<Text style={{ color: 'white' }}> | ||
Toggle {currentColorMode === 'dark' ? 'light' : 'dark'} | ||
</Text> | ||
</Pressable> | ||
<StyleView /> | ||
</Wrapper> | ||
</Wrapper> | ||
); | ||
} | ||
export default MultipleProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters