Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #500 from gluestack/fix/theme-styling
Browse files Browse the repository at this point in the history
fix: layouting issue with theme component and provide styling capability
  • Loading branch information
ankit-tailor authored Oct 30, 2023
2 parents f0c4213 + 66f488c commit c36044e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/react/src/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { View } from 'react-native';
import * as React from 'react';
import { styled } from './styled';
type Config = any;

export const defaultConfig: { theme?: string } = {
Expand All @@ -8,11 +9,17 @@ export const defaultConfig: { theme?: string } = {

const defaultContextData: Config = defaultConfig;
const ThemeContext = React.createContext<Config>(defaultContextData);
// Can be discussed should we provide flex 1 by default or not.
const StyledView = styled(
View,
{
// flex: 1
},
{ componentName: 'GluestackThemeView' }
);

export const Theme: React.FC<{
children?: React.ReactNode;
name?: any;
}> = ({ name, children }) => {
// @ts-ignore
export const Theme: typeof StyledView = ({ children, name, ...props }) => {
const contextValue = React.useMemo(() => {
return {
theme: name,
Expand All @@ -22,7 +29,9 @@ export const Theme: React.FC<{
return (
<ThemeContext.Provider value={contextValue}>
{/* @ts-ignore */}
<View dataSet={{ 'theme-id': name }}>{children}</View>
<StyledView dataSet={{ 'theme-id': name }} {...props}>
{children}
</StyledView>
</ThemeContext.Provider>
);
};
Expand Down

0 comments on commit c36044e

Please sign in to comment.