Leon 2 anni fa
parent
commit
b1b9ef220c

BIN
src/assets/images/arrow4.png


+ 7 - 5
src/components/input/Slider.scss

@@ -103,8 +103,8 @@
 }
 
 .slider-arrow {
-    width: 48px;
-    height: 48px;
+    width: 56px;
+    height: 56px;
 }
 
 .tooltip_bg {
@@ -127,14 +127,15 @@
     padding-bottom: 20px;
     box-sizing: border-box;
     border-radius: 16px;
-    background-color: #787878;
+    background-color: $tipBgColor;
     display: flex;
     flex-direction: column;
 }
 
 .tooltip_title {
-    font-size: 28px;
+    font-size: 32px;
     line-height: 40px;
+    letter-spacing: 0.05em;
     color: #fff;
     font-weight: bold;
 }
@@ -142,6 +143,7 @@
 .tooltip_desc {
     font-size: 24px;
     line-height: 40px;
+    letter-spacing: 0.05em;
     color: #fff;
     opacity: 0.6;
 }
@@ -152,7 +154,7 @@
     margin-top: -2px;
     border-left: 25px solid transparent;
     border-right: 25px solid transparent;
-    border-top: 20px solid #787878;
+    border-top: 20px solid $tipBgColor;
 
 }
 

+ 33 - 32
src/components/input/Slider.tsx

@@ -49,7 +49,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             var data = calculateNumber(brightnessValue)
             if (lastValue != data && data == 5) {
                 Taro.vibrateShort({
-                    type: 'heavy'
+                    type: 'light'
                 })
             }
             lastValue = data
