Add actionButton

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-09 19:35:29 +03:00
parent 5c6d26e5a0
commit f483bf4430
2 changed files with 56 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import { lightTheme, darkTheme } from './theme';
import { Meme, Tag } from './database'; import { Meme, Tag } from './database';
import NavigationContainer from './navigation'; import NavigationContainer from './navigation';
import { SettingsProvider } from './contexts/settings'; import { SettingsProvider } from './contexts/settings';
import ActionButton from './components/actionButton';
function App(): JSX.Element { function App(): JSX.Element {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
@@ -19,12 +20,11 @@ function App(): JSX.Element {
<SettingsProvider> <SettingsProvider>
<SafeAreaProvider> <SafeAreaProvider>
<StatusBar <StatusBar
barStyle={ barStyle={isDarkMode ? 'light-content' : 'dark-content'}
isDarkMode ? 'light-content' : 'dark-content'
}
backgroundColor={theme.colors.background} backgroundColor={theme.colors.background}
/> />
<NavigationContainer /> <NavigationContainer />
<ActionButton />
</SafeAreaProvider> </SafeAreaProvider>
</SettingsProvider> </SettingsProvider>
</PaperProvider> </PaperProvider>

View File

@@ -0,0 +1,53 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { FAB, Portal } from 'react-native-paper';
import { noOp } from '../constants';
const styles = StyleSheet.create({
fab: {
marginBottom: 100,
},
});
const ActionButton = () => {
const [state, setState] = React.useState(false);
return (
<Portal>
<FAB.Group
open={state}
visible
icon={state ? 'image' : 'plus'}
actions={[
{
icon: 'tag',
label: 'Tag',
onPress: () => noOp,
},
{
icon: 'note-text',
label: 'Text',
onPress: () => noOp,
},
{
icon: 'microphone',
label: 'Audio',
onPress: () => noOp,
},
{
icon: 'image-album',
label: 'Album',
onPress: () => noOp,
},
]}
onStateChange={({ open }) => setState(open)}
onPress={() => {
if (state) noOp;
}}
style={styles.fab}
/>
</Portal>
);
};
export default ActionButton;