|
|
@@ -63,16 +63,38 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
|
|
|
return '天'
|
|
|
}
|
|
|
|
|
|
+ function nextStatus(){
|
|
|
+ const {status} = props.data.current
|
|
|
+ if (status == 'EXPIRED'){
|
|
|
+ return t('feature.track_time_duration.streaks.last_reset')
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return t('feature.track_time_duration.streaks.next_reset')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function getTime() {
|
|
|
- if (props.data.current.reset_ts) {
|
|
|
- var date = new Date(props.data.current.reset_ts - 1000)
|
|
|
+ const {status} = props.data.current
|
|
|
+ var ts:any=null;
|
|
|
+ switch (status){
|
|
|
+ case 'EXPIRED':
|
|
|
+ ts = props.data.current.prev_reset_ts
|
|
|
+ break;
|
|
|
+ case 'ACTIVE':
|
|
|
+ ts = props.data.current.reset_ts
|
|
|
+ break;
|
|
|
+ case 'NOT_DETERMINED':
|
|
|
+ case 'HEADS_UP':
|
|
|
+ return t('feature.track_time_duration.streaks.not_determined');
|
|
|
+ }
|
|
|
+
|
|
|
+ var date = new Date(ts)
|
|
|
var time = TimeFormatter.padZero(date.getHours()) + ':' + TimeFormatter.padZero(date.getMinutes())
|
|
|
- if (TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) == 'Today') {
|
|
|
+ if (TimeFormatter.dateDescription(ts, false) == 'Today') {
|
|
|
return 'Tonight ' + time
|
|
|
}
|
|
|
- return TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) + ' ' + time
|
|
|
- }
|
|
|
- return '时间'
|
|
|
+ return TimeFormatter.dateDescription(ts, false) + ' ' + time
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function tapDetail() {
|
|
|
@@ -131,18 +153,23 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
|
|
|
}
|
|
|
<View className='streak_next'>
|
|
|
<View className='streak_line_left' />
|
|
|
- <Text className='streak_next_text'>Next Reset</Text>
|
|
|
+ <Text className='streak_next_text'>{nextStatus()}</Text>
|
|
|
<View className='streak_line_right' />
|
|
|
</View>
|
|
|
<Text className='streak_status'>{getTime()}</Text>
|
|
|
<View className='streak_bottom'>
|
|
|
{
|
|
|
- props.data.current.reset_ts && <View className='streak_bottom_info' style={{ backgroundColor: 'red' }} onClick={(e) => {
|
|
|
+ props.data.current.status=='ACTIVE' && <View className='streak_bottom_info' style={{ backgroundColor: 'red' }}>
|
|
|
+ <Text className='streak_bottom_info_text'>{TimeFormatter.countdown(props.data.current.reset_ts)}</Text>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ props.data.current.status=='HEADS_UP' && <View className='streak_bottom_info' style={{ backgroundColor: ColorType.sleep }} onClick={(e) => {
|
|
|
if (process.env.TARO_ENV == 'weapp')
|
|
|
e.stopPropagation()
|
|
|
tapDetail()
|
|
|
}}>
|
|
|
- <Text className='streak_bottom_info_text'>{TimeFormatter.countdown(props.data.current.reset_ts)}</Text>
|
|
|
+ <Text className='streak_bottom_info_text'>{t('feature.track_time_duration.streaks.heads_up')}</Text>
|
|
|
</View>
|
|
|
}
|
|
|
|