|
@@ -14,6 +14,7 @@ import Footer from "@/components/layout/Footer";
|
|
|
import { IconCheck } from "@/components/basic/Icons";
|
|
import { IconCheck } from "@/components/basic/Icons";
|
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
+import Taro from "@tarojs/taro";
|
|
|
|
|
|
|
|
let ScrollViewRN
|
|
let ScrollViewRN
|
|
|
if (process.env.TARO_ENV === 'rn') {
|
|
if (process.env.TARO_ENV === 'rn') {
|
|
@@ -44,6 +45,7 @@ export default function Suggest() {
|
|
|
const [scrollTop, setScrollTop] = useState(0)
|
|
const [scrollTop, setScrollTop] = useState(0)
|
|
|
const [fastRecommendIndex, setFastRecommendIndex] = useState(-1)
|
|
const [fastRecommendIndex, setFastRecommendIndex] = useState(-1)
|
|
|
const [fastLastIndex, setFastLastIndex] = useState(-1)
|
|
const [fastLastIndex, setFastLastIndex] = useState(-1)
|
|
|
|
|
+ const [scrollHeight, setScrollHeight] = useState(0)
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const scrollViewRef = useRef(null);
|
|
const scrollViewRef = useRef(null);
|
|
|
|
|
|
|
@@ -111,11 +113,18 @@ export default function Suggest() {
|
|
|
setFastLastIndex(lastIndex)
|
|
setFastLastIndex(lastIndex)
|
|
|
setSuggestItem(array)
|
|
setSuggestItem(array)
|
|
|
setSuggestIndex(currentIndex)
|
|
setSuggestIndex(currentIndex)
|
|
|
- setScrollTop(currentIndex * rpxToPx(244) + 50)
|
|
|
|
|
- if (process.env.TARO_ENV=='rn'){
|
|
|
|
|
- setTimeout(()=>{
|
|
|
|
|
- (scrollViewRef.current as any).scrollTo({x:0,y:currentIndex * rpxToPx(244)+20,animated:true})
|
|
|
|
|
- },500)
|
|
|
|
|
|
|
+ setScrollTop(currentIndex * rpxToPx(264) - 30)
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ (scrollViewRef.current as any).scrollTo({ x: 0, y: currentIndex * rpxToPx(264) - 30, animated: true })
|
|
|
|
|
+ }, 500)
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ Taro.createSelectorQuery().select('#myScrollView').boundingClientRect((rect) => {
|
|
|
|
|
+ setScrollHeight(Taro.getSystemInfoSync().windowHeight-(rect as any).top-rpxToPx(188)-40);
|
|
|
|
|
+ }).exec()
|
|
|
|
|
+ }, 100)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else if (pageStep == 3) {
|
|
else if (pageStep == 3) {
|
|
@@ -293,7 +302,7 @@ export default function Suggest() {
|
|
|
|
|
|
|
|
var minutes: string[] = []
|
|
var minutes: string[] = []
|
|
|
for (let i = min; i <= max; i += step) {
|
|
for (let i = min; i <= max; i += step) {
|
|
|
- minutes.push(i + ' '+t('feature.suggest.mins'))
|
|
|
|
|
|
|
+ minutes.push(i + ' ' + t('feature.suggest.mins'))
|
|
|
}
|
|
}
|
|
|
return [minutes]
|
|
return [minutes]
|
|
|
}
|
|
}
|
|
@@ -549,7 +558,7 @@ export default function Suggest() {
|
|
|
|
|
|
|
|
function suggestList() {
|
|
function suggestList() {
|
|
|
if (pageStep == 1 && process.env.TARO_ENV === 'weapp') {
|
|
if (pageStep == 1 && process.env.TARO_ENV === 'weapp') {
|
|
|
- return <ScrollView scrollY style={{ height: 450 }} scrollTop={scrollTop}>
|
|
|
|
|
|
|
+ return <ScrollView scrollY style={{ height: scrollHeight }} id="myScrollView" scrollTop={scrollTop}>
|
|
|
{
|
|
{
|
|
|
scrollContent()
|
|
scrollContent()
|
|
|
}
|
|
}
|
|
@@ -577,8 +586,8 @@ export default function Suggest() {
|
|
|
</View>
|
|
</View>
|
|
|
<View>
|
|
<View>
|
|
|
|
|
|
|
|
- <View className="suggest_item_title">{item.hours}{t('feature.suggest.hours2')}{item.minutes>0&&item.minutes+t('feature.suggest.minute')}</View>
|
|
|
|
|
- <View className="suggest_item_desc">{t('feature.suggest.cycles',{times:item.number})}</View>
|
|
|
|
|
|
|
+ <View className="suggest_item_title">{item.hours}{t('feature.suggest.hours2')}{item.minutes > 0 && item.minutes + t('feature.suggest.minute')}</View>
|
|
|
|
|
+ <View className="suggest_item_desc">{t('feature.suggest.cycles', { times: item.number })}</View>
|
|
|
{
|
|
{
|
|
|
index == suggestIndex && <View className="suggest_choose">
|
|
index == suggestIndex && <View className="suggest_choose">
|
|
|
<View className="suggest_choose_text" style={{ color: ColorType.sleep }}>{t('feature.suggest.go_to_bed_at', { time: item.time })}</View>
|
|
<View className="suggest_choose_text" style={{ color: ColorType.sleep }}>{t('feature.suggest.go_to_bed_at', { time: item.time })}</View>
|
|
@@ -605,7 +614,7 @@ export default function Suggest() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function content() {
|
|
function content() {
|
|
|
- return <View style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
|
|
+ return <View style={{ flex: 1, display: 'flex', flexDirection: 'column', backgroundColor: 'red' }}>
|
|
|
{
|
|
{
|
|
|
(pageStep == 0 || pageStep == 2) && timePicker()
|
|
(pageStep == 0 || pageStep == 2) && timePicker()
|
|
|
}
|
|
}
|
|
@@ -613,7 +622,7 @@ export default function Suggest() {
|
|
|
(pageStep == 1 || pageStep == 3) && suggestList()
|
|
(pageStep == 1 || pageStep == 3) && suggestList()
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- pageStep==3 && <Text className="suggest_footer_note">{t('feature.suggest.sleep_suggest_footer')}</Text>
|
|
|
|
|
|
|
+ pageStep == 3 && <Text className="suggest_footer_note">{t('feature.suggest.sleep_suggest_footer')}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
pageStep == 2 && fallSleepPicker()
|
|
pageStep == 2 && fallSleepPicker()
|
|
@@ -624,7 +633,7 @@ export default function Suggest() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function btnText(){
|
|
|
|
|
|
|
+ function btnText() {
|
|
|
// if (pageStep == 3){
|
|
// if (pageStep == 3){
|
|
|
// return t('feature.suggest.done')
|
|
// return t('feature.suggest.done')
|
|
|
// }
|
|
// }
|
|
@@ -635,7 +644,7 @@ export default function Suggest() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
|
|
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column', flex: 1, height: process.env.TARO_ENV == 'weapp' ? '100vh' : 'auto' }}>
|
|
|
<Text className="target_title">{suggestTitle()}</Text>
|
|
<Text className="target_title">{suggestTitle()}</Text>
|
|
|
<Text className="target_desc">{suggestDesc()}</Text>
|
|
<Text className="target_desc">{suggestDesc()}</Text>
|
|
|
{
|
|
{
|