Header.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 { useBoolean, useCreation } from '@umijs/hooks';
  7. import { goBack, navigate } from '../../navigation/RootNavigation';
  8. export default function Header({ title, noBack, bg, hasRight, orderId }) {
  9. const { state, setTrue, setFalse } = useBoolean(false);
  10. return (
  11. <>
  12. <StatusBar
  13. backgroundColor={bg || '#FFC21C'}
  14. style={!bg || bg === '#FFC21C' ? 'light' : 'dark'}
  15. translucent
  16. />
  17. <Appbar.Header
  18. dark={!bg || bg === '#FFC21C'}
  19. style={{
  20. zIndex: 3,
  21. elevation: 0,
  22. shadowOffset: {
  23. width: 0,
  24. height: 0,
  25. },
  26. shadowOpacity: 0,
  27. }}
  28. theme={{ colors: { primary: bg || '#FFC21C' } }}
  29. >
  30. {!noBack && <Appbar.BackAction onPress={goBack} />}
  31. <Appbar.Content
  32. title={title || '我的订单'}
  33. titleStyle={{ textAlign: 'center', fontSize: 16 }}
  34. />
  35. {!noBack && !hasRight && (
  36. <Appbar.Action
  37. icon={() => <View style={{ width: 24, height: 24 }} />}
  38. />
  39. )}
  40. {hasRight && (
  41. <Menu
  42. visible={state}
  43. onDismiss={setFalse}
  44. anchor={<Appbar.Action icon="dots-vertical" onPress={setTrue} />}
  45. >
  46. <Menu.Item
  47. onPress={() => {
  48. setFalse();
  49. navigate('ApplayCancel', {
  50. orderId,
  51. });
  52. }}
  53. title="取消订单"
  54. />
  55. </Menu>
  56. )}
  57. </Appbar.Header>
  58. </>
  59. );
  60. }