|
@@ -32,6 +32,7 @@ export default function Component() {
|
|
|
const pickerRef = useRef<any>(null);
|
|
const pickerRef = useRef<any>(null);
|
|
|
// const [count,setCount] = useState(0)
|
|
// const [count,setCount] = useState(0)
|
|
|
const [beginChange, setBeginChange] = useState(true)
|
|
const [beginChange, setBeginChange] = useState(true)
|
|
|
|
|
+ const [operateType, setOperateType] = useState(0)
|
|
|
|
|
|
|
|
var scheduleObj: { start_time: any; end_time: any; };
|
|
var scheduleObj: { start_time: any; end_time: any; };
|
|
|
if (scenario.name == 'FAST') {
|
|
if (scenario.name == 'FAST') {
|
|
@@ -225,11 +226,28 @@ export default function Component() {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ global.startDuration = (type) => {
|
|
|
|
|
+ setOperateType(type)
|
|
|
|
|
+ console.log(type)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
global.updateDuration = (start, end) => {
|
|
global.updateDuration = (start, end) => {
|
|
|
var startCount = parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])
|
|
var startCount = parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])
|
|
|
var endCount = parseInt(end.split(':')[0]) * 60 + parseInt(end.split(':')[1])
|
|
var endCount = parseInt(end.split(':')[0]) * 60 + parseInt(end.split(':')[1])
|
|
|
- if (startCount % 15 == 0 || endCount % 15 == 0) {
|
|
|
|
|
- Taro.vibrateShort()
|
|
|
|
|
|
|
+ if (operateType == 1 && startCount % 15 == 0) {
|
|
|
|
|
+ Taro.vibrateShort({
|
|
|
|
|
+ type: 'heavy',
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (operateType == 2 && endCount % 15 == 0) {
|
|
|
|
|
+ Taro.vibrateShort({
|
|
|
|
|
+ type: 'heavy',
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (operateType == 3 && (startCount % 15 == 0 || endCount % 15 == 0)) {
|
|
|
|
|
+ Taro.vibrateShort({
|
|
|
|
|
+ type: 'heavy',
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
setStartTime(start)
|
|
setStartTime(start)
|
|
@@ -240,6 +258,11 @@ export default function Component() {
|
|
|
saveTempCache(start, end)
|
|
saveTempCache(start, end)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ global.endDuration = () => {
|
|
|
|
|
+ setOperateType(0)
|
|
|
|
|
+ console.log(0)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function layoutContent() {
|
|
function layoutContent() {
|
|
|
return <PickerViews ref={pickerRef} onChange={durationChange} items={durationDatas(common)} value={pickerValue} height={200} showBtns={true} onCancel={() => { setIsOpen(false) }} />
|
|
return <PickerViews ref={pickerRef} onChange={durationChange} items={durationDatas(common)} value={pickerValue} height={200} showBtns={true} onCancel={() => { setIsOpen(false) }} />
|
|
|
}
|
|
}
|
|
@@ -257,28 +280,33 @@ export default function Component() {
|
|
|
|
|
|
|
|
<View className="box">
|
|
<View className="box">
|
|
|
<View className="header">
|
|
<View className="header">
|
|
|
- <View className="item1" onClick={() => {
|
|
|
|
|
|
|
+ <View className="item1" style={{ opacity: operateType == 1 || operateType == 3 ? 1 : 0.4 }} onClick={() => {
|
|
|
setChooseStart(true)
|
|
setChooseStart(true)
|
|
|
setIsTimeOpen(true)
|
|
setIsTimeOpen(true)
|
|
|
}}>
|
|
}}>
|
|
|
- <Text>{scenario.step == 'fast' ? 'Fast starts\n' + startTime : 'Sleep starts\n' + startTime}</Text>
|
|
|
|
|
|
|
+ <Text className="item_title">{scenario.step == 'fast' ? 'Fast starts' : 'Sleep starts'}</Text>
|
|
|
|
|
+ <Text className="item_text">{startTime}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
- <View className="item1" onClick={() => {
|
|
|
|
|
|
|
+ <View className="item1" style={{ opacity: operateType == 2 || operateType == 3 ? 1 : 0.4 }} onClick={() => {
|
|
|
setChooseStart(false)
|
|
setChooseStart(false)
|
|
|
setIsTimeOpen(true)
|
|
setIsTimeOpen(true)
|
|
|
}}>
|
|
}}>
|
|
|
- <Text>{scenario.step == 'fast' ? 'Fast ends\n' + endTime : 'Sleep ends\n' + endTime}</Text>
|
|
|
|
|
|
|
+ <Text className="item_title">{scenario.step == 'fast' ? 'Fast ends' : 'Sleep ends'}</Text>
|
|
|
|
|
+ <Text className="item_text">{endTime}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
<View style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
<View style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
<Dial ref={canvasRef} />
|
|
<Dial ref={canvasRef} />
|
|
|
</View>
|
|
</View>
|
|
|
- <Text className="duration" onClick={() => { setIsOpen(true) }}>{hours > 0 ? hours + ' hours ' : ''}{minutes > 0 ? minutes + ' minutes' : ''}</Text>
|
|
|
|
|
|
|
+ <Text className="duration" style={{ opacity: operateType == 1 || operateType == 2 ? 1 : 0.4 }} onClick={() => { setIsOpen(true) }}>{hours > 0 ? hours + ' hours ' : ''}{minutes > 0 ? minutes + ' minutes' : ''}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
<Footer>
|
|
<Footer>
|
|
|
- <SetScheduleBtn title={scenario.step == 'fast' ? 'Set fast schedule' : 'Set sleep schedule'} isFast={scenario.step == 'fast'} onClick={() => start()} />
|
|
|
|
|
|
|
+ <SetScheduleBtn title={scenario.step == 'fast' ? 'Set fast schedule' : 'Set sleep schedule'}
|
|
|
|
|
+ lowLight={operateType != 0}
|
|
|
|
|
+ isFast={scenario.step == 'fast'}
|
|
|
|
|
+ onClick={() => start()} />
|
|
|
</Footer>
|
|
</Footer>
|
|
|
{
|
|
{
|
|
|
isOpen && <Modal children={layoutContent()} dismiss={() => setIsOpen(false)} confirm={() => {
|
|
isOpen && <Modal children={layoutContent()} dismiss={() => setIsOpen(false)} confirm={() => {
|