forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for SafeAreaView and minor improvements
- Loading branch information
1 parent
cc9be15
commit 7342fb0
Showing
16 changed files
with
199 additions
and
161 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
plugins: | ||
process.env.NODE_ENV === 'production' ? ['transform-remove-console'] : [], | ||
}; |
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
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
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
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
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
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,13 @@ | ||
import styled from 'styled-components/native'; | ||
import { FlexboxProps, flexbox } from 'styled-system'; | ||
import { SafeAreaView as RNSafeAreaView, ViewProps } from 'react-native'; | ||
import { customBackground } from '../../../utils/customProps'; | ||
import type { customBackgroundProps } from '../../../utils/customProps'; | ||
|
||
export type IViewProps = ViewProps & FlexboxProps & customBackgroundProps; | ||
const SafeAreaView: any = styled(RNSafeAreaView)<IViewProps>( | ||
flexbox, | ||
customBackground | ||
); | ||
|
||
export default SafeAreaView; |
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
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
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
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
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,2 @@ | ||
export { usePropsConfig } from './useProps'; | ||
export { usePropsWithComponentTheme } from './usePropsWithComponentTheme'; |
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,47 @@ | ||
import get from 'lodash/get'; | ||
import omit from 'lodash/omit'; | ||
import { useWindowDimensions } from 'react-native'; | ||
import { useNativeBase } from './../useNativeBase'; | ||
import { omitUndefined, extractInObject } from './../../theme/tools/'; | ||
import { filterShadowProps } from './../../utils/filterShadowProps'; | ||
import { calculateProps } from './utils'; | ||
|
||
const filterAndCalculateProps = ( | ||
theme: any, | ||
colorModeProps: any, | ||
componentTheme: any, | ||
propsReceived: any, | ||
windowWidth: any | ||
) => { | ||
// Extracting out children and style, as they do not contribute in props calculation | ||
let [ignoredProps, props] = extractInObject(propsReceived, [ | ||
'children', | ||
'style', | ||
'onPress', | ||
'icon', | ||
'onOpen', | ||
'onClose', | ||
]); | ||
let newProps = calculateProps( | ||
theme, | ||
colorModeProps, | ||
componentTheme, | ||
props, | ||
windowWidth | ||
); | ||
let mergedProps = filterShadowProps(newProps, ignoredProps); | ||
return omitUndefined(mergedProps); | ||
}; | ||
|
||
export function usePropsConfig(component: string, propsReceived: any) { | ||
const { theme, ...colorModeProps } = useNativeBase(); | ||
const componentTheme = get(theme, `components.${component}`); | ||
let windowWidth = useWindowDimensions()?.width; | ||
return filterAndCalculateProps( | ||
omit(theme, ['components']), | ||
colorModeProps, | ||
componentTheme, | ||
propsReceived, | ||
windowWidth | ||
); | ||
} |
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,19 @@ | ||
import omit from 'lodash/omit'; | ||
import { useWindowDimensions } from 'react-native'; | ||
import { useNativeBase } from './../useNativeBase'; | ||
import { calculateProps } from './utils'; | ||
|
||
export function usePropsWithComponentTheme( | ||
localTheme: any, | ||
propsReceived: any | ||
) { | ||
const { theme, ...colorModeProps } = useNativeBase(); | ||
let windowWidth = useWindowDimensions()?.width; | ||
return calculateProps( | ||
omit(theme, 'components'), | ||
colorModeProps, | ||
localTheme, | ||
propsReceived, | ||
windowWidth | ||
); | ||
} |
Oops, something went wrong.