Toolbar.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import React from 'react';
  2. import { Pressable, StyleSheet, View } from 'react-native';
  3. import TopChargeBackground from '../icons/TopChargeBackground';
  4. import HeaderTitle from './HeaderTitle';
  5. export const BackButton = ({style=Styles.backIcon, color=pageTitleTint, children, onPress}) => {
  6. return (
  7. <Pressable
  8. style={({pressed }) => [
  9. (pressed && isIOS) && {
  10. opacity: 0.5
  11. },
  12. style
  13. ]}
  14. android_ripple = {rippleLessIcon}
  15. onPress={() => {
  16. if (onPress) {
  17. onPress();
  18. } else {
  19. goBack();
  20. }
  21. }}>
  22. { children
  23. ? children
  24. : <BackIcon color={color}/>
  25. }
  26. </Pressable>
  27. )
  28. }
  29. export const BackIcon = ({color=pageTitleTint}) => {
  30. return <MaterialIcons name={isIOS ? 'arrow-back-ios' : 'arrow-back'} size={24} color={color} />
  31. }
  32. export const StationBack = ({bottom = 24, scale=1.0}) => {
  33. return (
  34. // <Image
  35. // style={{
  36. // right: 0,
  37. // bottom: bottom,
  38. // width: 125.8,
  39. // height: 137.64,
  40. // position: 'absolute'
  41. // }}
  42. // source={require('../images/charge/bg-top-station.png')}/>
  43. <View
  44. style={{
  45. right: 0,
  46. bottom: bottom,
  47. width: 127.5 * scale,
  48. height: 136.67 * scale,
  49. position: 'absolute',
  50. alignItems: 'flex-end'
  51. }}>
  52. <TopChargeBackground width={127.5 * scale} height={136.67 * scale}/>
  53. </View>
  54. );
  55. }
  56. export default Toolbar = ({
  57. title,
  58. scope,
  59. showBack=true,
  60. rightIcon,
  61. onBackPress
  62. }) => {
  63. return (
  64. <View style={Styles.toolbar}>
  65. { showBack &&
  66. <BackButton onPress={onBackPress}/>
  67. }
  68. <HeaderTitle scope={scope} title={title} style={Styles.titleText}/>
  69. { rightIcon
  70. ? rightIcon()
  71. : showBack
  72. ? <View style={Styles.backIcon}>
  73. <MaterialIcons
  74. name={'arrow-back-ios'}
  75. size={16}
  76. color={'transparent'} />
  77. </View>
  78. : <></>
  79. }
  80. </View>
  81. )
  82. }
  83. export const Styles = StyleSheet.create({
  84. toolbar: {
  85. height: toolbarSize + statusHeight,
  86. paddingLeft: 2,
  87. paddingRight: 2,
  88. paddingTop: statusHeight,
  89. alignItems: 'center',
  90. flexDirection: 'row',
  91. justifyContent: 'center',
  92. backgroundColor: colorPrimaryDark
  93. },
  94. backIcon: {
  95. width: 48,
  96. height: 48,
  97. zIndex: 2,
  98. alignItems: 'center',
  99. justifyContent: 'center'
  100. },
  101. content: {
  102. flex: 1,
  103. paddingRight: 48,
  104. alignItems: 'center'
  105. },
  106. logo: {
  107. width:123.8,
  108. height: 38.95
  109. },
  110. rightIcon: {
  111. width: 22,
  112. height: 22,
  113. opacity: 0.9
  114. },
  115. iconOpacity: {
  116. opacity: 0.9
  117. },
  118. titleText: {
  119. flex: 1,
  120. color: pageTitleTint,
  121. paddingLeft: isIOS ? 8 : 16
  122. }
  123. });