Toolbar.js 2.3 KB

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