-
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.
Merge pull request #13 from williamjayjay/step10-add-libs-classnames-…
…rn-safe-container-component-wrapper feat: add libs classnames and rn safe area, and create component to u…
- Loading branch information
Showing
12 changed files
with
8,532 additions
and
37 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
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
src/presentation/ui/components/SafeAreaContainer/safeAreaContainer.index.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,70 @@ | ||
import { useMemo, type FC, type ReactNode } from 'react'; | ||
import classNames from 'classnames'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
|
||
import { | ||
KeyboardAvoidingView, | ||
ScrollView, | ||
View, | ||
} from 'react-native'; | ||
|
||
export const SafeAreaContainer: FC<{ | ||
children: ReactNode; | ||
haveKeyboard?: boolean; | ||
viewKeyboardClassName?: string; | ||
containerClassName?: string; | ||
disableScroll?: boolean; | ||
testID?: string; | ||
}> = ({ | ||
viewKeyboardClassName = '', | ||
containerClassName = '', | ||
haveKeyboard = false, | ||
children, | ||
testID, | ||
disableScroll = false, | ||
}) => { | ||
const insets = useSafeAreaInsets(); | ||
|
||
const renderChildren = useMemo(() => { | ||
const stylContainer = classNames('flex flex-1 z-10', containerClassName); | ||
|
||
return ( | ||
<View | ||
className={stylContainer} | ||
style={{ paddingTop: insets.top + 8, paddingBottom: insets.bottom + 8 , paddingHorizontal:8}} | ||
testID={testID}> | ||
{children} | ||
</View> | ||
); | ||
}, [ | ||
children, | ||
containerClassName, | ||
insets.bottom, | ||
insets.top | ||
]); | ||
|
||
if (disableScroll) return renderChildren; | ||
|
||
if (haveKeyboard) { | ||
return ( | ||
<KeyboardAvoidingView | ||
className={classNames('flex-1', viewKeyboardClassName)} | ||
behavior="padding" | ||
enabled> | ||
<ScrollView | ||
showsVerticalScrollIndicator={false} | ||
className={classNames('flex flex-1', containerClassName)}> | ||
{renderChildren} | ||
</ScrollView> | ||
</KeyboardAvoidingView> | ||
); | ||
} | ||
|
||
return ( | ||
<ScrollView | ||
showsVerticalScrollIndicator={false} | ||
className={classNames('flex flex-1', containerClassName)}> | ||
{renderChildren} | ||
</ScrollView> | ||
); | ||
}; |
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
File renamed without changes.
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,21 @@ | ||
import { useHomeViewModel } from "@/presentation/viewmodels/HomeViewModel/hooks/home.hook"; | ||
import { FC } from "react"; | ||
import { Text } from "react-native"; | ||
import { IHome } from "./types/home.type"; | ||
import { SafeAreaContainer } from "@/presentation/ui/components/SafeAreaContainer/safeAreaContainer.index"; | ||
|
||
const HomeScreen: FC<IHome.Input> = () => { | ||
|
||
const { students } = useHomeViewModel({}) | ||
|
||
console.log('students', students.length) | ||
|
||
return ( | ||
<SafeAreaContainer haveKeyboard > | ||
<Text className="font-karla600SemiBold" >Ola mundo</Text> | ||
<Text className="font-karla200ExtraLight" >Ola mundo</Text> | ||
</SafeAreaContainer> | ||
); | ||
}; | ||
|
||
export { HomeScreen } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.