import React, { useState, useMemo } from 'react'; import { View, StyleSheet, Button, Text } from 'react-native'; import { WorkspaceView } from './WorkspaceView'; import { WorkspaceFactory } from '@adaptive-desktop/adaptive-workspace'; import { idGenerator } from '../../utils/idGenerator'; import { loadDesktopSnapshot } from '@adaptive-desktop/adaptive-workspace'; const DEVICE_PRESETS = [ { name: 'Ultrawide', bounds: { width: 2560, height: 1080 }, orientations: ['landscape'], }, { name: 'Laptop', bounds: { width: 1440, height: 900 }, orientations: ['landscape'], }, { name: 'Tablet', bounds: { width: 834, height: 1112 }, orientations: ['portrait', 'landscape'], }, { name: 'Phone', bounds: { width: 375, height: 812 }, orientations: ['portrait', 'landscape'], }, ]; export const WorkspaceView_DevicePresets = () => { const [deviceIdx, setDeviceIdx] = useState(0); const [orientation, setOrientation] = useState('landscape'); const device = DEVICE_PRESETS[deviceIdx]; const bounds = orientation === 'portrait' ? { width: device.bounds.height, height: device.bounds.width } : device.bounds; // Memoize workspace creation from snapshot const workspace = useMemo(() => { const factory = new WorkspaceFactory(idGenerator); const snapshot = loadDesktopSnapshot(); return factory.fromSnapshot(snapshot, { ...bounds, x: 0, y: 0 }); }, [deviceIdx, orientation]); return ( {DEVICE_PRESETS.map((d, i) => (