SiteLabelView.js 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * 站点标签组件
  3. * @邠心vbe on 2023/11/30
  4. */
  5. import React from 'react';
  6. import { StyleSheet } from 'react-native';
  7. import TextView from './TextView';
  8. const SiteLabelView = ({
  9. label,
  10. color = textLight,
  11. version=1,
  12. background = colorPrimary
  13. }) => {
  14. if (label) {
  15. return (
  16. <TextView
  17. style={[
  18. version == 2
  19. ? style.textV2
  20. : style.textV1,
  21. {
  22. color: color || textLight,
  23. backgroundColor: background || colorPrimary
  24. }
  25. ]}>
  26. {label}
  27. </TextView>
  28. )
  29. } else {
  30. return <></>
  31. }
  32. };
  33. export default SiteLabelView;
  34. const style = StyleSheet.create({
  35. textV1: {
  36. height: 22,
  37. fontSize: 12,
  38. marginRight: 5,
  39. marginBottom: 5,
  40. borderRadius: 3,
  41. ...$padding(0, 6)
  42. },
  43. textV2: {
  44. height: 20,
  45. fontSize: 8,
  46. marginRight: 6,
  47. borderRadius: 30,
  48. ...$padding(0, 10)
  49. }
  50. })