Header.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import * as React from 'react';
  2. import { StyleSheet, View } from 'react-native';
  3. import { StatusBar } from 'expo-status-bar';
  4. import { Appbar } from 'react-native-paper';
  5. import useModel from 'flooks';
  6. import Detail from './model';
  7. import { goBack } from '../../navigation/RootNavigation';
  8. export default function Header({ noRight }) {
  9. const { heardColor } = useModel(Detail, ['heardColor']);
  10. return (
  11. <>
  12. <StatusBar backgroundColor="transparent" style="light" translucent />
  13. <View style={styles.view}>
  14. <Appbar.Header
  15. dark
  16. theme={{
  17. colors: { primary: heardColor || 'transparent' },
  18. }}
  19. style={styles.header}
  20. >
  21. <Appbar.BackAction onPress={goBack} />
  22. <Appbar.Content />
  23. {!noRight && <Appbar.Action icon="magnify" />}
  24. {!noRight && <Appbar.Action icon="share-variant" />}
  25. </Appbar.Header>
  26. </View>
  27. </>
  28. );
  29. }
  30. const styles = StyleSheet.create({
  31. header: {
  32. elevation: 0,
  33. shadowOffset: {
  34. width: 0,
  35. height: 0,
  36. },
  37. shadowOpacity: 0,
  38. },
  39. view: {
  40. // backgroundColor: 'rgb(242, 242, 242)',
  41. position: 'absolute',
  42. top: 0,
  43. left: 0,
  44. right: 0,
  45. zIndex: 2,
  46. },
  47. });