tadd select component

This commit is contained in:
Tran Anh Tuan
2025-11-07 15:28:55 +07:00
parent 25b9e831d1
commit f7b05f1e08
7 changed files with 318 additions and 25 deletions

View File

@@ -1,4 +1,5 @@
import ScanQRCode from "@/components/ScanQRCode";
import Select from "@/components/Select";
import { useState } from "react";
import {
Platform,
@@ -21,13 +22,32 @@ export default function Sensor() {
const handleScanPress = () => {
setScanModalVisible(true);
};
const [selectedValue, setSelectedValue] = useState<
string | number | undefined
>(undefined);
const options = [
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Cherry", value: "cherry", disabled: true },
];
return (
<SafeAreaView style={{ flex: 1 }}>
<ScrollView contentContainerStyle={styles.scrollContent}>
<View style={styles.container}>
<Text style={styles.titleText}>Cảm biến trên tàu</Text>
<Select
style={{ width: "80%", marginBottom: 20 }}
options={options}
value={selectedValue}
onChange={(val) => {
setSelectedValue(val);
console.log("Value: ", val);
}}
placeholder="Select a fruit"
allowClear
/>
<Pressable style={styles.scanButton} onPress={handleScanPress}>
<Text style={styles.scanButtonText}>📱 Scan QR Code</Text>
</Pressable>

View File

@@ -1,8 +1,8 @@
import { ThemedText } from "@/components/themed-text";
import { ThemedView } from "@/components/themed-view";
import { showToastError } from "@/config";
import { TOKEN } from "@/constants";
import { login } from "@/controller/AuthController";
import { showErrorToast } from "@/services/toast_service";
import {
getStorageItem,
removeStorageItem,
@@ -57,7 +57,7 @@ export default function LoginScreen() {
const handleLogin = async () => {
// Validate input
if (!username.trim() || !password.trim()) {
showToastError("Lỗi", "Vui lòng nhập tài khoản và mật khẩu");
showErrorToast("Vui lòng nhập tài khoản và mật khẩu");
return;
}
@@ -81,8 +81,7 @@ export default function LoginScreen() {
router.replace("/(tabs)");
}
} catch (error) {
showToastError(
"Lỗi",
showErrorToast(
error instanceof Error ? error.message : "Đăng nhập thất bại"
);
} finally {