|
@@ -102,7 +102,8 @@ export default function Suggest() {
|
|
|
setFastLastIndex(lastIndex)
|
|
setFastLastIndex(lastIndex)
|
|
|
setSuggestItem(array)
|
|
setSuggestItem(array)
|
|
|
setSuggestIndex(currentIndex)
|
|
setSuggestIndex(currentIndex)
|
|
|
- setScrollTop(currentIndex * rpxToPx(160))
|
|
|
|
|
|
|
+ setScrollTop(currentIndex * rpxToPx(160) + 50)
|
|
|
|
|
+ // setScrollTop(currentIndex * 100-30)
|
|
|
}
|
|
}
|
|
|
else if (pageStep == 3) {
|
|
else if (pageStep == 3) {
|
|
|
var obj = target.sleep.schedule.sleep
|
|
var obj = target.sleep.schedule.sleep
|
|
@@ -402,14 +403,33 @@ export default function Suggest() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function targetRing(start, end, isFast) {
|
|
|
|
|
|
|
+ function targetRing(start, end, isFast, isHighLight) {
|
|
|
|
|
+ var color: any = isFast ? ColorType.fast + '66' : ColorType.sleep + '66'
|
|
|
|
|
+ if (!isHighLight) {
|
|
|
|
|
+ color = isFast ? ColorType.fast + '0D' : ColorType.sleep + '0D'
|
|
|
|
|
+ }
|
|
|
return {
|
|
return {
|
|
|
- color: isFast ? ColorType.fast : ColorType.sleep,
|
|
|
|
|
|
|
+ color: color,
|
|
|
startArc: timeToArc(start),
|
|
startArc: timeToArc(start),
|
|
|
durationArc: durationToArc(start, end)
|
|
durationArc: durationToArc(start, end)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function point(isFast: boolean, isShow: boolean) {
|
|
|
|
|
+ if (!isShow) return null;
|
|
|
|
|
+
|
|
|
|
|
+ var now = new Date()
|
|
|
|
|
+ var t = suggestItems[suggestIndex].time
|
|
|
|
|
+ now.setHours(parseInt(t.split(':')[0]))
|
|
|
|
|
+ now.setMinutes(parseInt(t.split(':')[1]))
|
|
|
|
|
+
|
|
|
|
|
+ return [{
|
|
|
|
|
+ color: isFast ? ColorType.fast : ColorType.sleep,
|
|
|
|
|
+ borderColor: 'transparent',
|
|
|
|
|
+ timestamp: now.getTime()
|
|
|
|
|
+ }]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function timeToArc(time: string) {
|
|
function timeToArc(time: string) {
|
|
|
var count: number = parseInt(time.split(':')[1]) + parseInt(time.split(':')[0]) * 60
|
|
var count: number = parseInt(time.split(':')[1]) + parseInt(time.split(':')[0]) * 60
|
|
|
// count = count>720?count-720:count
|
|
// count = count>720?count-720:count
|
|
@@ -432,32 +452,64 @@ export default function Suggest() {
|
|
|
<View style={{ flexDirection: 'column', display: 'flex' }}>
|
|
<View style={{ flexDirection: 'column', display: 'flex' }}>
|
|
|
{
|
|
{
|
|
|
suggestItems.map((item: any, index: number) => {
|
|
suggestItems.map((item: any, index: number) => {
|
|
|
- return <View onClick={() => {
|
|
|
|
|
- setSuggestIndex(index)
|
|
|
|
|
- }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
|
|
|
|
|
- <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
- <View className="suggest_item_title">{item.hours} hours</View>
|
|
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
|
|
- {
|
|
|
|
|
- index == fastRecommendIndex &&
|
|
|
|
|
- <View style={{ color: '#fff' }}>Recommended</View>
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- index == fastLastIndex &&
|
|
|
|
|
- <View style={{ color: '#fff', marginLeft: 5 }}>Last</View>
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
|
|
|
|
|
+ <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
|
|
|
|
|
+ <Rings2 common={ringCommon()}
|
|
|
|
|
+ bgRing={bgRing}
|
|
|
|
|
+ targetRing={targetRing(item.time, target.fast.schedule.fast.end_time, true, suggestIndex == index)}
|
|
|
|
|
+ dotList={point(true, index == suggestIndex)}
|
|
|
|
|
+ canvasId={new Date().getTime() + index * 5} />
|
|
|
</View>
|
|
</View>
|
|
|
-
|
|
|
|
|
- <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
|
|
|
|
|
- {
|
|
|
|
|
- index == suggestIndex &&
|
|
|
|
|
- <View className="suggest_choose">
|
|
|
|
|
- <View style={{ color: ColorType.fast }}>Start fasting at {item.time}</View>
|
|
|
|
|
- <IconCheck color={ColorType.fast} width={38} height={26} />
|
|
|
|
|
|
|
+ <View>
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
+ <View className="suggest_item_title">{item.hours} hours</View>
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
|
|
+ {
|
|
|
|
|
+ index == fastRecommendIndex &&
|
|
|
|
|
+ <View style={{ color: '#fff' }}>Popular</View>
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ index == fastLastIndex &&
|
|
|
|
|
+ <View style={{ color: '#fff', marginLeft: 5 }}>Recent</View>
|
|
|
|
|
+ }
|
|
|
</View>
|
|
</View>
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
|
|
|
|
|
+ {
|
|
|
|
|
+ index == suggestIndex &&
|
|
|
|
|
+ <View className="suggest_choose">
|
|
|
|
|
+ <View style={{ color: ColorType.fast }}>Start fasting at {item.time}</View>
|
|
|
|
|
+ <IconCheck color={ColorType.fast} width={38} height={26} />
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+ </View>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
+ // return <View onClick={() => {
|
|
|
|
|
+ // setSuggestIndex(index)
|
|
|
|
|
+ // }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
|
|
|
|
|
+ // <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
+ // <View className="suggest_item_title">{item.hours} hours</View>
|
|
|
|
|
+ // <View style={{ flex: 1 }} />
|
|
|
|
|
+ // {
|
|
|
|
|
+ // index == fastRecommendIndex &&
|
|
|
|
|
+ // <View style={{ color: '#fff' }}>Popular</View>
|
|
|
|
|
+ // }
|
|
|
|
|
+ // {
|
|
|
|
|
+ // index == fastLastIndex &&
|
|
|
|
|
+ // <View style={{ color: '#fff', marginLeft: 5 }}>Recent</View>
|
|
|
|
|
+ // }
|
|
|
|
|
+ // </View>
|
|
|
|
|
+
|
|
|
|
|
+ // <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
|
|
|
|
|
+ // {
|
|
|
|
|
+ // index == suggestIndex &&
|
|
|
|
|
+ // <View className="suggest_choose">
|
|
|
|
|
+ // <View style={{ color: ColorType.fast }}>Start fasting at {item.time}</View>
|
|
|
|
|
+ // <IconCheck color={ColorType.fast} width={38} height={26} />
|
|
|
|
|
+ // </View>
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // </View>
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
@@ -466,19 +518,26 @@ export default function Suggest() {
|
|
|
return <View style={{ flex: 1, overflow: 'scroll' }}>
|
|
return <View style={{ flex: 1, overflow: 'scroll' }}>
|
|
|
{
|
|
{
|
|
|
suggestItems.map((item: any, index: number) => {
|
|
suggestItems.map((item: any, index: number) => {
|
|
|
- return <View onClick={() => {
|
|
|
|
|
- setSuggestIndex(index)
|
|
|
|
|
- }} key={index} className={index == suggestIndex ? 'item_sel2' : 'item1'}>
|
|
|
|
|
-
|
|
|
|
|
- <View className="suggest_item_title">{item.hours} hrs {item.minutes} mins</View>
|
|
|
|
|
- <View className="suggest_item_desc">{item.number} sleep cycles</View>
|
|
|
|
|
- {
|
|
|
|
|
- index == suggestIndex && <View className="suggest_choose">
|
|
|
|
|
- <View style={{ color: ColorType.sleep }}>Go to bed at {item.time}</View>
|
|
|
|
|
- <IconCheck color={ColorType.sleep} width={38} height={26} />
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
|
|
|
|
|
+ <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
|
|
|
|
|
+ <Rings2 common={ringCommon()}
|
|
|
|
|
+ bgRing={bgRing}
|
|
|
|
|
+ dotList={point(false, index == suggestIndex)}
|
|
|
|
|
+ targetRing={targetRing(item.time, target.sleep.schedule.sleep.end_time, false, suggestIndex == index)}
|
|
|
|
|
+ canvasId={new Date().getTime() + index * 5} />
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <View>
|
|
|
|
|
+
|
|
|
|
|
+ <View className="suggest_item_title">{item.hours} hrs {item.minutes} mins</View>
|
|
|
|
|
+ <View className="suggest_item_desc">{item.number} sleep cycles</View>
|
|
|
|
|
+ {
|
|
|
|
|
+ index == suggestIndex && <View className="suggest_choose">
|
|
|
|
|
+ <View style={{ color: ColorType.sleep }}>Go to bed at {item.time}</View>
|
|
|
|
|
+ <IconCheck color={ColorType.sleep} width={38} height={26} />
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ </View>
|
|
|
</View>
|
|
</View>
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|