| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import { Colors } from "@/constants/Colors";
- import { Images } from "@/constants/images";
- import { Image } from "expo-image";
- import React, { useState } from "react";
- import {
- StyleSheet,
- Text,
- TextInput,
- TouchableOpacity,
- View,
- } from "react-native";
- interface SearchBarProps {
- onSearch?: (keyword: string) => void;
- }
- export function SearchBar({ onSearch }: SearchBarProps) {
- const [keyword, setKeyword] = useState("");
- const handleSearch = () => {
- onSearch?.(keyword);
- };
- return (
- <View style={styles.container}>
- {/* Logo Area */}
- <View style={styles.logo}>
- {/* Use text logo for now to ensure theme match */}
- <Text style={styles.logoText}>
- CYBER<Text style={styles.logoTextHighlight}>MART</Text>
- </Text>
- </View>
- {/* Search Box */}
- <View style={styles.searchBox}>
- <TouchableOpacity onPress={handleSearch}>
- {/* Tint the search icon */}
- <Image
- source={Images.home.search}
- style={styles.searchIcon}
- contentFit="contain"
- tintColor={Colors.neonBlue}
- />
- </TouchableOpacity>
- <TextInput
- style={styles.input}
- placeholder="搜索装备..."
- placeholderTextColor={Colors.textTertiary}
- value={keyword}
- onChangeText={setKeyword}
- onSubmitEditing={handleSearch}
- returnKeyType="search"
- />
- </View>
- </View>
- );
- }
- const styles = StyleSheet.create({
- container: {
- flexDirection: "row",
- alignItems: "center",
- paddingHorizontal: 15,
- paddingVertical: 10,
- backgroundColor: Colors.darkBg, // Ensure bg matches
- },
- logo: {
- marginRight: 20,
- justifyContent: "center",
- },
- logoText: {
- color: "#fff",
- fontWeight: "bold",
- fontSize: 18,
- fontStyle: "italic",
- },
- logoTextHighlight: {
- color: Colors.neonBlue,
- },
- searchBox: {
- flex: 1, // Take remaining width
- flexDirection: "row",
- alignItems: "center",
- backgroundColor: "rgba(255, 255, 255, 0.05)",
- borderRadius: 20,
- paddingHorizontal: 12,
- height: 36,
- borderWidth: 1,
- borderColor: "rgba(0, 243, 255, 0.3)", // Neon border
- },
- searchIcon: {
- width: 16,
- height: 16,
- marginRight: 8,
- },
- input: {
- flex: 1,
- color: Colors.textPrimary,
- fontSize: 14,
- padding: 0,
- },
- });
|