|
@@ -9,14 +9,14 @@ import Taro from "@tarojs/taro";
|
|
|
import { AtFloatLayout } from "taro-ui";
|
|
import { AtFloatLayout } from "taro-ui";
|
|
|
import LimitPickers from '@/components/LimitPickers';
|
|
import LimitPickers from '@/components/LimitPickers';
|
|
|
import { endFast, endSleep, startFast, startSleep } from "../actions/TrackTimeActions";
|
|
import { endFast, endSleep, startFast, startSleep } from "../actions/TrackTimeActions";
|
|
|
-import { pickerDurations } from "../hooks/Console";
|
|
|
|
|
|
|
+import { durationDatas, durationIndex, pickerDurations } from "../hooks/Console";
|
|
|
import PickerViews from "@/components/PickerViews";
|
|
import PickerViews from "@/components/PickerViews";
|
|
|
|
|
|
|
|
export default function Component() {
|
|
export default function Component() {
|
|
|
const [key, setKey] = useState('');
|
|
const [key, setKey] = useState('');
|
|
|
const [value, setValue] = useState('');
|
|
const [value, setValue] = useState('');
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
-
|
|
|
|
|
|
|
+ // const common = useSelector((state: any) => state.common);
|
|
|
const [isFast, setIsFast] = useState(true);
|
|
const [isFast, setIsFast] = useState(true);
|
|
|
const [fastValues, setFastValues] = useState<number[]>([0, 0]);
|
|
const [fastValues, setFastValues] = useState<number[]>([0, 0]);
|
|
|
const [sleepValues, setSleepValues] = useState<number[]>([0, 0]);
|
|
const [sleepValues, setSleepValues] = useState<number[]>([0, 0]);
|
|
@@ -26,8 +26,10 @@ export default function Component() {
|
|
|
const [sleepStr, setSleepStr] = useState('00:00');
|
|
const [sleepStr, setSleepStr] = useState('00:00');
|
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
const [showModal, setShowModal] = useState(false);
|
|
const [showModal, setShowModal] = useState(false);
|
|
|
- const [fastPickerValue, setFastPickerValue] = useState([0])
|
|
|
|
|
- const [sleepPickerValue, setSleepPickerValue] = useState([0])
|
|
|
|
|
|
|
+ const [fastPickerValue, setFastPickerValue] = useState([0,0])
|
|
|
|
|
+ const [sleepPickerValue, setSleepPickerValue] = useState([0,0])
|
|
|
|
|
+
|
|
|
|
|
+ // const [pickerValue, setPickerValue] = useState([0,0])
|
|
|
|
|
|
|
|
// const pickerDurations = pickerDurations();
|
|
// const pickerDurations = pickerDurations();
|
|
|
|
|
|
|
@@ -91,7 +93,8 @@ export default function Component() {
|
|
|
setFastStr(fastTime);
|
|
setFastStr(fastTime);
|
|
|
var fastCount = current_record.fast.target_end_time - current_record.fast.target_start_time
|
|
var fastCount = current_record.fast.target_end_time - current_record.fast.target_start_time
|
|
|
setFastDuration(fastCount)
|
|
setFastDuration(fastCount)
|
|
|
- setFastPickerValue([fastCount / 60000 / 5 - 12])
|
|
|
|
|
|
|
+ // setFastPickerValue(durationIndex(current_record.fast.target_start_time, current_record.fast.target_end_time, common))
|
|
|
|
|
+ // setFastPickerValue([fastCount / 60000 / 5 - 12])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (current_record.sleep) {
|
|
if (current_record.sleep) {
|
|
@@ -106,8 +109,8 @@ export default function Component() {
|
|
|
var sleepCount = current_record.sleep.target_end_time - current_record.sleep.target_start_time
|
|
var sleepCount = current_record.sleep.target_end_time - current_record.sleep.target_start_time
|
|
|
|
|
|
|
|
setSleepDuration(sleepCount)
|
|
setSleepDuration(sleepCount)
|
|
|
-
|
|
|
|
|
- setSleepPickerValue([sleepCount / 60000 / 5 - 12])
|
|
|
|
|
|
|
+ // setSleepPickerValue(durationIndex(current_record.sleep.target_start_time, current_record.sleep.target_end_time, common))
|
|
|
|
|
+ // setSleepPickerValue([sleepCount / 60000 / 5 - 12])
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -213,13 +216,41 @@ export default function Component() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function durationFormate() {
|
|
|
|
|
+ if (isFast) {
|
|
|
|
|
+ var t = fastDuration / 60000
|
|
|
|
|
+ var hour = Math.floor(t / 60)
|
|
|
|
|
+ var minute = Math.floor(t % 60)
|
|
|
|
|
+ return `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分钟' : ''}`
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var t = sleepDuration / 60000
|
|
|
|
|
+ var hour = Math.floor(t / 60)
|
|
|
|
|
+ var minute = Math.floor(t % 60)
|
|
|
|
|
+ return `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分钟' : ''}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function showDurationPicker() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
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' }}>
|
|
|
- <PickerViews onChange={() => { }} items={[pickerDurations()]} value={[12 * 15]} />
|
|
|
|
|
|
|
+ <Text>16:00</Text>
|
|
|
|
|
+ {/* <PickerViews onChange={() => { }} items={[pickerDurations()]} value={[12 * 15]} /> */}
|
|
|
{/* <TimePickers time={isFast ? fastStr : sleepStr} content="" change={handlePickerChange} isPickerView={true} /> */}
|
|
{/* <TimePickers time={isFast ? fastStr : sleepStr} content="" change={handlePickerChange} isPickerView={true} /> */}
|
|
|
<Text style={{ color: '#AAFF00' }} onClick={login}>Start Fast</Text>
|
|
<Text style={{ color: '#AAFF00' }} onClick={login}>Start Fast</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ const [isOpenDurationPicker, setIsOpenDurationPicker] = useState(false)
|
|
|
|
|
+ function durationPickerContent() {
|
|
|
|
|
+ return <View style={{ color: '#000' }}>
|
|
|
|
|
+ {/* <PickerViews onChange={durationChange} items={durationDatas(common)} value={isFast?fastPickerValue:sleepPickerValue} height={200} showBtns={true} onCancel={() => { setIsOpenDurationPicker(false) }} /> */}
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', width: '100%', alignItems: 'center' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', width: '100%', alignItems: 'center' }}>
|
|
|
{
|
|
{
|
|
@@ -237,7 +268,8 @@ export default function Component() {
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
(value == 'ONGOING1' || value == 'WAIT_FOR_START') &&
|
|
(value == 'ONGOING1' || value == 'WAIT_FOR_START') &&
|
|
|
- <PickerViews onChange={durationChange} items={[pickerDurations()]} value={isFast ? [fastPickerValue] : [sleepPickerValue]} />
|
|
|
|
|
|
|
+ <Text onClick={showDurationPicker}>{durationFormate()}</Text>
|
|
|
|
|
+ // <PickerViews onChange={durationChange} items={[pickerDurations()]} value={isFast ? [fastPickerValue] : [sleepPickerValue]} />
|
|
|
// <TimePickers time={isFast ? fastStr : sleepStr} content="" change={handlePickerChange} isPickerView={true} />
|
|
// <TimePickers time={isFast ? fastStr : sleepStr} content="" change={handlePickerChange} isPickerView={true} />
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
@@ -277,6 +309,16 @@ export default function Component() {
|
|
|
}
|
|
}
|
|
|
</AtFloatLayout>
|
|
</AtFloatLayout>
|
|
|
}
|
|
}
|
|
|
|
|
+ <AtFloatLayout
|
|
|
|
|
+ isOpened={isOpenDurationPicker}
|
|
|
|
|
+ onClose={() => {
|
|
|
|
|
+ setIsOpenDurationPicker(false)
|
|
|
|
|
+ }}
|
|
|
|
|
+ title="">
|
|
|
|
|
+ {
|
|
|
|
|
+ durationPickerContent()
|
|
|
|
|
+ }
|
|
|
|
|
+ </AtFloatLayout>
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
)
|
|
)
|