-
Notifications
You must be signed in to change notification settings - Fork 296
Feat/range 适配 JDRN、鸿蒙端 #2357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/range 适配 JDRN、鸿蒙端 #2357
Changes from all commits
d9ae0aa
ee5c98b
f95b676
d45139d
df7a1a2
2bf648d
a45d083
2084300
4f106a5
3cc3abb
b019884
90049f4
278bedd
78d8e8a
8540ec8
b9cdbe8
fbd01ea
94d516c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| export default { | ||
| navigationBarTitleText: 'Range', | ||
| navigationBarTitleText: 'Range' | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export default <>button</>; | ||
| import Demo from '@/packages/range/demo.taro'; | ||
| export default Demo; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,30 @@ | ||
| import React, { useState } from 'react' | ||
| import { Range, Cell, Toast } from '@nutui/nutui-react-taro' | ||
| import React, { useMemo, useState } from 'react' | ||
| import { View } from '@tarojs/components' | ||
| import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro' | ||
lyxuncle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import pxTransform from '@/utils/px-transform' | ||
| import { harmonyAndRn } from '@/utils/platform-taro' | ||
|
|
||
| const Demo1 = () => { | ||
| const cellStyle = { | ||
| padding: '40px 18px', | ||
| } | ||
| const cellStyle = useMemo(() => { | ||
| return harmonyAndRn() | ||
| ? { | ||
| paddingTop: pxTransform(40), | ||
| paddingBottom: pxTransform(40), | ||
| paddingLeft: pxTransform(18), | ||
| paddingRight: pxTransform(18), | ||
| } | ||
| : { | ||
| padding: '40px 18px', | ||
| } | ||
| }, []) | ||
| const [show, setShow] = useState(false) | ||
| const [msg, setMsg] = useState('') | ||
| const showToast = (msg: string) => { | ||
| setMsg(msg) | ||
| setShow(true) | ||
| } | ||
| return ( | ||
| <> | ||
| <View> | ||
| <Cell style={cellStyle}> | ||
| <Range defaultValue={40} onEnd={(val) => showToast(`${val}`)} /> | ||
| </Cell> | ||
|
|
@@ -26,15 +38,15 @@ const Demo1 = () => { | |
| onEnd={(val) => showToast(`${val}`)} | ||
| /> | ||
| </Cell> | ||
| <Toast | ||
| {/* <Toast | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不要影响 h5 和 小程序~ |
||
| type="text" | ||
| visible={show} | ||
| content={msg} | ||
| onClose={() => { | ||
| setShow(false) | ||
| }} | ||
| /> | ||
| </> | ||
| /> */} | ||
lyxuncle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </View> | ||
| ) | ||
| } | ||
| export default Demo1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,99 @@ | ||
| import React, { useState } from 'react' | ||
| import { View } from '@tarojs/components' | ||
| import { Range, Cell, Toast } from '@nutui/nutui-react-taro' | ||
| import React, { useMemo, useState } from 'react' | ||
| import { View, Text } from '@tarojs/components' | ||
| import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro' | ||
| import { rn, harmony, harmonyAndRn } from '@/utils/platform-taro' | ||
| import pxTransform from '@/utils/px-transform' | ||
|
|
||
| const Demo11 = () => { | ||
| const cellStyle = useMemo(() => { | ||
| return harmonyAndRn() | ||
| ? { | ||
| paddingTop: pxTransform(40), | ||
| paddingBottom: pxTransform(40), | ||
| paddingLeft: pxTransform(18), | ||
| paddingRight: pxTransform(18), | ||
| } | ||
| : { | ||
| padding: '40px 18px', | ||
| } | ||
| }, []) | ||
|
|
||
| const buttonNativeStyle = useMemo(() => { | ||
| if (rn()) { | ||
| return { | ||
| transform: [ | ||
| { translateX: pxTransform(-13) }, | ||
| { translateY: pxTransform(3) }, | ||
| ], | ||
| } | ||
| } | ||
| return {} | ||
| }, []) | ||
| const [value, setValue] = useState(60) | ||
| const cellStyle = { | ||
| padding: '40px 18px', | ||
| } | ||
| const [show, setShow] = useState(false) | ||
| const [msg, setMsg] = useState('') | ||
| const showToast = (msg: string) => { | ||
| setMsg(msg) | ||
| setShow(true) | ||
| } | ||
| return ( | ||
| <> | ||
| <View> | ||
| <Cell style={cellStyle}> | ||
| <Range | ||
| value={value} | ||
| button={ | ||
| <View | ||
| style={{ | ||
| width: '26px', | ||
| color: 'white', | ||
| fontSize: '10px', | ||
| lineHeight: '18px', | ||
| textAlign: 'center', | ||
| position: 'absolute', | ||
| display: 'flex', | ||
| width: pxTransform(26), | ||
| backgroundColor: 'red', | ||
| borderRadius: '10px', | ||
| borderRadius: pxTransform(10), | ||
| justifyContent: 'center', | ||
| top: '50%', | ||
| left: '50%', | ||
| // @ts-ignore | ||
| transform: 'translate(-50%, -50%)', | ||
| ...buttonNativeStyle, | ||
| }} | ||
| > | ||
| {value} | ||
| <Text | ||
| style={ | ||
| harmony() | ||
| ? { | ||
| height: pxTransform(18), | ||
| color: 'white', | ||
| fontSize: pxTransform(10), | ||
| lineHeight: pxTransform(10), | ||
| textAlign: 'center', | ||
| paddingTop: pxTransform(4), | ||
| paddingBottom: pxTransform(4), | ||
| } | ||
| : { | ||
| color: 'white', | ||
| fontSize: pxTransform(10), | ||
| lineHeight: rn() ? pxTransform(18) : '18px', | ||
| textAlign: 'center', | ||
| } | ||
| } | ||
| > | ||
| {value} | ||
| </Text> | ||
| </View> | ||
| } | ||
| onChange={(val: any) => setValue(val)} | ||
| onEnd={(val) => showToast(`${val}`)} | ||
| /> | ||
| </Cell> | ||
| <Toast | ||
| {/* <Toast | ||
| type="text" | ||
| visible={show} | ||
| content={msg} | ||
| onClose={() => { | ||
| setShow(false) | ||
| }} | ||
| /> | ||
| </> | ||
| /> */} | ||
| </View> | ||
| ) | ||
| } | ||
| export default Demo11 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,29 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||
| import React, { useState } from 'react' | ||||||||||||||||||||||||||||||||||||||||
| import React, { useMemo, useState } from 'react' | ||||||||||||||||||||||||||||||||||||||||
| import { View } from '@tarojs/components' | ||||||||||||||||||||||||||||||||||||||||
| import { Range, Cell, Toast } from '@nutui/nutui-react-taro' | ||||||||||||||||||||||||||||||||||||||||
| import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro' | ||||||||||||||||||||||||||||||||||||||||
| import pxTransform from '@/utils/px-transform' | ||||||||||||||||||||||||||||||||||||||||
| import { harmonyAndRn } from '@/utils/platform-taro' | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const Demo12 = () => { | ||||||||||||||||||||||||||||||||||||||||
| const verticalStyle = { | ||||||||||||||||||||||||||||||||||||||||
| height: '180px', | ||||||||||||||||||||||||||||||||||||||||
| padding: '10px', | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| const verticalStyle = useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||
| return harmonyAndRn() | ||||||||||||||||||||||||||||||||||||||||
| ? { | ||||||||||||||||||||||||||||||||||||||||
| height: pxTransform(180), | ||||||||||||||||||||||||||||||||||||||||
| paddingTop: pxTransform(10), | ||||||||||||||||||||||||||||||||||||||||
| paddingBottom: pxTransform(10), | ||||||||||||||||||||||||||||||||||||||||
| paddingLeft: pxTransform(10), | ||||||||||||||||||||||||||||||||||||||||
| paddingRight: pxTransform(10), | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| : { | ||||||||||||||||||||||||||||||||||||||||
| height: '180px', | ||||||||||||||||||||||||||||||||||||||||
| padding: '10px', | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }, []) | ||||||||||||||||||||||||||||||||||||||||
| const viewStyle = useMemo( | ||||||||||||||||||||||||||||||||||||||||
| () => ({ width: pxTransform(150), height: '100%' }), | ||||||||||||||||||||||||||||||||||||||||
| [] | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| const [show, setShow] = useState(false) | ||||||||||||||||||||||||||||||||||||||||
| const [msg, setMsg] = useState('') | ||||||||||||||||||||||||||||||||||||||||
| const showToast = (msg: string) => { | ||||||||||||||||||||||||||||||||||||||||
| setMsg(msg) | ||||||||||||||||||||||||||||||||||||||||
| setShow(true) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||||||
| <View> | ||||||||||||||||||||||||||||||||||||||||
| <Cell style={verticalStyle}> | ||||||||||||||||||||||||||||||||||||||||
| <View style={{ width: '150px', height: '100%' }}> | ||||||||||||||||||||||||||||||||||||||||
| <View style={viewStyle}> | ||||||||||||||||||||||||||||||||||||||||
| <Range | ||||||||||||||||||||||||||||||||||||||||
| defaultValue={20} | ||||||||||||||||||||||||||||||||||||||||
| vertical | ||||||||||||||||||||||||||||||||||||||||
| onEnd={(val) => showToast(`${val}`)} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| </View> | ||||||||||||||||||||||||||||||||||||||||
| <View style={{ width: '150px', height: '100%' }}> | ||||||||||||||||||||||||||||||||||||||||
| <View style={viewStyle}> | ||||||||||||||||||||||||||||||||||||||||
| <Range | ||||||||||||||||||||||||||||||||||||||||
| defaultValue={[20, 80]} | ||||||||||||||||||||||||||||||||||||||||
| vertical | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,15 +48,15 @@ const Demo12 = () => { | |||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| </View> | ||||||||||||||||||||||||||||||||||||||||
| </Cell> | ||||||||||||||||||||||||||||||||||||||||
| <Toast | ||||||||||||||||||||||||||||||||||||||||
| {/* <Toast | ||||||||||||||||||||||||||||||||||||||||
| type="text" | ||||||||||||||||||||||||||||||||||||||||
| visible={show} | ||||||||||||||||||||||||||||||||||||||||
| content={msg} | ||||||||||||||||||||||||||||||||||||||||
| onClose={() => { | ||||||||||||||||||||||||||||||||||||||||
| setShow(false) | ||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||||||
| /> */} | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+51
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 注释了 + // TODO: Review the necessity of Toast component here and decide whether to reintroduce or permanently remove.Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| </View> | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| export default Demo12 | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
添加 'range' 到导出列表是符合 PR 目标的。但是,请注意修复全局变量重新赋值的问题。
Committable suggestion