import React, { useState } from 'react';
import {ScrollView, StyleSheet, Text, View, useWindowDimensions} from 'react-native';
import useSandbox from '../../useSandbox';
import NoSelectionEmptyState from './NoSelectionEmptyState';
import FrameContent from './layouts/FrameContent';
import { useTheme } from '../theme';
import Chip from '../components/Chip';
import Icon from '../components/Icon';
const styles = StyleSheet.create({
container: {
flex: 1,
width: '100%',
},
toolbar: {
flexGrow: 0,
flexDirection: 'row',
borderBottomWidth: 1,
padding: 8,
},
toolbarGroup: {
flexDirection: 'row',
},
itemWrapper: {
},
divider: {
alignSelf: 'center',
height: '80%',
width: 1,
marginHorizontal: 8,
}
});
const LAYOUT_OPTIONS = ['horizontal', 'vertical'];
function getNextArrayItem(arr) {
return function (curr) {
return arr[(arr.findIndex(val => val === curr) + 1) % arr.length];
};
}
function Frame() {
const context = useSandbox();
const {colors} = useTheme();
const { width } = useWindowDimensions();
const [layout, setLayout] = useState(width < 600 ? 'vertical' : 'horizontal');
if (!context) {
return (
Loading
);
}
const {activeComponent, componentPanels, toolbarGroups} = context;
if (!activeComponent) {
return ;
}
const divider =
return (
{ setLayout(getNextArrayItem(LAYOUT_OPTIONS))}}>
{divider}
{toolbarGroups.map((group, groupIndex) => (
{group.items.map(({ id, component: ToolbarItem }, itemIndex) => (
))}
{groupIndex < toolbarGroups.length - 1 && (
divider
)}
))}
);
}
export default Frame;