|
@@ -31,7 +31,7 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
|
|
const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
|
|
|
const limitPickerRef = useRef(null)
|
|
const limitPickerRef = useRef(null)
|
|
|
const durationPickerRef = useRef(null)
|
|
const durationPickerRef = useRef(null)
|
|
|
- const {t} = useTranslation()
|
|
|
|
|
|
|
+ const { t } = useTranslation()
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -171,11 +171,11 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var title = getTimePickerTitle(time,t)
|
|
|
|
|
|
|
+ var title = getTimePickerTitle(time, t)
|
|
|
var color = getColor(time)
|
|
var color = getColor(time)
|
|
|
if (props.isNextStep) {
|
|
if (props.isNextStep) {
|
|
|
title = t('feature.track_time_duration.console.fast_end')
|
|
title = t('feature.track_time_duration.console.fast_end')
|
|
|
- color = ColorType.fast
|
|
|
|
|
|
|
+ color = global.fastColor?global.fastColor:ColorType.fast
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -206,7 +206,7 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
if (isFast) {
|
|
if (isFast) {
|
|
|
if (time.status == 'WAIT_FOR_START') {
|
|
if (time.status == 'WAIT_FOR_START') {
|
|
|
startFast(t, fastDuration).then(res => {
|
|
startFast(t, fastDuration).then(res => {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ((res as any).current_record.scenario == 'FAST_SLEEP' &&
|
|
if ((res as any).current_record.scenario == 'FAST_SLEEP' &&
|
|
|
(res as any).current_record.status == 'ONGOING1') {
|
|
(res as any).current_record.status == 'ONGOING1') {
|
|
|
global.consoleType = 'going'
|
|
global.consoleType = 'going'
|
|
@@ -248,8 +248,8 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
<Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
|
|
<Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
- return <View className="target_view" style={{ backgroundColor: ColorType.fast+'1A', opacity: opacity }}>
|
|
|
|
|
- <Text className="target_text" style={{ color: ColorType.fast }}>距离目标结束</Text>
|
|
|
|
|
|
|
+ return <View className="target_view" style={{ backgroundColor: global.fastColor?global.fastColor:ColorType.fast + '1A', opacity: opacity }}>
|
|
|
|
|
+ <Text className="target_text" style={{ color: global.fastColor?global.fastColor:ColorType.fast }}>距离目标结束</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -260,8 +260,8 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
<Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
|
|
<Text className="target_text" style={{ color: '#FA5151' }}>超出目标结束</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
- return <View className="target_view" style={{ backgroundColor: isFast ? ColorType.fast+'1A' : ColorType.sleep+'1A', opacity: opacity }}>
|
|
|
|
|
- <Text className="target_text" style={{ color: isFast ? ColorType.fast : ColorType.sleep }}>距离目标结束</Text>
|
|
|
|
|
|
|
+ return <View className="target_view" style={{ backgroundColor: isFast ? global.fastColor?global.fastColor:ColorType.fast + '1A' : global.sleepColor?global.sleepColor:ColorType.sleep + '1A', opacity: opacity }}>
|
|
|
|
|
+ <Text className="target_text" style={{ color: isFast ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep }}>距离目标结束</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
return <View />
|
|
return <View />
|
|
@@ -341,7 +341,8 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
return `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分钟' : ''}`
|
|
return `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分钟' : ''}`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function showDurationPicker() {
|
|
|
|
|
|
|
+ function showDurationPicker(e) {
|
|
|
|
|
+ e.stopPropagation()
|
|
|
var node = <Modal children={durationPickerContent()} dismiss={() => global.showClockModal2(false, null)} confirm={() => {
|
|
var node = <Modal children={durationPickerContent()} dismiss={() => global.showClockModal2(false, null)} confirm={() => {
|
|
|
var picker = durationPickerRef.current;
|
|
var picker = durationPickerRef.current;
|
|
|
durationChange((picker as any).getConfirmData());
|
|
durationChange((picker as any).getConfirmData());
|
|
@@ -355,7 +356,7 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
|
|
|
|
|
function durationPickerContent() {
|
|
function durationPickerContent() {
|
|
|
var color = getColor(time)
|
|
var color = getColor(time)
|
|
|
- var title = getDurationTitle(time,t)
|
|
|
|
|
|
|
+ var title = getDurationTitle(time, t)
|
|
|
return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
|
|
return <View style={{ color: '#fff', backgroundColor: 'transparent' }}>
|
|
|
<PickerViews ref={durationPickerRef}
|
|
<PickerViews ref={durationPickerRef}
|
|
|
onChange={durationChange}
|
|
onChange={durationChange}
|
|
@@ -369,7 +370,9 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
|
|
|
|
|
function minus() {
|
|
function minus() {
|
|
|
if (isFast) {
|
|
if (isFast) {
|
|
|
- var count = fastDuration - 5 * 60 * 1000
|
|
|
|
|
|
|
+ var count = fastDuration - common.duration.step * 60 * 1000
|
|
|
|
|
+ count = count<3600000?3600000:count
|
|
|
|
|
+
|
|
|
setFastDuration(count)
|
|
setFastDuration(count)
|
|
|
var hour = count / 60000 / 60
|
|
var hour = count / 60000 / 60
|
|
|
var minute = count / 60000 % 60
|
|
var minute = count / 60000 % 60
|
|
@@ -377,7 +380,8 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
|
|
setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- var count = sleepDuration - 5 * 60 * 1000
|
|
|
|
|
|
|
+ var count = sleepDuration - common.duration.step * 60 * 1000
|
|
|
|
|
+ count = count<3600000?3600000:count
|
|
|
|
|
|
|
|
setSleepDuration(count)
|
|
setSleepDuration(count)
|
|
|
var hour = count / 60000 / 60
|
|
var hour = count / 60000 / 60
|
|
@@ -389,7 +393,9 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
|
|
|
|
|
function plus() {
|
|
function plus() {
|
|
|
if (isFast) {
|
|
if (isFast) {
|
|
|
- var count = fastDuration + 5 * 60 * 1000
|
|
|
|
|
|
|
+ var count = fastDuration + common.duration.step * 60 * 1000
|
|
|
|
|
+ count = count>23*3600000?23*3600000:count
|
|
|
|
|
+
|
|
|
setFastDuration(count)
|
|
setFastDuration(count)
|
|
|
var hour = count / 60000 / 60
|
|
var hour = count / 60000 / 60
|
|
|
var minute = count / 60000 % 60
|
|
var minute = count / 60000 % 60
|
|
@@ -397,7 +403,9 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
|
|
setFastPickerValue(durationIndex('00:00', `${hour > 10 ? hour : '0' + hour}:${minute > 10 ? minute : '0' + minute}`, common))
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- var count = sleepDuration + 5 * 60 * 1000
|
|
|
|
|
|
|
+ var count = sleepDuration + common.duration.step * 60 * 1000
|
|
|
|
|
+
|
|
|
|
|
+ count = count>23*3600000?23*3600000:count
|
|
|
|
|
|
|
|
setSleepDuration(count)
|
|
setSleepDuration(count)
|
|
|
var hour = count / 60000 / 60
|
|
var hour = count / 60000 / 60
|
|
@@ -445,7 +453,7 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
if (!user.isLogin) {
|
|
if (!user.isLogin) {
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column', width: '100%', alignItems: 'center' }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column', width: '100%', alignItems: 'center' }}>
|
|
|
<Text>16:00</Text>
|
|
<Text>16:00</Text>
|
|
|
- <Text style={{ color: ColorType.fast }} onClick={login}>Start Fast</Text>
|
|
|
|
|
|
|
+ <Text style={{ color: global.fastColor?global.fastColor:ColorType.fast }} onClick={login}>Start Fast</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -458,25 +466,26 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
}}>
|
|
}}>
|
|
|
{
|
|
{
|
|
|
(time.status == 'WAIT_FOR_START') && <Stepper child={
|
|
(time.status == 'WAIT_FOR_START') && <Stepper child={
|
|
|
- <Text className="stepper_text" style={{ color: ColorType.sleep, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
|
|
|
|
|
|
|
+ <Text className="stepper_text" style={{ color: global.sleepColor?global.sleepColor:ColorType.sleep, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
|
|
|
} minus={minus} plus={plus}
|
|
} minus={minus} plus={plus}
|
|
|
- themeColor={ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
|
|
|
|
|
|
|
+ themeColor={global.sleepColor?global.sleepColor:ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- time.status == 'ONGOING1' && <View>
|
|
|
|
|
- <Text className="counter_text" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : ColorType.fast, opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
|
|
|
|
|
|
|
+ (time.status == 'ONGOING1' || time.status == 'ONGOING2') &&
|
|
|
|
|
+ <View className="console_time_bg">
|
|
|
|
|
+ <View className="console_time_item">
|
|
|
|
|
+ <Text className="console_time_value" style={{ color: global.fastColor?global.fastColor:ColorType.fast, opacity: textNextStepAlpha(time) }}>{
|
|
|
|
|
+ TimeFormatter.calculateTimeDifference(time.fast.target_start_time,
|
|
|
|
|
+ time.fast.target_end_time, true)}</Text>
|
|
|
|
|
+ <Text className="console_time_desc">{t('feature.track_time_duration.console.total_duration')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <View className="console_time_item">
|
|
|
|
|
+ <Text className="console_time_value" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : global.fastColor?global.fastColor:ColorType.fast, opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
|
|
|
|
|
+ <Text className="console_time_desc">{textNextStepAlpha(time) == 1 ? t('feature.track_time_duration.console.timeout') : t('feature.track_time_duration.console.countdown_not_due')}</Text>
|
|
|
|
|
+ </View>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- {
|
|
|
|
|
- time.status == 'ONGOING2' && <View>
|
|
|
|
|
- <Text className="counter_text" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : ColorType.fast, opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- targetView()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
<View>
|
|
<View>
|
|
|
{
|
|
{
|
|
|
nextStepBtns()
|
|
nextStepBtns()
|
|
@@ -485,36 +494,42 @@ export default function Component(props: { isNextStep?: boolean }) {
|
|
|
</View>
|
|
</View>
|
|
|
</Box>
|
|
</Box>
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ function ongoing() {
|
|
|
|
|
+ if (time.status == 'ONGOING' || time.status == 'ONGOING2' || time.status == 'ONGOING3') {
|
|
|
|
|
+ var isFastData = time.scenario == 'FAST' || time.status == 'ONGOING3'
|
|
|
|
|
+ var duration = TimeFormatter.calculateTimeDifference(isFastData ? time.fast.target_start_time : time.sleep.target_start_time,
|
|
|
|
|
+ isFast ? time.fast.target_end_time : time.sleep.target_end_time, true);
|
|
|
|
|
+ return <View className="console_time_bg">
|
|
|
|
|
+ <View className="console_time_item">
|
|
|
|
|
+ <Text className="console_time_value" style={{ color: isFastData ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep, opacity: textAlpha(time) }}>{duration}</Text>
|
|
|
|
|
+ <Text className="console_time_desc">{t('feature.track_time_duration.console.total_duration')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <View className="console_time_item">
|
|
|
|
|
+ <Text className="console_time_value" style={{ color: textColor, opacity: textAlpha(time) }}>{isFastData ?
|
|
|
|
|
+ TimeFormatter.countdown(time.fast.target_end_time) :
|
|
|
|
|
+ TimeFormatter.countdown(time.sleep.target_end_time)}</Text>
|
|
|
|
|
+ <Text className="console_time_desc">{textAlpha(time) == 1 ? t('feature.track_time_duration.console.timeout') : t('feature.track_time_duration.console.countdown_not_due')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+ return <View />
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
<Box >
|
|
<Box >
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}>
|
|
|
{
|
|
{
|
|
|
- time.status == 'ONGOING' && <View>
|
|
|
|
|
- <Text className="counter_text" style={{ color: textColor, opacity: textAlpha(time) }}>{time.scenario == 'FAST' ?
|
|
|
|
|
- TimeFormatter.countdown(time.fast.target_end_time) :
|
|
|
|
|
- TimeFormatter.countdown(time.sleep.target_end_time)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ ongoing()
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
(time.status == 'ONGOING1' || time.status == 'WAIT_FOR_START') && <Stepper child={
|
|
(time.status == 'ONGOING1' || time.status == 'WAIT_FOR_START') && <Stepper child={
|
|
|
<Text className="stepper_text" style={{ color: textColor, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
|
|
<Text className="stepper_text" style={{ color: textColor, opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
|
|
|
} minus={minus} plus={plus}
|
|
} minus={minus} plus={plus}
|
|
|
- themeColor={isFast?ColorType.fast:ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- time.status == 'ONGOING2' && <View>
|
|
|
|
|
- <Text className="counter_text" style={{ color: textColor, opacity: textAlpha(time) }}>{TimeFormatter.countdown(time.sleep.target_end_time)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ themeColor={isFast ? global.fastColor?global.fastColor:ColorType.fast : global.sleepColor?global.sleepColor:ColorType.sleep} disableMinus={disableMinus()} disablePlus={disablePlus()} />
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- {
|
|
|
|
|
- time.status == 'ONGOING3' && <View>
|
|
|
|
|
- <Text className="counter_text" style={{ color: textColor, opacity: textAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ {/* {
|
|
|
targetView()
|
|
targetView()
|
|
|
- }
|
|
|
|
|
|
|
+ } */}
|
|
|
|
|
|
|
|
<View>
|
|
<View>
|
|
|
{
|
|
{
|