|
|
@@ -11,10 +11,14 @@ import NewDurationPicker from '../base/new_durationpicker';
|
|
|
import NewButton, { NewButtonType } from '../base/new_button';
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
+let isYesterdayTarget = false
|
|
|
export default function PostMomentTime(props: {
|
|
|
title?: string,
|
|
|
time: string,
|
|
|
- onChange: any, dismiss: any
|
|
|
+ isTemp: boolean,
|
|
|
+ onChange: any,
|
|
|
+ moment?: any,
|
|
|
+ dismiss: any
|
|
|
}) {
|
|
|
const health = useSelector((state: any) => state.health);
|
|
|
const [showDurationPicker, setShowDurationPicker] = useState(false)
|
|
|
@@ -61,7 +65,7 @@ export default function PostMomentTime(props: {
|
|
|
return strTime + 'Today';
|
|
|
} else if (dt.isSame(yesterday, 'day')) {
|
|
|
return strTime + 'Yesterday';
|
|
|
- }else if (dt.isSame(tomorrow, 'day')) {
|
|
|
+ } else if (dt.isSame(tomorrow, 'day')) {
|
|
|
return strTime + 'Tomorrow';
|
|
|
} else {
|
|
|
return strTime + dt.format('MM-DD');
|
|
|
@@ -101,6 +105,21 @@ export default function PostMomentTime(props: {
|
|
|
</View>
|
|
|
</View>
|
|
|
}
|
|
|
+
|
|
|
+ function scheduleTime() {
|
|
|
+ if (props.moment) {
|
|
|
+ var timestamp = props.moment.target.timestamp
|
|
|
+ var time = parseInt(dayjs(timestamp).format('HHmm'))
|
|
|
+ var now = parseInt(dayjs().format('HHmm'))
|
|
|
+ if (time > now) {
|
|
|
+ isYesterdayTarget = true
|
|
|
+ return `Scheduled for ${dayjs(timestamp).format('HH:mm')} yesterday`
|
|
|
+ }
|
|
|
+ isYesterdayTarget = false
|
|
|
+ return `Scheduled for ${dayjs(timestamp).format('HH:mm')} today`
|
|
|
+ }
|
|
|
+ return 'Scheduled for xxx today'
|
|
|
+ }
|
|
|
/*
|
|
|
type={expandIndex == index ? NewButtonType.alpha : NewButtonType.gray}
|
|
|
color={iFast ? MainColorType.fast : MainColorType.sleep}
|
|
|
@@ -111,7 +130,8 @@ export default function PostMomentTime(props: {
|
|
|
confirm={() => {
|
|
|
props.onChange({
|
|
|
time: time,
|
|
|
- duration: minutes
|
|
|
+ duration: minutes,
|
|
|
+ isYesterday: isYesterday
|
|
|
})
|
|
|
}}
|
|
|
themeColor={getThemeColor(health.mode)}>
|
|
|
@@ -149,9 +169,12 @@ export default function PostMomentTime(props: {
|
|
|
}} color={getThemeColor(health.mode)} />
|
|
|
}
|
|
|
{
|
|
|
- !showDurationPicker && <View className='picker_time_card_footer'>
|
|
|
+ !props.isTemp && !showDurationPicker && <View className='picker_time_card_footer' onClick={() => {
|
|
|
+ setIsYesterday(isYesterdayTarget)
|
|
|
+ setTime(dayjs(props.moment.target.timestamp).format('HH:mm'))
|
|
|
+ }}>
|
|
|
<IconCalendar width={rpxToPx(24)} color='#5C7099' />
|
|
|
- <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for xxx today</Text>
|
|
|
+ <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>{scheduleTime()}</Text>
|
|
|
</View>
|
|
|
}
|
|
|
|