SpecBtns.tsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import Buttons from "@/components/basic/Buttons"
  2. import { ButtonType } from "@/utils/types"
  3. import { View, Text } from "@tarojs/components"
  4. import { useState } from "react"
  5. import PostBtn from "./PostBtn"
  6. import './SpecBtns.scss'
  7. import Taro from "@tarojs/taro"
  8. import { useTranslation } from "react-i18next"
  9. import { ColorType } from "@/context/themes/color"
  10. export const rpxToPx = (n: number) => {
  11. var rate = Taro.getSystemInfoSync().windowWidth / 750;
  12. return n * rate;
  13. }
  14. export const StartFastBtn = (props: { onClick: Function, isLoading?: boolean }) => {
  15. const { t } = useTranslation()
  16. return (
  17. <PostBtn title={t('feature.track_time_duration.console.fast_start')} type={ButtonType.elevated}
  18. onClick={() => { props.onClick() }}
  19. btnStyle={{
  20. height: rpxToPx(100),
  21. borderRadius: rpxToPx(50),
  22. backgroundColor: global.fastColor ? global.fastColor : ColorType.fast,
  23. width: rpxToPx(320),
  24. // paddingLeft: 40,
  25. // paddingRight: 40,
  26. color: 'black',
  27. fontSize: 20,
  28. fontWeight: 'bold',
  29. display: 'flex',
  30. alignItems: 'center',
  31. justifyContent: 'center',
  32. // lineHeight:20
  33. }} />
  34. )
  35. }
  36. export const StartSleepBtn = (props: { onClick: Function, lowLight?: boolean, isLoading?: boolean }) => {
  37. const { t } = useTranslation()
  38. return (
  39. <PostBtn title={t('feature.track_time_duration.console.sleep_start')} type={ButtonType.elevated}
  40. onClick={() => { props.onClick() }}
  41. lowLight={props.lowLight ? props.lowLight : false}
  42. btnStyle={{
  43. height: rpxToPx(100),
  44. borderRadius: rpxToPx(50),
  45. backgroundColor: global.sleepColor ? global.sleepColor : ColorType.sleep,
  46. width: rpxToPx(320),
  47. // paddingLeft: 40,
  48. // paddingRight: 40,
  49. color: 'black',
  50. fontWeight: 'bold',
  51. fontSize: 20,
  52. display: 'flex',
  53. alignItems: 'center',
  54. justifyContent: 'center',
  55. // lineHeight:20
  56. }}
  57. />
  58. )
  59. }
  60. export const EndSleepBtn = (props: { onClick: Function, lowLight?: boolean, isLoading?: boolean }) => {
  61. const { t } = useTranslation()
  62. return (
  63. <PostBtn title={t('feature.track_time_duration.console.sleep_end')} type={ButtonType.outline}
  64. onClick={() => { props.onClick() }}
  65. lowLight={props.lowLight ? props.lowLight : false}
  66. lightLoading={true}
  67. btnStyle={{
  68. height: rpxToPx(100),
  69. borderRadius: rpxToPx(50),
  70. borderColor: global.sleepColor ? global.sleepColor : ColorType.sleep,
  71. borderWidth: 2,
  72. borderStyle: 'solid',
  73. width: rpxToPx(320),
  74. // paddingLeft: 40,
  75. // paddingRight: 40,
  76. color: global.sleepColor ? global.sleepColor : ColorType.sleep,
  77. fontWeight: 'bold',
  78. fontSize: 20,
  79. display: 'flex',
  80. alignItems: 'center',
  81. justifyContent: 'center',
  82. // lineHeight:20
  83. }}
  84. />
  85. )
  86. }
  87. export const EndFastBtn = (props: { onClick: Function, lowLight?: boolean, isLoading?: boolean }) => {
  88. const { t } = useTranslation()
  89. return (
  90. <PostBtn title={t('feature.track_time_duration.console.fast_end')} type={ButtonType.outline}
  91. onClick={() => { props.onClick() }}
  92. lowLight={props.lowLight ? props.lowLight : false}
  93. lightLoading={true}
  94. btnStyle={{
  95. height: rpxToPx(100),
  96. borderRadius: rpxToPx(50),
  97. borderColor: global.fastColor ? global.fastColor : ColorType.fast,
  98. borderWidth: 2,
  99. borderStyle: 'solid',
  100. width: rpxToPx(320),
  101. // paddingLeft: 40,
  102. // paddingRight: 40,
  103. color: global.fastColor ? global.fastColor : ColorType.fast,
  104. fontSize: 20,
  105. fontWeight: 'bold',
  106. display: 'flex',
  107. alignItems: 'center',
  108. justifyContent: 'center',
  109. // lineHeight:20
  110. }}
  111. />
  112. )
  113. }
  114. export const SetScheduleBtn = (props: { onClick: Function, title: string, isFast?: boolean, lowLight?: boolean, disable?: boolean }) => {
  115. return (
  116. <Buttons title={props.title} type={ButtonType.elevated}
  117. onClick={() => { props.onClick() }}
  118. lowLight={props.lowLight ? props.lowLight : false}
  119. disabled={props.disable}
  120. btnStyle={{
  121. height: 50,
  122. width: 300,
  123. boxSizing: 'border-box',
  124. borderRadius: 25,
  125. backgroundColor: props.isFast ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep,
  126. paddingLeft: 40,
  127. paddingRight: 40,
  128. color: 'black',
  129. fontSize: 20,
  130. fontWeight: 'bold',
  131. display: 'flex',
  132. alignItems: 'center',
  133. justifyContent: 'center',
  134. }}
  135. />
  136. )
  137. }
  138. export const ChooseScenarioBtn = (props: { onClick: Function, title: string, background: string }) => {
  139. return (
  140. <Buttons title={props.title} type={ButtonType.elevated}
  141. onClick={() => { props.onClick() }}
  142. btnStyle={{
  143. height: 50,
  144. width: 300,
  145. boxSizing: 'border-box',
  146. borderRadius: 25,
  147. backgroundColor: props.background,
  148. paddingLeft: 40,
  149. paddingRight: 40,
  150. color: 'black',
  151. fontSize: 20,
  152. fontWeight: 'bold',
  153. display: 'flex',
  154. alignItems: 'center',
  155. justifyContent: 'center',
  156. }}
  157. />
  158. )
  159. }
  160. export const RecordMetricBtn = (props: { onClick: Function, title: string, themeColor: string, isDisable?: boolean }) => {
  161. return (
  162. <PostBtn title={props.title} type={ButtonType.elevated}
  163. onClick={() => { props.onClick() }}
  164. lowLight={props.isDisable}
  165. btnStyle={{
  166. height: 42,
  167. // width: 100,
  168. boxSizing: 'border-box',
  169. borderRadius: 21,
  170. backgroundColor: props.themeColor,
  171. color: 'black',
  172. fontSize: 20,
  173. fontWeight: 'bold',
  174. display: 'flex',
  175. alignItems: 'center',
  176. justifyContent: 'center',
  177. }}
  178. />
  179. )
  180. }