Toolbar.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 (
  31. <MaterialIcons
  32. name={isIOS ? 'arrow-back-ios' : 'arrow-back'}
  33. size={isIOS ? 20 : 24}
  34. color={color}/>
  35. )
  36. }
  37. export const StationBack = ({bottom = 24, scale=1.0}) => {
  38. return (
  39. // <Image
  40. // style={{
  41. // right: 0,
  42. // bottom: bottom,
  43. // width: 125.8,
  44. // height: 137.64,
  45. // position: 'absolute'
  46. // }}
  47. // source={require('../images/charge/bg-top-station.png')}/>
  48. <View
  49. style={{
  50. right: 0,
  51. bottom: bottom,
  52. width: 127.5 * scale,
  53. height: 136.67 * scale,
  54. position: 'absolute',
  55. alignItems: 'flex-end'
  56. }}>
  57. <TopChargeBackground width={127.5 * scale} height={136.67 * scale}/>
  58. </View>
  59. );
  60. }
  61. export default Toolbar = ({
  62. title,
  63. scope,
  64. showBack=true,
  65. rightIcon,
  66. onBackPress
  67. }) => {
  68. return (
  69. <View style={Styles.toolbar}>
  70. { showBack &&
  71. <BackButton onPress={onBackPress}/>
  72. }
  73. <HeaderTitle scope={scope} title={title} style={Styles.titleText}/>
  74. { rightIcon
  75. ? rightIcon()
  76. : showBack
  77. ? <View style={Styles.backIcon}>
  78. <MaterialIcons
  79. name={'arrow-back-ios'}
  80. size={16}
  81. color={'transparent'} />
  82. </View>
  83. : <></>
  84. }
  85. </View>
  86. )
  87. }
  88. export const Styles = StyleSheet.create({
  89. toolbar: {
  90. height: toolbarSize + statusHeight,
  91. paddingLeft: isIOS ? 0 : 2,
  92. paddingRight: isIOS ? 0 : 2,
  93. paddingTop: statusHeight,
  94. alignItems: 'center',
  95. flexDirection: 'row',
  96. justifyContent: 'center',
  97. backgroundColor: colorPrimaryDark
  98. },
  99. backIcon: {
  100. width: 48,
  101. height: 48,
  102. zIndex: 2,
  103. alignItems: 'center',
  104. justifyContent: 'center'
  105. },
  106. content: {
  107. flex: 1,
  108. paddingRight: 48,
  109. alignItems: 'center'
  110. },
  111. logo: {
  112. width:123.8,
  113. height: 38.95
  114. },
  115. rightIcon: {
  116. width: 22,
  117. height: 22,
  118. opacity: 0.9
  119. },
  120. iconOpacity: {
  121. opacity: 0.9
  122. },
  123. titleText: {
  124. flex: 1,
  125. color: pageTitleTint,
  126. paddingLeft: isIOS ? 8 : 16,
  127. textAlign: isIOS ? 'center' : 'left'
  128. }
  129. });