PinMessage.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React, { useState } from 'react';
  2. import { StyleSheet, Text, View } from 'react-native';
  3. import { Marquee } from '@animatereactnative/marquee';
  4. import { ElevationObject } from '../../../components/Button';
  5. import TextView from '../../../components/TextView';
  6. const PinMessage = ({
  7. visible=false,
  8. title,
  9. message
  10. }) => {
  11. const [expand, setExpand] = useState(false)
  12. if (visible)
  13. return (
  14. <View style={styles.pinMessageCard}>
  15. <Marquee style={$padding(12, 16, 4)} spacing={$vw(80)} speed={0.8}>
  16. <Text style={styles.textTitle}>{title}</Text>
  17. </Marquee>
  18. { expand &&
  19. <TextView style={styles.textMessage}>{message}</TextView>
  20. }
  21. <MaterialIcons
  22. name={expand ? "keyboard-arrow-up" : "keyboard-arrow-down"}
  23. size={26}
  24. color={colorCancel}
  25. onPress={() => setExpand(!expand)}/>
  26. </View>
  27. );
  28. else
  29. return <></>
  30. }
  31. export default PinMessage;
  32. const styles = StyleSheet.create({
  33. pinMessageCard: {
  34. top: 180,
  35. left: 16,
  36. right: 16,
  37. zIndex: 10,
  38. overflow: "hidden",
  39. borderRadius: 6,
  40. alignItems: "center",
  41. position: 'absolute',
  42. backgroundColor: colorLight,
  43. ...ElevationObject(3)
  44. },
  45. textTitle: {
  46. color: textPrimary,
  47. fontSize: 16,
  48. fontWeight: "bold"
  49. },
  50. textMessage: {
  51. color: textSecondary,
  52. padding: 8,
  53. fontSize: 14,
  54. marginBottom: -20
  55. }
  56. })