Discovery.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { View, Text, Image } from "@tarojs/components";
  2. import { getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "@/features/trackTimeDuration/hooks/RingData";
  3. import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
  4. import { ColorType } from "@/context/themes/color";
  5. import { useSelector } from "react-redux";
  6. import Rings from "@/features/trackTimeDuration/components/Rings";
  7. export default function Discovery() {
  8. const user = useSelector((state: any) => state.user);
  9. function bigRing() {
  10. var common = getCommon(null, true)
  11. common.radius = 42;
  12. common.lineWidth = 9;
  13. var bgRing = getBgRing()
  14. const realRingBig: RealRing = {
  15. color: ColorType.day,
  16. startArc: 0,
  17. durationArc: 2
  18. }
  19. var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
  20. var sunSet = user.test_user ? 19 * 60 : 18 * 60
  21. var duration = sunRise - sunSet
  22. realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
  23. realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
  24. return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_big'} />
  25. }
  26. function smallRing() {
  27. var common = getCommon(null, false)
  28. common.radius = 28;
  29. common.lineWidth = 9;
  30. var bgRing = getBgRing()
  31. const realRingBig: RealRing = {
  32. color: ColorType.day,
  33. startArc: 0,
  34. durationArc: 2
  35. }
  36. var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
  37. var sunSet = user.test_user ? 19 * 60 : 18 * 60
  38. var duration = sunRise - sunSet
  39. realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
  40. realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
  41. return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_small'} />
  42. }
  43. function dayRing() {
  44. var common = getCommon(null, true)
  45. common.radius = 56;
  46. common.lineWidth = 9;
  47. var bgRing = getBgRing()
  48. const realRingBig: RealRing = {
  49. color: ColorType.day,
  50. startArc: 0,
  51. durationArc: 2
  52. }
  53. var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
  54. var sunSet = user.test_user ? 19 * 60 : 18 * 60
  55. var duration = sunRise - sunSet
  56. realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
  57. realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
  58. return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_day'} />
  59. }
  60. function rings() {
  61. return <View style={{ position: 'relative', zIndex: 1 }}>
  62. {
  63. bigRing()
  64. }
  65. {
  66. <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
  67. {
  68. smallRing()
  69. }
  70. </View>
  71. }
  72. {
  73. <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
  74. {
  75. dayRing()
  76. }
  77. </View>
  78. }
  79. </View>
  80. }
  81. return <View >
  82. <View style={{display:'flex',flexDirection:'row'}}>
  83. {
  84. rings()
  85. }
  86. </View>
  87. </View>
  88. }