mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-26 21:54:45 +08:00
feat(ui): enhance settings sections with responsive layout and keyboard handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useCallback } from "react";
|
||||
import { View, Switch, StyleSheet, Pressable, Animated } from "react-native";
|
||||
import { View, Switch, StyleSheet, Pressable, Animated, Platform } from "react-native";
|
||||
import { useTVEventHandler } from "react-native";
|
||||
import { ThemedText } from "@/components/ThemedText";
|
||||
import { SettingsSection } from "./SettingsSection";
|
||||
@@ -7,18 +7,21 @@ import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { useRemoteControlStore } from "@/stores/remoteControlStore";
|
||||
import { useButtonAnimation } from "@/hooks/useAnimation";
|
||||
import { Colors } from "@/constants/Colors";
|
||||
import { useResponsiveLayout } from "@/hooks/useResponsiveLayout";
|
||||
|
||||
interface RemoteInputSectionProps {
|
||||
onChanged: () => void;
|
||||
onFocus?: () => void;
|
||||
onBlur?: () => void;
|
||||
onPress?: () => void;
|
||||
}
|
||||
|
||||
export const RemoteInputSection: React.FC<RemoteInputSectionProps> = ({ onChanged, onFocus, onBlur }) => {
|
||||
export const RemoteInputSection: React.FC<RemoteInputSectionProps> = ({ onChanged, onFocus, onBlur, onPress }) => {
|
||||
const { remoteInputEnabled, setRemoteInputEnabled } = useSettingsStore();
|
||||
const { isServerRunning, serverUrl, error } = useRemoteControlStore();
|
||||
const [isFocused, setIsFocused] = React.useState(false);
|
||||
const animationStyle = useButtonAnimation(isFocused, 1.2);
|
||||
const deviceType = useResponsiveLayout().deviceType;
|
||||
|
||||
const handleToggle = useCallback(
|
||||
(enabled: boolean) => {
|
||||
@@ -38,6 +41,10 @@ export const RemoteInputSection: React.FC<RemoteInputSectionProps> = ({ onChange
|
||||
onBlur?.();
|
||||
};
|
||||
|
||||
const handlePress = () => {
|
||||
handleToggle(!remoteInputEnabled);
|
||||
}
|
||||
|
||||
// TV遥控器事件处理
|
||||
const handleTVEvent = React.useCallback(
|
||||
(event: any) => {
|
||||
@@ -51,7 +58,9 @@ export const RemoteInputSection: React.FC<RemoteInputSectionProps> = ({ onChange
|
||||
useTVEventHandler(handleTVEvent);
|
||||
|
||||
return (
|
||||
<SettingsSection focusable onFocus={handleSectionFocus} onBlur={handleSectionBlur}>
|
||||
<SettingsSection focusable onFocus={handleSectionFocus} onBlur={handleSectionBlur}
|
||||
{...Platform.isTV||deviceType !=='tv'? undefined :{onPress:handlePress}}
|
||||
>
|
||||
<Pressable style={styles.settingItem} onFocus={handleSectionFocus} onBlur={handleSectionBlur}>
|
||||
<View style={styles.settingInfo}>
|
||||
<ThemedText style={styles.settingName}>启用远程输入</ThemedText>
|
||||
|
||||
Reference in New Issue
Block a user