sticky_date_list.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { MainColorType } from "@/context/themes/color";
  2. import { rpxToPx } from "@/utils/tools";
  3. import { ScrollView, View } from "@tarojs/components";
  4. export default function StickyDateList(props: {
  5. header?: any, children: any, footer?: any,
  6. onRefresherRefresh: any,
  7. isPulling: boolean,
  8. loadMore?: any,
  9. onScroll: any,
  10. showDate: boolean,
  11. date: string,
  12. disable?: boolean,
  13. }) {
  14. function headerDate() {
  15. if (global.language == 'en') {
  16. return props.date.substring(0, 4)
  17. }
  18. return props.date.substring(0, 5)
  19. }
  20. return <View style={{ position: 'relative' }}>
  21. <View className="h26" style={{
  22. position: 'absolute',
  23. left: 0,
  24. top: 0,
  25. right: 0,
  26. height: props.showDate ? rpxToPx(84) : 0,
  27. backgroundColor: '#f5f5f5',
  28. paddingLeft: rpxToPx(40),
  29. display: 'flex',
  30. boxSizing: 'border-box',
  31. flexDirection: 'row',
  32. alignItems: 'center',
  33. zIndex: 1,
  34. opacity: props.showDate ? 1 : 0,
  35. color: MainColorType.g01
  36. }}>{headerDate()}
  37. <View className="border_header_line" />
  38. <View className="border_footer_line" />
  39. </View>
  40. <ScrollView style='height:100vh'
  41. enableBackToTop
  42. scrollY={!props.disable}
  43. refresherEnabled
  44. upperThreshold={70}
  45. lowerThreshold={80}
  46. refresherBackground={MainColorType.g05}
  47. onRefresherRefresh={props.onRefresherRefresh}
  48. refresherTriggered={props.isPulling}
  49. onScroll={props.onScroll}
  50. onScrollToLower={props.loadMore}
  51. >
  52. {
  53. props.header
  54. }
  55. {
  56. props.children
  57. }
  58. {
  59. props.footer
  60. }
  61. </ScrollView>
  62. </View>
  63. }