Header.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* eslint-disable react/style-prop-object */
  2. import * as React from 'react';
  3. import { View } from 'react-native';
  4. import { StatusBar } from 'expo-status-bar';
  5. import { Appbar, Menu } from 'react-native-paper';
  6. import { useTranslation } from 'react-i18next';
  7. import { useBoolean, useCreation } from '@umijs/hooks';
  8. import { goBack, navigate } from '../../navigation/RootNavigation';
  9. export default function Header({ title, noBack, bg, hasRight, orderId }) {
  10. const { t } = useTranslation();
  11. const { state, setTrue, setFalse } = useBoolean(false);
  12. return (
  13. <>
  14. <StatusBar
  15. backgroundColor={bg || '#FFC21C'}
  16. style={!bg || bg === '#FFC21C' ? 'light' : 'dark'}
  17. translucent
  18. />
  19. <Appbar.Header
  20. dark={!bg || bg === '#FFC21C'}
  21. style={{
  22. zIndex: 3,
  23. elevation: 0,
  24. shadowOffset: {
  25. width: 0,
  26. height: 0,
  27. },
  28. shadowOpacity: 0,
  29. }}
  30. theme={{ colors: { primary: bg || '#FFC21C' } }}
  31. >
  32. {!noBack && <Appbar.BackAction onPress={goBack} />}
  33. <Appbar.Content
  34. title={title || t('wo-de-ding-dan')}
  35. titleStyle={{ textAlign: 'center', fontSize: 16 }}
  36. />
  37. {!noBack && !hasRight && (
  38. <Appbar.Action
  39. icon={() => <View style={{ width: 24, height: 24 }} />}
  40. />
  41. )}
  42. {hasRight && (
  43. <Menu
  44. visible={state}
  45. onDismiss={setFalse}
  46. anchor={<Appbar.Action icon="dots-vertical" onPress={setTrue} />}
  47. >
  48. <Menu.Item
  49. onPress={() => {
  50. setFalse();
  51. navigate('ApplayCancel', {
  52. orderId,
  53. });
  54. }}
  55. title={t('qu-xiao-ding-dan')}
  56. />
  57. </Menu>
  58. )}
  59. </Appbar.Header>
  60. </>
  61. );
  62. }