1- import { Platform , ScrollView , StyleSheet , Text , View } from "react-native" ;
1+ import {
2+ Dimensions ,
3+ Platform ,
4+ ScrollView ,
5+ StyleSheet ,
6+ Text ,
7+ View ,
8+ } from "react-native" ;
29import { Header } from "@/components/Header" ;
3- import { useRef , useState } from "react" ;
10+ import { useMemo , useRef , useState } from "react" ;
411import { Card } from "@/components/Card" ;
512import { fontStyles } from "@/styles/font" ;
613import { IconArrowSmRight } from "@/assets/images/IconArrowSmRight" ;
@@ -22,6 +29,7 @@ export default function HomeScreen() {
2229 const bottomSheetRef = useRef < BottomSheet > ( null ) ;
2330 const [ currentSnapIndex , setCurrentSnapIndex ] = useState < number > ( 0 ) ;
2431 const [ logs , setLogs ] = useState < Array < Log > > ( [ ] ) ;
32+ const [ cardPadding , setCardPadding ] = useState < number > ( 0 ) ;
2533
2634 const doPing = async ( ) => {
2735 setConnectionState ( "loading" ) ;
@@ -57,7 +65,22 @@ export default function HomeScreen() {
5765 }
5866 } ;
5967
68+ const snapPoints = useMemo (
69+ ( ) => [ Platform . OS === "android" ? 50 : 70 , "50%" , "90%" ] ,
70+ [ ] ,
71+ ) ;
72+
73+ const resolveSnapPoint = ( point : string | number ) : number => {
74+ if ( typeof point === "number" ) return point ;
75+ if ( point . endsWith ( "%" ) ) {
76+ const percent = parseFloat ( point . replace ( "%" , "" ) ) ;
77+ return ( percent / 100 ) * Dimensions . get ( "window" ) . height ;
78+ }
79+ return 0 ;
80+ } ;
81+
6082 const handleSnapChange = ( index : number ) => {
83+ setCardPadding ( resolveSnapPoint ( snapPoints [ index ] ) + 48 ) ;
6184 setCurrentSnapIndex ( index ) ;
6285 } ;
6386
@@ -66,17 +89,18 @@ export default function HomeScreen() {
6689 < GestureHandlerRootView >
6790 < ScrollView >
6891 < Header pingFunction = { doPing } state = { connectionState } />
69- < View style = { styles . cardContainer } >
92+ < View
93+ style = { { ...styles . cardContainer , paddingBlockEnd : cardPadding } }
94+ >
7095 < Card >
7196 < View style = { styles . cardHeader } >
7297 < Text style = { fontStyles . titleM } > Edit your app</ Text >
7398 </ View >
7499 < Text >
75100 < Code variant = { "secondary" } > Edit </ Code >
76101 < Code variant = { "primary" } > app/index.tsx</ Code >
77- < Code variant = { "secondary" } > to get started with building</ Code >
78102 < Code variant = { "secondary" } >
79- your app and many more to come
103+ to get started with building your app
80104 </ Code >
81105 </ Text >
82106 </ Card >
@@ -104,7 +128,7 @@ export default function HomeScreen() {
104128 </ ScrollView >
105129 < BottomSheet
106130 index = { 0 }
107- snapPoints = { [ Platform . OS === "android" ? 50 : 70 , "50%" , "90%" ] }
131+ snapPoints = { snapPoints }
108132 enablePanDownToClose = { false }
109133 handleComponent = { null }
110134 ref = { bottomSheetRef }
@@ -133,7 +157,9 @@ const styles = StyleSheet.create({
133157 cardContainer : {
134158 paddingInline : 20 ,
135159 display : "flex" ,
136- gap : 16 ,
160+ flexDirection : Dimensions . get ( "window" ) . width < 1024 ? "column" : "row" ,
161+ justifyContent : "center" ,
162+ gap : 28 ,
137163 } ,
138164 scrollview : {
139165 height : 200 ,
0 commit comments