mobile ui fix
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
|
import { View, TextInput, StyleSheet, TouchableOpacity, useWindowDimensions } from 'react-native';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
import { colors, spacing, borderRadius } from '../constants/theme';
|
import { colors, spacing, borderRadius } from '../constants/theme';
|
||||||
|
|
||||||
|
const TABLET_MIN_WIDTH = 768;
|
||||||
|
|
||||||
interface SearchBarProps {
|
interface SearchBarProps {
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
onSearch: (query: string) => void;
|
onSearch: (query: string) => void;
|
||||||
@@ -16,6 +18,8 @@ export function SearchBar({
|
|||||||
value,
|
value,
|
||||||
onChangeText
|
onChangeText
|
||||||
}: SearchBarProps) {
|
}: SearchBarProps) {
|
||||||
|
const { width } = useWindowDimensions();
|
||||||
|
const isTablet = width >= TABLET_MIN_WIDTH;
|
||||||
const [localValue, setLocalValue] = useState(value || '');
|
const [localValue, setLocalValue] = useState(value || '');
|
||||||
|
|
||||||
const handleChange = (text: string) => {
|
const handleChange = (text: string) => {
|
||||||
@@ -34,10 +38,10 @@ export function SearchBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={[styles.container, isTablet && styles.containerTablet]}>
|
||||||
<Ionicons name="search" size={20} color={colors.textSecondary} style={styles.icon} />
|
<Ionicons name="search" size={20} color={colors.textSecondary} style={styles.icon} />
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={[styles.input, isTablet && styles.inputTablet]}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
placeholderTextColor={colors.textSecondary}
|
placeholderTextColor={colors.textSecondary}
|
||||||
value={localValue}
|
value={localValue}
|
||||||
@@ -71,6 +75,10 @@ const styles = StyleSheet.create({
|
|||||||
shadowRadius: 8,
|
shadowRadius: 8,
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
},
|
},
|
||||||
|
containerTablet: {
|
||||||
|
paddingHorizontal: spacing.lg,
|
||||||
|
paddingVertical: spacing.md,
|
||||||
|
},
|
||||||
icon: {
|
icon: {
|
||||||
marginRight: spacing.sm,
|
marginRight: spacing.sm,
|
||||||
},
|
},
|
||||||
@@ -80,6 +88,10 @@ const styles = StyleSheet.create({
|
|||||||
color: colors.text,
|
color: colors.text,
|
||||||
paddingVertical: spacing.xs,
|
paddingVertical: spacing.xs,
|
||||||
},
|
},
|
||||||
|
inputTablet: {
|
||||||
|
fontSize: 18,
|
||||||
|
paddingVertical: spacing.sm,
|
||||||
|
},
|
||||||
clearButton: {
|
clearButton: {
|
||||||
marginLeft: spacing.sm,
|
marginLeft: spacing.sm,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user