@@ -61,6 +61,9 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
     const handleTouchEnd = () => {
 
         setIsSliding(false);
+        Taro.vibrateShort({
+            type: 'heavy'
+        })
         if (props.onChanged) {
 
             var obj = common.food_scales.filter((item: any) => {
@@ -68,8 +71,8 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             })
 
             Taro.showModal({
-                title: props.isPreMeal ? t('feature.food.pre_meal_confirm_title') : t('feature.food.post_meal_confirm_title'),
-                content: value + '分 - ' + obj[0].description ?? '暂无描述',
+                title: props.isPreMeal ? t('feature.food.pre_meal_confirm_title', { score: value, desc: value < 5 ? '饿' : '饱' }) : t('feature.food.post_meal_confirm_title', { score: value, desc: value < 5 ? '饿' : '饱' }),
+                content: obj[0].description ? obj[0].description : '暂无描述',
                 success: function (res) {
                     if (res.confirm) {
                         props.onChanged && props.onChanged(value);
@@ -90,32 +93,28 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             })
         }
         if (props.edit) {
-            if (startX != 0 && value != 0) {
-                // 松手后,滑块动画移动到最左边
-                Taro.vibrateShort({
-                    type: 'heavy'
-                })
-                // Taro.showToast({
-                //     icon: 'none',
-                //     title: '请先上传!'
-                // })
-                Taro.showModal({
-                    title: '提示',
-                    content: t('feature.food.pre_meal_enforce_order_alert'),
-                    showCancel: false,
-                    confirmText: '好的',
-                    success: function (res) {
-                        if (res.confirm) {
-                            setShowArrow(true)
-                            setStartX(0);
-                            setBrightness(0)
-                            setValue(0)
-                        }
+            // 松手后,滑块动画移动到最左边
+
+            // Taro.showToast({
+            //     icon: 'none',
+            //     title: '请先上传!'
+            // })
+            Taro.showModal({
+                title: '提示',
+                content: t('feature.food.pre_meal_enforce_order_alert'),
+                showCancel: false,
+                confirmText: '好的',
+                success: function (res) {
+                    if (res.confirm) {
+                        setShowArrow(true)
+                        setStartX(0);
+                        setBrightness(0)
+                        setValue(0)
                     }
-                })
-                // const animationId = requestAnimationFrame(moveToStart);
-                // return () => cancelAnimationFrame(animationId);
-            }
+                }
+            })
+            // const animationId = requestAnimationFrame(moveToStart);
+            // return () => cancelAnimationFrame(animationId);
         }
     };
 
@@ -187,7 +186,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             onTouchStart={handleTouchStart}
             onTouchMove={handleTouchMove}
             onTouchEnd={handleTouchEnd}>
-            <View className='slider-tip-bg' style={{ width: (100 - brightness) * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx(28) }}>
+            <View className='slider-tip-bg' style={{ width: (100 - brightness) * 0.01 * rpxToPx(sliderWidth) - brightness * 0.01 * rpxToPx(120) + brightness * 0.01 * rpxToPx(28) }}>
                 <Text className={value < 5 ? 'slider-tip-title' : 'slider-tip-title-post'}>{value < 5 ?
                     t('feature.food.slider_tip_pre_meal_title') :
                     t('feature.food.slider_tip_post_meal_title')}</Text>
@@ -196,8 +195,10 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
                     t('feature.food.slider_tip_post_meal_desc')}</Text>
             </View>
             <View className='slider-item-content'>
-                <View className='slider-item-bg' style={{ width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112),
-                    backgroundColor: value==5?'#fff':value<5?ColorType.fast:ColorType.food}}>
+                <View className='slider-item-bg' style={{
+                    width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112),
+                    backgroundColor: value == 5 ? '#fff' : value < 5 ? ColorType.fast : ColorType.food
+                }}>
                     {/* <View className='slider-item' style={{
                         width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112) + 1,
                         backgroundColor: brightness <= 50 ? ColorType.fast : ColorType.food,
@@ -222,7 +223,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             isSliding && <View className='tooltip_bg'>
                 <View style={{ flex: 1 }} />
                 <View className='tooltip_content'>
-                    <Text className='tooltip_title'>{getTitle()}</Text>
+                    <Text className='tooltip_title' style={{ color: value == 5 ? '#fff' : value < 5 ? ColorType.fast : ColorType.food }}>{props.isPostMeal ? '餐后' : '餐前'}{getTitle()}</Text>
                     <Text className='tooltip_desc'>{getDesc()}</Text>
                 </View>
                 <View className='tooltip_arrow' style={{ marginLeft: brightness * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx((120 - 50) / 2) }} />

+ 26 - 24
src/context/locales/zh.js

@@ -8,7 +8,7 @@ export default {
     },
     share: {
         title: '减脂/断食睡眠/身材管理/指标记录/运动打卡, 尽在fast16cc',
-        food_title:'Food Journal'
+        food_title: 'Food Journal'
     },
     page: {
         clock: {
@@ -82,7 +82,7 @@ export default {
     },
     feature: {
         common: {
-            action_sheet_cancel:'取消',
+            action_sheet_cancel: '取消',
             picker_cancel_btn: '取消',
             picker_confirm_btn: '确定',
             wait_for_end: "待结束",
@@ -279,32 +279,34 @@ export default {
         food: {
             action_sheet: {
                 alert_text: '编辑这一餐',
-                edit_title:'对当前照片进行操作',
+                edit_title: '对当前照片进行操作',
                 tag: '标签',
                 start_time: '开始时间',
                 end_time: '结束时间',
-                edit_pic:'编辑图片',
-                share_pic:'分享图片',
+                edit_pic: '编辑图片',
+                share_pic: '分享图片',
             },
-            picker_tag_title:'标签',
-            picker_start_title:'开始时间',
-            picker_end_title:'结束时间',
-            camera:'拍摄食物',
-            album:'从相册选择',
-            share_title:'我的饮食日记',
-            prompt:'提示',
-            prompt_detail:'日记列表顺序发生变化,点击刷新',
-            sence_desc:'拍摄食物,记录餐前饥饿感\n记录餐后饱足感',
-            sence_desc_off:'感知身体饥饱信号, 提升健康饮食直觉',
-            learn_more:'了解更多',
-            mindful_switch_on:'感知模式已开启',
-            pre_meal_enforce_order_alert:'请先拍摄食物,或从相册选择食物照片',
-            pre_meal_confirm_title:'餐前饥饿感',
-            post_meal_confirm_title:'餐后饱足感',
-            slider_tip_pre_meal_title:'饥饿感',
-            slider_tip_post_meal_title:'饱足感',
-            slider_tip_pre_meal_desc:'极度饥饿到不饿',
-            slider_tip_post_meal_desc:'不饱到十分饱',
+            picker_tag_title: '标签',
+            picker_start_title: '开始时间',
+            picker_end_title: '结束时间',
+            camera: '拍摄食物',
+            album: '从相册选择',
+            share_title: '我的饮食日记',
+            prompt: '提示',
+            prompt_detail: '日记列表顺序发生变化,点击刷新',
+            sence_desc: '拍摄食物,记录餐前饥饿感\n记录餐后饱足感',
+            sence_desc_off: '感知身体饥饱信号, 提升健康饮食直觉',
+            learn_more: '了解更多',
+            mindful_switch_on: '感知模式已开启',
+            pre_meal_enforce_order_alert: '请先拍摄食物\n或从相册选择食物照片',
+            pre_meal_confirm_title: '餐前{{score}}分{{desc}}',
+            post_meal_confirm_title: '餐后{{score}}分{{desc}}',
+            slider_tip_pre_meal_title: '饥饿感',
+            slider_tip_post_meal_title: '饱足感',
+            slider_tip_pre_meal_desc: '极度饥饿到不饿',
+            slider_tip_post_meal_desc: '不饱到十分饱',
+            disable_switch_modal_title:'请先完成当前记录',
+            disable_switch_modal_btn:'我知道了'
         },
         track_something: {
             btn_record: '记录',

+ 12 - 2
src/features/food/FoodConsole.tsx

@@ -258,11 +258,21 @@ export default function Component(props: { addItem: Function, firstItem: any })
         }
     }
 
+    function clickSwitch(){
+        if (lastUnFinished){
+            Taro.showModal({
+                content:t('feature.food.disable_switch_modal_title'),
+                confirmText:t('feature.food.disable_switch_modal_btn'),
+                showCancel:false
+            })
+        }
+    }
+
     return <View style={{ marginBottom: rpxToPx(60) }}>
         <View className='food_console_box'>
             <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
                 <Text className='food_console_title'>感知模式</Text>
-                <Switch className='myswitch' disabled={lastUnFinished} checked={modeOn} color={ColorType.food} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
+                <Switch className='myswitch' onClick={clickSwitch} disabled={lastUnFinished} checked={modeOn} color={ColorType.food} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
             </View>
             {
                 modeOn && <View className='food_console_desc'>
@@ -276,7 +286,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
                 !modeOn && <View className='food_console_desc_off'>
                     
                     <Text>{t('feature.food.sence_desc_off')}</Text>
-                    <Text style={{ color: ColorType.food }} onClick={more}>{t('feature.food.learn_more')}</Text>
+                    {/* <Text style={{ color: ColorType.food }} onClick={more}>{t('feature.food.learn_more')}</Text> */}
                 </View>
             }
         </View>

+ 1 - 1
src/features/food/FoodTimelineItem.tsx

@@ -448,7 +448,7 @@ export default function Component(props: {
             </View>
         }
         {
-            detail.mindful_mode == 'AWARE' && detail.status=='WAIT_FOR_POSTMEAL' &&
+            detail.mindful_mode == 'AWARE' && detail.feel.pre_meal &&
             <View style={{
                 display: 'flex', flexDirection: 'row', alignItems: 'center',
                 marginBottom: rpxToPx(60), marginTop: -rpxToPx(60)

+ 2 - 1
src/utils/common.scss

@@ -1,5 +1,6 @@
 $themeColor: #AAFF00;
-$backgroundColor: #1C1C1C;
+$grayColor: #1C1C1C;
+$tipBgColor:#2c2c2c;
 $fastColor: #00ffff;
 $sleepColor: #8961F5;
 $alertColor: #ea6c6c;