diff --git a/src/components/TableBackground.js b/src/components/TableBackground.js index 16225b7..939793d 100644 --- a/src/components/TableBackground.js +++ b/src/components/TableBackground.js @@ -2,9 +2,9 @@ import { StyleSheet, View } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import { colors } from '../theme'; -export default function TableBackground({ children }) { +export default function TableBackground({ children, style }) { return ( - + { @@ -80,7 +82,16 @@ export default function LobbyScreen({ user, token, onLogout, onSelectTable, onRe const customValid = Number.isFinite(customValue) && customValue >= 50 && customValue <= 100; return ( - + Lobbi diff --git a/src/screens/TableScreen.js b/src/screens/TableScreen.js index c1096d3..4ed2f22 100644 --- a/src/screens/TableScreen.js +++ b/src/screens/TableScreen.js @@ -1,6 +1,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { Animated, Pressable, StyleSheet, Text, View } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; +import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { WS_URL } from '../api'; import { colors, fonts } from '../theme'; import CasinoButton from '../components/CasinoButton'; @@ -17,6 +18,7 @@ export default function TableScreen({ token, tableId, user, onLeave }) { const [turnSeconds, setTurnSeconds] = useState(null); const wsRef = useRef(null); const pulse = useRef(new Animated.Value(0)).current; + const insets = useSafeAreaInsets(); useEffect(() => { const ws = new WebSocket(WS_URL); @@ -122,8 +124,21 @@ export default function TableScreen({ token, tableId, user, onLeave }) { }); }; + const seats = table?.seats || []; + const topRow = seats.slice(0, 3); + const bottomRow = seats.slice(3); + return ( - + Asztal {tableId} @@ -132,25 +147,32 @@ export default function TableScreen({ token, tableId, user, onLeave }) { - - - - + + + + + + - - {table?.seats?.map((seat) => { - const position = seatPositions[seat.index]; - if (!position) { - return null; - } - return ( - - + + + {topRow.map((seat) => ( + + + + ))} - ); - })} - - + + {bottomRow.map((seat) => ( + + + + ))} + + + + + @@ -182,20 +204,10 @@ export default function TableScreen({ token, tableId, user, onLeave }) { ); } -const seatPositions = { - 0: { bottom: 10, left: '38%' }, - 1: { bottom: 20, left: '8%' }, - 2: { bottom: 20, right: '8%' }, - 3: { top: '52%', left: 0 }, - 4: { top: '52%', right: 0 }, - 5: { top: '22%', left: '6%' }, - 6: { top: '22%', right: '6%' } -}; - const styles = StyleSheet.create({ container: { flex: 1, - paddingTop: 40 + paddingHorizontal: 20 }, topBar: { paddingHorizontal: 20, @@ -214,16 +226,37 @@ const styles = StyleSheet.create({ marginTop: 4, fontFamily: fonts.mono }, - dealerArea: { + tableWrap: { + flex: 1, + justifyContent: 'center', alignItems: 'center' }, - seatsLayer: { - flex: 1, - position: 'relative' + tableSurface: { + aspectRatio: 1.35, + maxHeight: 420 }, - seatPosition: { - position: 'absolute', - width: 140 + dealerArea: { + alignItems: 'center', + paddingTop: 8 + }, + tableContent: { + flex: 1, + justifyContent: 'space-between', + paddingBottom: 8 + }, + playersArea: { + paddingHorizontal: 10, + paddingBottom: 8 + }, + seatRow: { + flexDirection: 'row', + justifyContent: 'space-between', + marginBottom: 10 + }, + seatCell: { + flex: 1, + marginHorizontal: 4, + minWidth: 82 }, controls: { paddingHorizontal: 20,