leon hace 1 año
padre
commit
3643cd9477

BIN
ios/assets/src/assets/images/check_white.png


BIN
ios/assets/src/assets/images/pointer.png


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
ios/main.jsbundle


BIN
src/assets/images/check_white.png


+ 2 - 4
src/components/input/SlidngScale.tsx

@@ -59,6 +59,7 @@ export default function Component(props: {
 
 
     if (isFT_IN) {
     if (isFT_IN) {
         for (var i: number = minNum; i <= maxNum * 1.2; i += props.step) {
         for (var i: number = minNum; i <= maxNum * 1.2; i += props.step) {
+            i = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var value: number = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var value: number = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var isBig: boolean = i % 12 == 0;
             var isBig: boolean = i % 12 == 0;
             var isMiddle: boolean = i % 6 == 0 && !isBig
             var isMiddle: boolean = i % 6 == 0 && !isBig
@@ -72,6 +73,7 @@ export default function Component(props: {
     else {
     else {
 
 
         for (var i: number = minNum; i <= maxNum; i += props.step) {
         for (var i: number = minNum; i <= maxNum; i += props.step) {
+            i = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale))
             var value: number = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var value: number = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var isBig: boolean = Math.round((value - minNum) * jingdu) % Math.round(stepNum * jingdu) == 0;
             var isBig: boolean = Math.round((value - minNum) * jingdu) % Math.round(stepNum * jingdu) == 0;
             var isMiddle: boolean = (Math.round((value - minNum) * jingdu) * 2) % Math.round(stepNum * jingdu) == 0;
             var isMiddle: boolean = (Math.round((value - minNum) * jingdu) * 2) % Math.round(stepNum * jingdu) == 0;
@@ -83,7 +85,6 @@ export default function Component(props: {
             })
             })
         }
         }
     }
     }
-    console.log('list length', list.length)
 
 
 
 
     useEffect(() => {
     useEffect(() => {
@@ -152,7 +153,6 @@ export default function Component(props: {
     }
     }
 
 
     function dragStart(e) {
     function dragStart(e) {
-        debugger
         lastValue = e.detail.scrollLeft;
         lastValue = e.detail.scrollLeft;
         setIsEnd(false)
         setIsEnd(false)
         setIsDraging(true)
         setIsDraging(true)
@@ -263,8 +263,6 @@ export default function Component(props: {
     svgLine2 += `</pattern>
     svgLine2 += `</pattern>
     <rect width="100%" height="100%" fill="url(#pattern)" />
     <rect width="100%" height="100%" fill="url(#pattern)" />
   </svg>`
   </svg>`
-
-    console.log(current)
     return <View className="slidng">
     return <View className="slidng">
         {
         {
             isFT_IN && <View className="number_bg" style={{ opacity: enableText ? 1 : 0.4 }}>
             isFT_IN && <View className="number_bg" style={{ opacity: enableText ? 1 : 0.4 }}>

+ 1 - 0
src/context/locales/en.js

@@ -24,6 +24,7 @@ export default {
         },
         },
         metric: {
         metric: {
             title: 'Metrics',
             title: 'Metrics',
+            unit_options:'Unit options'
         },
         },
         food: {
         food: {
             title: 'Breakfast Journal',
             title: 'Breakfast Journal',

+ 1 - 0
src/context/locales/zh.js

@@ -24,6 +24,7 @@ export default {
         },
         },
         metric: {
         metric: {
             title: '指标',
             title: '指标',
+            unit_options:'单位选项'
         },
         },
         food: {
         food: {
             title: '早餐日记',
             title: '早餐日记',

+ 52 - 32
src/features/trackSomething/components/MetricHistory.tsx

@@ -24,8 +24,8 @@ export default function Component(props: { records: any[] }) {
 
 
     }, [props.records])
     }, [props.records])
 
 
-    global.dimissSel = ()=>{
-        setSelIndex([-1,-1])
+    global.dimissSel = () => {
+        setSelIndex([-1, -1])
     }
     }
 
 
     function formateHourMinutes(timestamp: number) {
     function formateHourMinutes(timestamp: number) {
@@ -80,18 +80,18 @@ export default function Component(props: { records: any[] }) {
         }
         }
     }
     }
 
 
-    function changeUnit(index){
+    function changeUnit(index) {
         var data = global.selMetricItem;
         var data = global.selMetricItem;
         var unit = data.schemas[0].unit_options[index].unit;
         var unit = data.schemas[0].unit_options[index].unit;
         const indexs = selIndex;
         const indexs = selIndex;
         var temps = JSON.parse(JSON.stringify(list))
         var temps = JSON.parse(JSON.stringify(list))
         var array = temps[indexs[0]]
         var array = temps[indexs[0]]
         var selItem = array.records[indexs[1]]
         var selItem = array.records[indexs[1]]
-        const {id} = selItem
-        metricRecord(id,{show_unit:unit}).then(res=>{
+        const { id } = selItem
+        metricRecord(id, { show_unit: unit }).then(res => {
             temps[indexs[0]].records[indexs[1]] = res
             temps[indexs[0]].records[indexs[1]] = res
             setList(temps)
             setList(temps)
-            setSelIndex([-1,-1])
+            setSelIndex([-1, -1])
         })
         })
     }
     }
 
 
@@ -146,10 +146,9 @@ export default function Component(props: { records: any[] }) {
     }
     }
 
 
     var lastYearStr = '2050年'
     var lastYearStr = '2050年'
-    return <View style={{ display: 'flex', flexDirection: 'column' }} onClick={()=>{setSelIndex([-1,-1])}}>
+    return <View style={{ display: 'flex', flexDirection: 'column' }} onClick={() => { setSelIndex([-1, -1]) }}>
         {
         {
             user.test_user && <Text style={{ color: '#fff', position: 'absolute', right: 50, top: 0 }} onClick={() => {
             user.test_user && <Text style={{ color: '#fff', position: 'absolute', right: 50, top: 0 }} onClick={() => {
-                debugger
                 global.clearHistory()
                 global.clearHistory()
             }}>删除全部</Text>
             }}>删除全部</Text>
         }
         }
@@ -160,44 +159,27 @@ export default function Component(props: { records: any[] }) {
             (list as any).map((item, index) => {
             (list as any).map((item, index) => {
                 var showYear = lastYearStr != TimeFormatter.getYearByDate(item.date)
                 var showYear = lastYearStr != TimeFormatter.getYearByDate(item.date)
                 lastYearStr = TimeFormatter.getYearByDate(item.date)
                 lastYearStr = TimeFormatter.getYearByDate(item.date)
-                return <View style={{ display: 'flex', flexDirection: 'column' }}>
+                return <View style={{ display: 'flex', flexDirection: 'column', paddingBottom: index < list.length - 1 ? 0 : 80,zIndex:0 }}>
                     {
                     {
                         showYear && <Text className="year" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{TimeFormatter.getYearByDate(item.date)}</Text>
                         showYear && <Text className="year" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{TimeFormatter.getYearByDate(item.date)}</Text>
                     }
                     }
                     <Text className="operate_day" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{TimeFormatter.getMonthAndDayByDate(item.date)}</Text>
                     <Text className="operate_day" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{TimeFormatter.getMonthAndDayByDate(item.date)}</Text>
                     {
                     {
                         item.records.map((record, j) => {
                         item.records.map((record, j) => {
-                            return <RecordItem delete={() => deleteRecord(record)}>
+                            return <View style={{ position: 'relative' }} key={j}><RecordItem delete={() => deleteRecord(record)}>
                                 <View className="operate_item1" onClick={(e) => {
                                 <View className="operate_item1" onClick={(e) => {
-                                    if (process.env.TARO_ENV=='weapp'){
+                                    if (process.env.TARO_ENV == 'weapp') {
                                         e.stopPropagation()
                                         e.stopPropagation()
                                     }
                                     }
                                     tapItem(index, j)
                                     tapItem(index, j)
-                                }} style={{ position: 'relative' }}>
-                                    {
-                                        index == selIndex[0] && j == selIndex[1] && <View style={{ position: 'absolute', right: 20, zIndex: 1000000 }}>
-                                            <View style={{ display: 'flex', flexDirection: 'column', position: 'absolute', top: 30, right: 0, backgroundColor: 'red' }}>
-                                                {
-                                                    global.selMetricItem.schemas[0].unit_options.map((obj, k) => {
-                                                        return <View key={k * 1000} onClick={() => {
-
-                                                            changeUnit(k)
-                                                            setSelIndex([-1,-1])
-                                                        }}>
-                                                            <Text>{obj.unit}</Text>
-                                                        </View>
-                                                    })
-                                                }
-                                            </View>
+                                }} style={{ position: 'relative', zIndex: 100 }}>
 
 
-                                        </View>
-                                    }
                                     {
                                     {
                                         record.items[0].special == 'FT_IN' ?
                                         record.items[0].special == 'FT_IN' ?
                                             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'flex-end' }}>
                                             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'flex-end' }}>
-                                                <Text className="value" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{parseInt(record.items[0].value/12+'')}</Text>
+                                                <Text className="value" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{parseInt(record.items[0].value / 12 + '')}</Text>
                                                 <Text className="unit" style={{ marginBottom: 3, marginLeft: 3, marginRight: 3 }}>ft</Text>
                                                 <Text className="unit" style={{ marginBottom: 3, marginLeft: 3, marginRight: 3 }}>ft</Text>
-                                                <Text className="value" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{record.items[0].value%12}</Text>
+                                                <Text className="value" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{record.items[0].value % 12}</Text>
                                                 <Text className="unit" style={{ marginBottom: 3, marginLeft: 3 }}>in</Text>
                                                 <Text className="unit" style={{ marginBottom: 3, marginLeft: 3 }}>in</Text>
                                             </View> :
                                             </View> :
                                             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'flex-end' }}>
                                             <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'flex-end' }}>
@@ -208,7 +190,7 @@ export default function Component(props: { records: any[] }) {
                                                 {
                                                 {
                                                     record.type == 'basic' && record.items.length > 2 && <Text className="value">/{record.items[2].value}</Text>
                                                     record.type == 'basic' && record.items.length > 2 && <Text className="value">/{record.items[2].value}</Text>
                                                 }
                                                 }
-                                                <Text className="unit" style={{ marginBottom: 3,marginLeft:3 }}>{record.type == 'composite' ? record.unit ? record.unit : '' : record.items[0].unit}</Text>
+                                                <Text className="unit" style={{ marginBottom: 3, marginLeft: 3 }}>{record.type == 'composite' ? record.unit ? record.unit : '' : record.items[0].unit}</Text>
                                             </View>
                                             </View>
                                     }
                                     }
 
 
@@ -218,6 +200,44 @@ export default function Component(props: { records: any[] }) {
 
 
                                 </View>
                                 </View>
                             </RecordItem>
                             </RecordItem>
+                                {
+                                    index == selIndex[0] && j == selIndex[1] && 
+                                        <View style={{ display: 'flex', flexDirection: 'column',zIndex:10000, position: 'absolute', alignItems: 'center', top: rpxToPx(125), left: 30 }}>
+                                            <Image src={require('@assets/images/pointer.png')} style={{ width: 32, height: 12, marginBottom: -2 }} />
+                                            <View style={{
+                                                backgroundColor: '#505050',
+                                                width: 82,
+                                                borderRadius: 12,
+                                                boxSizing: 'border-box',
+                                                flexDirection: 'column',
+                                                display: 'flex'
+                                            }}>
+                                                {
+                                                    global.selMetricItem.schemas[0].unit_options.map((obj, k) => {
+                                                        return <View key={k * 1000} style={{
+                                                            height: 28,
+                                                            display: 'flex',
+                                                            flexDirection: 'row',
+                                                            alignItems: 'center',
+                                                            borderBottomWidth: 1,
+                                                            borderBottomColor: k < global.selMetricItem.schemas[0].unit_options.length - 1 ? '#FFFFFF33' : 'transparent',
+                                                            borderBottomStyle: 'solid'
+                                                        }} onClick={() => {
+                                                            changeUnit(k)
+                                                            setSelIndex([-1, -1])
+                                                        }}>
+                                                            <View style={{ width: 12 }} />
+                                                            <Image style={{ width: 12, height: 9, marginRight: 7, opacity: record.items[0].unit == obj.unit ? 1 : 0 }} src={require('@assets/images/check_white.png')} />
+                                                            <Text style={{ color: '#fff', fontSize: 12 }}>{obj.special == 'FT_IN' ? 'ft in' : obj.unit}</Text>
+                                                        </View>
+                                                    })
+                                                }
+                                            </View>
+                                        </View>
+
+
+                                }
+                            </View>
                         })
                         })
                     }
                     }
                 </View>
                 </View>

+ 90 - 26
src/features/trackSomething/components/MetricModalAdd.tsx

@@ -1,4 +1,4 @@
-import { View, Text, CoverView } from '@tarojs/components'
+import { View, Text, Image } from '@tarojs/components'
 import './MetricModalAdd.scss'
 import './MetricModalAdd.scss'
 import { useTranslation } from 'react-i18next'
 import { useTranslation } from 'react-i18next'
 import { alphaToHex, rpxToPx } from '@/utils/tools'
 import { alphaToHex, rpxToPx } from '@/utils/tools'
@@ -25,8 +25,8 @@ export default function Component(props: { item: any, strTime: string, showPicke
         setSelUnit(-1)
         setSelUnit(-1)
     }
     }
 
 
-    return <View>
-        <View className='modal_content'>
+    function addDetail() {
+        return <View className='modal_content'>
             <Text className='modal_title' style={{ color: (metricItem as any).theme_color }}>{(metricItem as any).name ? (metricItem as any).name : ''}</Text>
             <Text className='modal_title' style={{ color: (metricItem as any).theme_color }}>{(metricItem as any).name ? (metricItem as any).name : ''}</Text>
             <View style={{ position: 'relative' }}>
             <View style={{ position: 'relative' }}>
                 {
                 {
@@ -52,36 +52,84 @@ export default function Component(props: { item: any, strTime: string, showPicke
                                 }}>{item.name}</Text>
                                 }}>{item.name}</Text>
                             }
                             }
                             {
                             {
-                                unit_options && unit_options.length > 1 && <View style={{ position: 'absolute', right: 20, zIndex: 1000000 }}>
-                                    <Text style={{ color: '#fff' }} onClick={(e) => {
+                                unit_options && unit_options.length > 1 && <View style={{ position: 'absolute', right: 20, zIndex: 1000000, top: (metricItem as any).schemas.length == 1 ? -rpxToPx(80) : -rpxToPx(5) }}>
+                                    <Text style={{ color: '#fff', opacity: 0.2, fontSize: 12 }} onClick={(e) => {
                                         if (process.env.TARO_ENV == 'weapp') {
                                         if (process.env.TARO_ENV == 'weapp') {
                                             e.stopPropagation()
                                             e.stopPropagation()
                                         }
                                         }
                                         setSelUnit(index)
                                         setSelUnit(index)
-                                    }}>切换</Text>
+                                    }}>{t('page.metric.unit_options')}</Text>
                                     {
                                     {
-                                        selUnit == index && <View style={{ display: 'flex', flexDirection: 'column', position: 'absolute', top: 30, right: 0, backgroundColor: 'red' }}>
-                                            {
-                                                unit_options.map((obj, j) => {
-                                                    return <View key={j * 1000} onClick={() => {
-                                                        var dt = JSON.parse(JSON.stringify(metricItem))
-                                                        dt.schemas[index].chosen_unit = obj.unit
-                                                        setMetricItem(dt)
+                                        selUnit == index && <View style={{ display: 'flex', flexDirection: 'column', position: 'absolute', alignItems: 'center', top: 25, right: -10 }}>
+                                            <Image src={require('@assets/images/pointer.png')} style={{ width: 32, height: 12, marginBottom: -2 }} />
+                                            <View style={{
+                                                backgroundColor: '#505050',
+                                                width: 82,
+                                                borderRadius: 12,
+                                                boxSizing: 'border-box',
+                                                flexDirection: 'column',
+                                                display: 'flex'
+                                            }}>
+                                                {
+                                                    unit_options.map((obj, j) => {
+                                                        return <View key={j * 1000} style={{
+                                                            height: 28,
+                                                            display: 'flex',
+                                                            flexDirection: 'row',
+                                                            alignItems: 'center',
+                                                            borderBottomWidth: 1,
+                                                            borderBottomColor: j < unit_options.length - 1 ? '#FFFFFF33' : 'transparent',
+                                                            borderBottomStyle: 'solid'
+                                                        }} onClick={() => {
 
 
-                                                        setChangeIndex(index)
-                                                        setIsChanging(true)
-                                                        setTimeout(() => {
-                                                            setIsChanging(false)
-                                                        }, 20)
-                                                        setTimeout(() => {
-                                                            setChangeIndex(-1)
+                                                            var dt = JSON.parse(JSON.stringify(metricItem))
+                                                            const pre_unit = dt.schemas[index].chosen_unit
+                                                            const current_unit = obj.unit
+                                                            var pre_obj: any;
+                                                            var current_obj: any;
+                                                            dt.schemas[index].unit_options.map(item => {
+                                                                if (item.unit == pre_unit) {
+                                                                    pre_obj = item
+                                                                }
+                                                                else if (item.unit == current_unit) {
+                                                                    current_obj = item
+                                                                }
+                                                            })
+                                                            const preValue = item.tempValue ? item.tempValue : pre_obj.default_value;
+                                                            var currentValue: any = preValue * pre_obj.ratio_to_base / current_obj.ratio_to_base
+                                                            if (currentValue < current_obj.min) {
+                                                                currentValue = current_obj.min
+                                                            }
+                                                            else if (currentValue > current_obj.max) {
+                                                                currentValue = current_obj.max
+                                                            }
+                                                            else {
+                                                                currentValue = parseFloat(currentValue).toFixed(current_obj.scale);
+                                                            }
+                                                            current_obj.default_value = currentValue
+                                                            dt.schemas[index].tempValue = currentValue
 
 
-                                                        }, 100)
-                                                    }}>
-                                                        <Text>{obj.unit}</Text>
-                                                    </View>
-                                                })
-                                            }
+                                                            dt.schemas[index].chosen_unit = obj.unit
+                                                            setMetricItem(dt)
+
+
+                                                            setChangeIndex(index)
+                                                            setIsChanging(true)
+                                                            setTimeout(() => {
+                                                                setIsChanging(false)
+                                                            }, 20)
+                                                            setTimeout(() => {
+                                                                setChangeIndex(-1)
+
+                                                            }, 100)
+                                                        }}>
+                                                            <View style={{ width: 12 }} />
+                                                            <Image style={{ width: 12, height: 9, marginRight: 7, opacity: chosen_unit == obj.unit ? 1 : 0 }} src={require('@assets/images/check_white.png')} />
+                                                            <Text style={{ color: '#fff', fontSize: 12 }}>{obj.special == 'FT_IN' ? 'ft in' : obj.unit}</Text>
+                                                        </View>
+                                                    })
+                                                }
+                                            </View>
                                         </View>
                                         </View>
                                     }
                                     }
                                 </View>
                                 </View>
@@ -150,5 +198,21 @@ export default function Component(props: { item: any, strTime: string, showPicke
                 </View>
                 </View>
             </View>
             </View>
         </View>
         </View>
+    }
+
+    if (process.env.TARO_ENV == 'rn') {
+        return <View>
+            {
+                addDetail()
+            }
+        </View>
+    }
+
+    return <View onClick={() => {
+        setSelUnit(-1)
+    }}>
+        {
+            addDetail()
+        }
     </View>
     </View>
 }
 }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio