@lynx-example/lynx-ui-swiper 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/Basic/index.tsx +3 -3
  2. package/Basic/styles.css +1 -1
  3. package/BasicDynamic/index.tsx +66 -74
  4. package/BasicUpdateSize/index.tsx +65 -75
  5. package/Bounces/index.tsx +71 -55
  6. package/Bounces/styles.css +36 -27
  7. package/CHANGELOG.md +18 -0
  8. package/Common/Demo/styles.css +113 -0
  9. package/Custom/index.tsx +43 -41
  10. package/CustomScale/index.tsx +44 -42
  11. package/CustomTinder/index.tsx +2 -2
  12. package/CustomTinder/styles.css +1 -1
  13. package/DifferentHeight/Button.tsx +1 -29
  14. package/DifferentHeight/index.tsx +4 -4
  15. package/DifferentHeight/styles.css +1 -1
  16. package/Direction/index.tsx +97 -105
  17. package/EmptyDataBug/index.tsx +14 -13
  18. package/EmptyDataBug/styles.css +19 -12
  19. package/Indicator/index.tsx +56 -50
  20. package/Lazy/index.tsx +69 -65
  21. package/Loop/index.tsx +45 -42
  22. package/RTL/Button.tsx +1 -29
  23. package/RTL/index.tsx +74 -83
  24. package/RTLCustom/index.tsx +45 -43
  25. package/RTLLoop/Button.tsx +1 -29
  26. package/RTLLoop/index.tsx +57 -66
  27. package/RTLLoopLynxRTL/Button.tsx +1 -29
  28. package/RTLLoopLynxRTL/index.tsx +57 -66
  29. package/WithGap/Button.tsx +1 -29
  30. package/WithGap/index.tsx +57 -68
  31. package/dist/SwiperBasic.lynx.bundle +0 -0
  32. package/dist/SwiperBasic.web.bundle +1 -1
  33. package/dist/SwiperBasicDynamic.lynx.bundle +0 -0
  34. package/dist/SwiperBasicDynamic.web.bundle +1 -1
  35. package/dist/SwiperBasicUpdateSize.lynx.bundle +0 -0
  36. package/dist/SwiperBasicUpdateSize.web.bundle +1 -1
  37. package/dist/SwiperBounces.lynx.bundle +0 -0
  38. package/dist/SwiperBounces.web.bundle +1 -1
  39. package/dist/SwiperCustom.lynx.bundle +0 -0
  40. package/dist/SwiperCustom.web.bundle +1 -1
  41. package/dist/SwiperCustomScale.lynx.bundle +0 -0
  42. package/dist/SwiperCustomScale.web.bundle +1 -1
  43. package/dist/SwiperCustomTinder.lynx.bundle +0 -0
  44. package/dist/SwiperCustomTinder.web.bundle +1 -1
  45. package/dist/SwiperDifferentHeight.lynx.bundle +0 -0
  46. package/dist/SwiperDifferentHeight.web.bundle +1 -1
  47. package/dist/SwiperEmptyDataBug.lynx.bundle +0 -0
  48. package/dist/SwiperEmptyDataBug.web.bundle +1 -1
  49. package/dist/SwiperIndicator.lynx.bundle +0 -0
  50. package/dist/SwiperIndicator.web.bundle +1 -1
  51. package/dist/SwiperLazy.lynx.bundle +0 -0
  52. package/dist/SwiperLazy.web.bundle +1 -1
  53. package/dist/SwiperLoop.lynx.bundle +0 -0
  54. package/dist/SwiperLoop.web.bundle +1 -1
  55. package/dist/SwiperRTL.lynx.bundle +0 -0
  56. package/dist/SwiperRTL.web.bundle +1 -1
  57. package/dist/SwiperRTLCustom.lynx.bundle +0 -0
  58. package/dist/SwiperRTLCustom.web.bundle +1 -1
  59. package/dist/SwiperRTLLoop.lynx.bundle +0 -0
  60. package/dist/SwiperRTLLoop.web.bundle +1 -1
  61. package/dist/SwiperRTLLynxRTL.lynx.bundle +0 -0
  62. package/dist/SwiperRTLLynxRTL.web.bundle +1 -1
  63. package/dist/SwiperWithGap.lynx.bundle +0 -0
  64. package/dist/SwiperWithGap.web.bundle +1 -1
  65. package/package.json +6 -6
  66. package/BasicDynamic/styles.css +0 -47
  67. package/BasicUpdateSize/styles.css +0 -47
  68. package/Custom/styles.css +0 -47
  69. package/CustomScale/styles.css +0 -41
  70. package/Direction/styles.css +0 -41
  71. package/Indicator/styles.css +0 -41
  72. package/Lazy/styles.css +0 -41
  73. package/Loop/styles.css +0 -41
  74. package/RTL/styles.css +0 -41
  75. package/RTLCustom/styles.css +0 -41
  76. package/RTLLoop/styles.css +0 -41
  77. package/RTLLoopLynxRTL/styles.css +0 -41
  78. package/WithGap/styles.css +0 -47
package/RTL/index.tsx CHANGED
@@ -7,19 +7,13 @@ import { root, useRef, useState } from '@lynx-js/react'
7
7
  import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
8
  import type { SwiperRef } from '@lynx-js/lynx-ui'
9
9
 
10
- import './styles.css'
10
+ import { Button } from '../Common/Button'
11
+ import { Card } from '../Common/Card'
12
+ import { Indicator } from '../Common/Indicator'
11
13
 
12
- import { Button } from './Button'
14
+ import '../Common/Demo/styles.css'
13
15
 
14
- const colorsArr: string[] = [
15
- 'red',
16
- 'green',
17
- 'yellow',
18
- 'purple',
19
- 'lightblue',
20
- 'lightgreen',
21
- 'lightyellow',
22
- ]
16
+ const itemArr: number[] = [1, 2, 3, 4, 5, 6, 7]
23
17
 
24
18
  const itemWidths = [250, 350, 400]
25
19
  const alignArr: ['start', 'center', 'end'] = ['start', 'center', 'end']
@@ -31,98 +25,95 @@ function SwiperEntry(): JSX.Element {
31
25
  const swiperRef = useRef<SwiperRef>(null)
32
26
 
33
27
  return (
34
- <view id='container'>
35
- <Swiper
36
- ref={swiperRef}
37
- data={colorsArr}
38
- itemWidth={itemWidths[itemWidthsIndex] ?? 0}
39
- itemHeight={200}
40
- duration={500}
41
- initialIndex={0}
42
- onChange={setCurrentIndex}
43
- mode='normal'
44
- modeConfig={{
45
- align: alignArr[alignIndex] ?? 'start',
46
- spaceBetween: 8,
47
- }}
48
- RTL={true}
49
- bounceConfig={{
50
- enable: true,
51
- startBounceItemWidth: 100,
52
- endBounceItemWidth: 100,
53
- startBounceItem: (
54
- <view style='display: linear; linear-orientation: vertical; height: 100%; width: 30px; border: 1px solid #000;'>
55
- <text style='color: #000'>Start Show More</text>
56
- </view>
57
- ),
58
- endBounceItem: (
59
- <view style='display: linear; linear-orientation: vertical; height: 100%; width: 30px; border: 1px solid #000;'>
60
- <text style='color: #000'>Show More</text>
61
- </view>
62
- ),
63
- onEndBounceItemBounce: ({ type }) => {
64
- console.log('onBounce result', type)
65
- },
66
- }}
67
- >
68
- {({ item, index, realIndex }) => (
69
- <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
70
- <view
71
- class='block-view'
72
- style={{
73
- width: '100%',
74
- height: '100%',
75
- backgroundColor: item,
76
- display: 'flex',
77
- justifyContent: 'center',
78
- alignItems: 'center',
79
- }}
80
- >
81
- <view
28
+ <view className='demo-container lunaris-dark'>
29
+ <view className='top-area' />
30
+ <view className='content-area'>
31
+ <Swiper
32
+ ref={swiperRef}
33
+ data={itemArr}
34
+ itemWidth={itemWidths[itemWidthsIndex] ?? 0}
35
+ itemHeight={250}
36
+ containerWidth={lynx.__globalProps.screenWidth - 32
37
+ || SystemInfo.pixelWidth / SystemInfo.pixelRatio - 32}
38
+ duration={500}
39
+ initialIndex={0}
40
+ onChange={setCurrentIndex}
41
+ mode='normal'
42
+ modeConfig={{
43
+ align: alignArr[alignIndex] ?? 'start',
44
+ spaceBetween: 16,
45
+ }}
46
+ RTL={true}
47
+ style={{
48
+ overflow: 'visible',
49
+ }}
50
+ bounceConfig={{
51
+ enable: true,
52
+ startBounceItemWidth: 100,
53
+ endBounceItemWidth: 100,
54
+ startBounceItem: (
55
+ <view className='bounce-item'>
56
+ <text className='bounce-item-text'>Start</text>
57
+ </view>
58
+ ),
59
+ endBounceItem: (
60
+ <view className='bounce-item'>
61
+ <text className='bounce-item-text'>End</text>
62
+ </view>
63
+ ),
64
+ onEndBounceItemBounce: ({ type }) => {
65
+ console.log('onBounce result', type)
66
+ },
67
+ }}
68
+ >
69
+ {({ index }) => (
70
+ <SwiperItem>
71
+ <Card
72
+ index={index}
82
73
  style={{
83
- backgroundColor: 'white',
84
- width: '4px',
85
- height: '4px',
74
+ height: '250px',
86
75
  }}
87
- >
88
- </view>
89
- </view>
90
- <text class='image-text'>Number.{index}</text>
91
- </SwiperItem>
92
- )}
93
- </Swiper>
94
- <view class='operation'>
95
- <view class='block'>
96
- <text>Current Index: {currentIndex}</text>
97
- </view>
76
+ />
77
+ </SwiperItem>
78
+ )}
79
+ </Swiper>
80
+ <Indicator
81
+ current={currentIndex}
82
+ count={itemArr.length}
83
+ />
84
+ </view>
85
+ <view className='operation'>
98
86
  <Button
99
87
  onClick={() => {
100
88
  swiperRef.current?.swipePrev()
101
89
  }}
90
+ className='expand'
102
91
  text='SwipePrev'
103
- >
104
- </Button>
92
+ />
105
93
  <Button
106
94
  onClick={() => {
107
95
  swiperRef.current?.swipeNext()
108
96
  }}
97
+ className='expand'
98
+ type='primary'
109
99
  text='SwipeNext'
110
- >
111
- </Button>
100
+ />
101
+ </view>
102
+ <view className='sub-operation'>
112
103
  <Button
113
104
  onClick={() => {
114
105
  setItemWidthsIndex(prev => (prev + 1) % itemWidths.length)
115
106
  }}
116
- text={`itemWidth: ${itemWidths[itemWidthsIndex]}`}
117
- >
118
- </Button>
107
+ text='Change Item Width'
108
+ subText={`ItemWidth: ${itemWidths[itemWidthsIndex]}`}
109
+ />
119
110
  <Button
120
111
  onClick={() => {
121
112
  setAlignIndex(prev => (prev + 1) % itemWidths.length)
122
113
  }}
123
- text={`alignType: ${alignArr[alignIndex]}`}
124
- >
125
- </Button>
114
+ text='Change Align Type'
115
+ subText={`AlignType: ${alignArr[alignIndex]}`}
116
+ />
126
117
  </view>
127
118
  </view>
128
119
  )
@@ -2,7 +2,7 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import { root, useRef } from '@lynx-js/react'
5
+ import { root, useRef, useState } from '@lynx-js/react'
6
6
 
7
7
  import {
8
8
  Swiper,
@@ -12,9 +12,12 @@ import {
12
12
  } from '@lynx-js/lynx-ui'
13
13
  import type { SwiperRef } from '@lynx-js/lynx-ui'
14
14
 
15
- import './styles.css'
15
+ import { Card } from '../Common/Card'
16
+ import { Indicator } from '../Common/Indicator'
16
17
 
17
- const colorsArr: string[] = ['red', 'green', 'yellow', 'purple']
18
+ import '../Common/Demo/styles.css'
19
+
20
+ const itemArr: number[] = [1, 2, 3, 4, 5]
18
21
 
19
22
  const ITEM_WIDTH = 250
20
23
 
@@ -62,50 +65,49 @@ function customAnimationFirstScreen(value: number, _index: number) {
62
65
 
63
66
  function SwiperEntry(): JSX.Element {
64
67
  const swiperRef = useRef<SwiperRef>(null)
68
+ const [currentIndex, setCurrentIndex] = useState(0)
65
69
 
66
70
  return (
67
- <view id='container'>
68
- <Swiper
69
- ref={swiperRef}
70
- data={colorsArr}
71
- itemWidth={ITEM_WIDTH}
72
- itemHeight={200}
73
- duration={500}
74
- initialIndex={0}
75
- mode='custom'
76
- modeConfig={{
77
- align: 'center',
78
- }}
79
- RTL={true}
80
- main-thread:customAnimation={customAnimation}
81
- customAnimationFirstScreen={customAnimationFirstScreen}
82
- >
83
- {({ item, index, realIndex }) => (
84
- <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
85
- <view
86
- class='block-view'
87
- style={{
88
- width: '100%',
89
- height: '100%',
90
- backgroundColor: item,
91
- display: 'flex',
92
- justifyContent: 'center',
93
- alignItems: 'center',
94
- }}
95
- >
96
- <view
71
+ <view className='demo-container lunaris-dark'>
72
+ <view className='top-area' />
73
+ <view className='content-area'>
74
+ <Swiper
75
+ ref={swiperRef}
76
+ data={itemArr}
77
+ itemWidth={ITEM_WIDTH}
78
+ itemHeight={250}
79
+ duration={500}
80
+ initialIndex={0}
81
+ mode='custom'
82
+ modeConfig={{
83
+ align: 'center',
84
+ }}
85
+ RTL={true}
86
+ onChange={setCurrentIndex}
87
+ main-thread:customAnimation={customAnimation}
88
+ customAnimationFirstScreen={customAnimationFirstScreen}
89
+ style={{
90
+ overflow: 'visible',
91
+ }}
92
+ >
93
+ {({ index }) => (
94
+ <SwiperItem>
95
+ <Card
96
+ index={index}
97
97
  style={{
98
- backgroundColor: 'white',
99
- width: '4px',
100
- height: '4px',
98
+ height: '250px',
101
99
  }}
102
- >
103
- </view>
104
- </view>
105
- <text class='image-text'>Number.{index}</text>
106
- </SwiperItem>
107
- )}
108
- </Swiper>
100
+ />
101
+ </SwiperItem>
102
+ )}
103
+ </Swiper>
104
+ <Indicator current={currentIndex} count={itemArr.length} />
105
+ </view>
106
+ <view className='demo-status'>
107
+ <text className='demo-status-text'>
108
+ RTL custom mode mirrors the same centered scale animation.
109
+ </text>
110
+ </view>
109
111
  </view>
110
112
  )
111
113
  }
@@ -2,32 +2,4 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import './styles.css'
6
- import { Button as ButtonInner } from '@lynx-js/lynx-ui'
7
-
8
- const ButtonStyle = {
9
- border: '1px solid',
10
- 'border-radius': '4px',
11
- width: '150px',
12
- 'background-color': 'red',
13
- margin: '4px 8px',
14
- padding: '4px 8px',
15
- }
16
-
17
- const ButtonTextStyle = {
18
- color: 'white',
19
- }
20
-
21
- export function Button(props: {
22
- onClick: () => void
23
- text: string
24
- }) {
25
- return (
26
- <ButtonInner
27
- style={ButtonStyle}
28
- onClick={props.onClick}
29
- >
30
- <text style={ButtonTextStyle}>{props.text}</text>
31
- </ButtonInner>
32
- )
33
- }
5
+ export { Button } from '../Common/Button'
package/RTLLoop/index.tsx CHANGED
@@ -7,19 +7,13 @@ import { root, useRef, useState } from '@lynx-js/react'
7
7
  import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
8
  import type { SwiperRef } from '@lynx-js/lynx-ui'
9
9
 
10
- import './styles.css'
10
+ import { Button } from '../Common/Button'
11
+ import { Card } from '../Common/Card'
12
+ import { Indicator } from '../Common/Indicator'
11
13
 
12
- import { Button } from './Button'
14
+ import '../Common/Demo/styles.css'
13
15
 
14
- const colorsArr: string[] = [
15
- 'red',
16
- 'green',
17
- 'yellow',
18
- 'purple',
19
- 'lightblue',
20
- 'lightgreen',
21
- 'lightyellow',
22
- ]
16
+ const itemArr: number[] = [1, 2, 3, 4, 5, 6, 7]
23
17
 
24
18
  const itemWidths = [250, 350, 400]
25
19
  const alignArr: ['start', 'center', 'end'] = ['start', 'center', 'end']
@@ -31,81 +25,78 @@ function SwiperEntry(): JSX.Element {
31
25
  const swiperRef = useRef<SwiperRef>(null)
32
26
 
33
27
  return (
34
- <view id='container'>
35
- <Swiper
36
- ref={swiperRef}
37
- data={colorsArr}
38
- itemWidth={itemWidths[itemWidthsIndex] ?? 0}
39
- itemHeight={200}
40
- duration={500}
41
- initialIndex={0}
42
- onChange={setCurrentIndex}
43
- mode='normal'
44
- modeConfig={{
45
- align: alignArr[alignIndex] ?? 'start',
46
- spaceBetween: 8,
47
- }}
48
- RTL={true}
49
- loop={true}
50
- >
51
- {({ item, index, realIndex }) => (
52
- <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
53
- <view
54
- class='block-view'
55
- style={{
56
- width: '100%',
57
- height: '100%',
58
- backgroundColor: item,
59
- display: 'flex',
60
- justifyContent: 'center',
61
- alignItems: 'center',
62
- }}
63
- >
64
- <view
28
+ <view className='demo-container lunaris-dark'>
29
+ <view className='top-area' />
30
+ <view className='content-area'>
31
+ <Swiper
32
+ ref={swiperRef}
33
+ data={itemArr}
34
+ itemWidth={itemWidths[itemWidthsIndex] ?? 0}
35
+ itemHeight={250}
36
+ containerWidth={lynx.__globalProps.screenWidth - 32
37
+ || SystemInfo.pixelWidth / SystemInfo.pixelRatio - 32}
38
+ duration={500}
39
+ initialIndex={0}
40
+ onChange={setCurrentIndex}
41
+ mode='normal'
42
+ modeConfig={{
43
+ align: alignArr[alignIndex] ?? 'start',
44
+ spaceBetween: 16,
45
+ }}
46
+ RTL={true}
47
+ loop={true}
48
+ style={{
49
+ overflow: 'visible',
50
+ }}
51
+ >
52
+ {({ index }) => (
53
+ <SwiperItem>
54
+ <Card
55
+ index={index}
65
56
  style={{
66
- backgroundColor: 'white',
67
- width: '4px',
68
- height: '4px',
57
+ height: '250px',
69
58
  }}
70
- >
71
- </view>
72
- </view>
73
- <text class='image-text'>Number.{index}</text>
74
- </SwiperItem>
75
- )}
76
- </Swiper>
77
- <view class='operation'>
78
- <view class='block'>
79
- <text>Current Index: {currentIndex}</text>
80
- </view>
59
+ />
60
+ </SwiperItem>
61
+ )}
62
+ </Swiper>
63
+ <Indicator
64
+ current={currentIndex}
65
+ count={itemArr.length}
66
+ />
67
+ </view>
68
+ <view className='operation'>
81
69
  <Button
82
70
  onClick={() => {
83
71
  swiperRef.current?.swipePrev()
84
72
  }}
73
+ className='expand'
85
74
  text='SwipePrev'
86
- >
87
- </Button>
75
+ />
88
76
  <Button
89
77
  onClick={() => {
90
78
  swiperRef.current?.swipeNext()
91
79
  }}
80
+ className='expand'
81
+ type='primary'
92
82
  text='SwipeNext'
93
- >
94
- </Button>
83
+ />
84
+ </view>
85
+ <view className='sub-operation'>
95
86
  <Button
96
87
  onClick={() => {
97
88
  setItemWidthsIndex(prev => (prev + 1) % itemWidths.length)
98
89
  }}
99
- text={`itemWidth: ${itemWidths[itemWidthsIndex]}`}
100
- >
101
- </Button>
90
+ text='Change Item Width'
91
+ subText={`ItemWidth: ${itemWidths[itemWidthsIndex]}`}
92
+ />
102
93
  <Button
103
94
  onClick={() => {
104
95
  setAlignIndex(prev => (prev + 1) % itemWidths.length)
105
96
  }}
106
- text={`alignType: ${alignArr[alignIndex]}`}
107
- >
108
- </Button>
97
+ text='Change Align Type'
98
+ subText={`AlignType: ${alignArr[alignIndex]}`}
99
+ />
109
100
  </view>
110
101
  </view>
111
102
  )
@@ -2,32 +2,4 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import './styles.css'
6
- import { Button as ButtonInner } from '@lynx-js/lynx-ui'
7
-
8
- const ButtonStyle = {
9
- border: '1px solid',
10
- 'border-radius': '4px',
11
- width: '150px',
12
- 'background-color': 'red',
13
- margin: '4px 8px',
14
- padding: '4px 8px',
15
- }
16
-
17
- const ButtonTextStyle = {
18
- color: 'white',
19
- }
20
-
21
- export function Button(props: {
22
- onClick: () => void
23
- text: string
24
- }) {
25
- return (
26
- <ButtonInner
27
- style={ButtonStyle}
28
- onClick={props.onClick}
29
- >
30
- <text style={ButtonTextStyle}>{props.text}</text>
31
- </ButtonInner>
32
- )
33
- }
5
+ export { Button } from '../Common/Button'