feat: Support remote input

This commit is contained in:
zimplexing
2025-07-10 22:18:34 +08:00
parent eaa783824d
commit 9e4d4ca242
12 changed files with 9691 additions and 9 deletions

View File

@@ -7,6 +7,8 @@ import { Platform } from "react-native";
import Toast from "react-native-toast-message";
import { useSettingsStore } from "@/stores/settingsStore";
import { useRemoteControlStore } from "@/stores/remoteControlStore";
import { remoteControlService } from "@/services/remoteControlService";
// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();
@@ -31,6 +33,23 @@ export default function RootLayout() {
}
}, [loaded, error]);
useEffect(() => {
// Initialize the service with store actions to break require cycle
const { setMessage, hideModal } = useRemoteControlStore.getState();
remoteControlService.init({
onMessage: setMessage,
onHandshake: hideModal,
});
// Start the remote control server on app launch
useRemoteControlStore.getState().startServer();
return () => {
// Stop the server on app close
useRemoteControlStore.getState().stopServer();
};
}, []);
if (!loaded && !error) {
return null;
}