moved deck stuff away from app

This commit is contained in:
Niklas 2021-01-23 01:43:53 +01:00
parent 66ae1bd758
commit 5d254ee0e1
2 changed files with 15 additions and 17 deletions

View File

@ -11,26 +11,15 @@
import React from 'react'; import React from 'react';
import {SafeAreaView, StatusBar} from 'react-native'; import {SafeAreaView, StatusBar} from 'react-native';
import Deck from './components/Deck'; import Deck from './components/Deck';
import DeckButton from './components/DeckButton';
declare const global: {HermesInternal: null | {}}; declare const global: {HermesInternal: null | {}};
const App = () => { export default function App() {
const buttons = [];
for (let i = 0; i < 21; i++) {
let text = 'btn' + i;
buttons.push(<DeckButton text={text} key={i} />);
}
return ( return (
<> <>
<StatusBar hidden={true} /> <StatusBar hidden={true} />
<SafeAreaView> <SafeAreaView>
<Deck>{buttons}</Deck> <Deck />
</SafeAreaView> </SafeAreaView>
</> </>
); );
}; }
export default App;

View File

@ -1,14 +1,23 @@
import React, {PropsWithChildren, useEffect} from 'react'; import React, {useEffect} from 'react';
import {StyleSheet, View} from 'react-native'; import {StyleSheet, View} from 'react-native';
import Orientation from 'react-native-orientation-locker'; import Orientation from 'react-native-orientation-locker';
import DeckButton from './DeckButton';
export default function Deck(props: PropsWithChildren<{}>) { export default function Deck() {
useEffect(() => { useEffect(() => {
Orientation.lockToPortrait(); Orientation.lockToPortrait();
}); });
const buttons = [];
for (let i = 0; i < 21; i++) {
let text = 'btn' + i;
buttons.push(<DeckButton text={text} key={i} />);
}
return ( return (
<> <>
<View style={style.view}>{props.children}</View> <View style={style.view}>{buttons}</View>
</> </>
); );
} }