@momo-kits/carousel 0.79.6 → 0.80.1-beta.2

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.
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- import Carousel from './CarouselV2';
2
- import Pagination from './pagination/Pagination';
3
- import NumberPagination from './pagination/NumberPagination';
4
-
5
- export {Carousel, Pagination, NumberPagination};
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { Colors, Radius, Spacing, Text } from '@momo-kits/core-v2';
3
- import { View, StyleSheet } from 'react-native';
4
- import PropTypes from 'prop-types';
5
-
6
- const NumberPagination = (props) => {
7
- const { dataLength, activeIndex, style } = props;
8
-
9
- return (
10
- <View style={style}>
11
- <View style={styles.container}>
12
- <Text.Label1 style={styles.number}>{`${
13
- activeIndex + 1
14
- }/${dataLength}`}</Text.Label1>
15
- </View>
16
- </View>
17
- );
18
- };
19
-
20
- const styles = StyleSheet.create({
21
- container: {
22
- backgroundColor: Colors.black_08,
23
- alignSelf: 'baseline',
24
- paddingHorizontal: Spacing.S,
25
- borderRadius: Radius.M,
26
- },
27
- number: {
28
- color: Colors.black_01,
29
- },
30
- });
31
-
32
- NumberPagination.defaultProps = {
33
- dataLength: 0,
34
- activeIndex: 0,
35
- };
36
-
37
- NumberPagination.propsType = {
38
- dataLength: PropTypes.number,
39
- activeIndex: PropTypes.number,
40
- style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
41
- };
42
-
43
- export default NumberPagination;
@@ -1,188 +0,0 @@
1
- import React, { PureComponent } from 'react';
2
- import { I18nManager, Platform, View } from 'react-native';
3
- import PropTypes from 'prop-types';
4
- import PaginationDot from './PaginationDot';
5
- import styles from './styles';
6
- import { Colors, Radius, Spacing } from '@momo-kits/core-v2';
7
-
8
- const IS_IOS = Platform.OS === 'ios';
9
- const IS_RTL = I18nManager.isRTL;
10
-
11
- export default class Pagination extends PureComponent {
12
- constructor(props) {
13
- super(props);
14
-
15
- // Warnings
16
- if (
17
- (props.dotColor && !props.inactiveDotColor) ||
18
- (!props.dotColor && props.inactiveDotColor)
19
- ) {
20
- console.warn(
21
- 'react-native-snap-carousel | Pagination: ' +
22
- 'You need to specify both `dotColor` and `inactiveDotColor`',
23
- );
24
- }
25
- if (
26
- (props.dotElement && !props.inactiveDotElement) ||
27
- (!props.dotElement && props.inactiveDotElement)
28
- ) {
29
- console.warn(
30
- 'react-native-snap-carousel | Pagination: ' +
31
- 'You need to specify both `dotElement` and `inactiveDotElement`',
32
- );
33
- }
34
- if (props.tappableDots && !props.carouselRef) {
35
- console.warn(
36
- 'react-native-snap-carousel | Pagination: ' +
37
- 'You must specify prop `carouselRef` when setting `tappableDots` to `true`',
38
- );
39
- }
40
- }
41
-
42
- get _activeDotIndex() {
43
- const { activeDotIndex, dotsLength } = this.props;
44
- return this._needsRTLAdaptations()
45
- ? dotsLength - activeDotIndex - 1
46
- : activeDotIndex;
47
- }
48
-
49
- get dots() {
50
- const {
51
- activeOpacity,
52
- carouselRef,
53
- dotsLength,
54
- dotColor,
55
- dotContainerStyle,
56
- dotElement,
57
- dotStyle,
58
- inactiveDotColor,
59
- inactiveDotElement,
60
- inactiveDotOpacity,
61
- inactiveDotScale,
62
- inactiveDotStyle,
63
- renderDots,
64
- tappableDots,
65
- type,
66
- } = this.props;
67
-
68
- if (renderDots) {
69
- return renderDots(this._activeDotIndex, dotsLength, this);
70
- }
71
-
72
- const DefaultDot = (
73
- <PaginationDot
74
- carouselRef={carouselRef}
75
- tappable={tappableDots && typeof carouselRef !== 'undefined'}
76
- activeOpacity={activeOpacity}
77
- color={dotColor}
78
- containerStyle={dotContainerStyle}
79
- style={dotStyle}
80
- inactiveColor={inactiveDotColor}
81
- inactiveOpacity={inactiveDotOpacity}
82
- inactiveScale={inactiveDotScale}
83
- inactiveStyle={inactiveDotStyle}
84
- type={type}
85
- />
86
- );
87
-
88
- const dots = [];
89
-
90
- for (let i = 0; i < dotsLength; i += 1) {
91
- const isActive = i === this._activeDotIndex;
92
- dots.push(
93
- React.cloneElement(
94
- (isActive ? dotElement : inactiveDotElement) || DefaultDot,
95
- {
96
- key: `pagination-dot-${i}`,
97
- active: i === this._activeDotIndex,
98
- index: i,
99
- },
100
- ),
101
- );
102
- }
103
-
104
- return dots;
105
- }
106
-
107
- _needsRTLAdaptations() {
108
- const { vertical } = this.props;
109
- return IS_RTL && !IS_IOS && !vertical;
110
- }
111
-
112
- render() {
113
- const {
114
- dotsLength,
115
- containerStyle,
116
- vertical,
117
- accessibilityLabel,
118
- type,
119
- } = this.props;
120
-
121
- if (!dotsLength || dotsLength < 2) {
122
- return false;
123
- }
124
-
125
- const style = [
126
- styles.sliderPagination,
127
- {
128
- flexDirection: vertical
129
- ? 'column'
130
- : this._needsRTLAdaptations()
131
- ? 'row-reverse'
132
- : 'row',
133
- },
134
- containerStyle || {},
135
- ];
136
-
137
- return (
138
- <View
139
- pointerEvents="box-none"
140
- style={style}
141
- accessible={!!accessibilityLabel}
142
- accessibilityLabel={accessibilityLabel}>
143
- <View
144
- style={[
145
- {
146
- flexDirection: 'row',
147
- padding: Spacing.XS,
148
- borderRadius: Radius.S,
149
- },
150
- type === 'light'
151
- ? {}
152
- : { backgroundColor: Colors.opacity_02_white_20 },
153
- ]}>
154
- {this.dots}
155
- </View>
156
- </View>
157
- );
158
- }
159
- }
160
- Pagination.propTypes = {
161
- activeDotIndex: PropTypes.number.isRequired,
162
- dotsLength: PropTypes.number.isRequired,
163
- activeOpacity: PropTypes.number,
164
- carouselRef: PropTypes.object,
165
- dotColor: PropTypes.string,
166
- dotElement: PropTypes.element,
167
- dotStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
168
- inactiveDotColor: PropTypes.string,
169
- inactiveDotElement: PropTypes.element,
170
- inactiveDotOpacity: PropTypes.number,
171
- inactiveDotScale: PropTypes.number,
172
- inactiveDotStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
173
- renderDots: PropTypes.func,
174
- tappableDots: PropTypes.bool,
175
- vertical: PropTypes.bool,
176
- accessibilityLabel: PropTypes.string,
177
- containerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
178
- dotContainerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
179
- type: PropTypes.oneOf(['light', 'dark']),
180
- };
181
-
182
- Pagination.defaultProps = {
183
- inactiveDotOpacity: 0.5,
184
- inactiveDotScale: 0.5,
185
- tappableDots: false,
186
- vertical: false,
187
- type: 'light',
188
- };
@@ -1,151 +0,0 @@
1
- import React, { PureComponent } from 'react';
2
- import { Animated, Easing, TouchableOpacity } from 'react-native';
3
- import PropTypes from 'prop-types';
4
- import styles from './styles';
5
- import { Colors } from '@momo-kits/core-v2';
6
-
7
- export default class PaginationDot extends PureComponent {
8
- constructor(props) {
9
- super(props);
10
- this.state = {
11
- animColor: new Animated.Value(0),
12
- animOpacity: new Animated.Value(0),
13
- animTransform: new Animated.Value(0),
14
- };
15
- }
16
-
17
- get _shouldAnimateColor() {
18
- const { color, inactiveColor } = this.props;
19
- return color && inactiveColor;
20
- }
21
-
22
- componentDidMount() {
23
- const { active } = this.props;
24
- if (active) {
25
- this._animate(1);
26
- }
27
- }
28
-
29
- UNSAFE_componentWillReceiveProps(nextProps) {
30
- const { active } = this.props;
31
- if (nextProps.active !== active) {
32
- this._animate(nextProps.active ? 1 : 0);
33
- }
34
- }
35
-
36
- _animate(toValue = 0) {
37
- const { animColor, animOpacity, animTransform } = this.state;
38
-
39
- const commonProperties = {
40
- toValue,
41
- duration: 250,
42
- isInteraction: false,
43
- useNativeDriver: false,
44
- };
45
-
46
- const animations = [
47
- Animated.timing(animOpacity, {
48
- easing: Easing.linear,
49
- ...commonProperties,
50
- }),
51
- Animated.spring(animTransform, {
52
- // friction: 4,
53
- tension: 50,
54
- ...commonProperties,
55
- }),
56
- ];
57
-
58
- if (this._shouldAnimateColor) {
59
- animations.push(
60
- Animated.timing(animColor, {
61
- easing: Easing.linear,
62
- ...commonProperties,
63
- }),
64
- );
65
- }
66
-
67
- Animated.parallel(animations).start();
68
- }
69
-
70
- render() {
71
- const { animColor, animOpacity, animTransform } = this.state;
72
- const {
73
- active,
74
- activeOpacity,
75
- carouselRef,
76
- color,
77
- containerStyle,
78
- inactiveColor,
79
- inactiveStyle,
80
- inactiveOpacity,
81
- index,
82
- style,
83
- tappable,
84
- type,
85
- } = this.props;
86
-
87
- const animatedStyle = {
88
- opacity: animOpacity.interpolate({
89
- inputRange: [0, 1],
90
- outputRange: [inactiveOpacity, 1],
91
- }),
92
- width: animTransform.interpolate({
93
- inputRange: [0, 1],
94
- outputRange: [4, 12],
95
- }),
96
- };
97
- const animatedColor = this._shouldAnimateColor
98
- ? {
99
- backgroundColor: animColor.interpolate({
100
- inputRange: [0, 1],
101
- outputRange: [inactiveColor, color],
102
- }),
103
- }
104
- : {};
105
-
106
- const dotContainerStyle = [
107
- styles.sliderPaginationDotContainer,
108
- containerStyle || {},
109
- ];
110
-
111
- const dotStyle = [
112
- styles.sliderPaginationDot,
113
- style || {},
114
- (!active && inactiveStyle) || {},
115
- !active && { backgroundColor: Colors.black_10 },
116
- animatedStyle,
117
- type === 'light'
118
- ? animatedColor
119
- : { backgroundColor: Colors.black_01 },
120
- ];
121
-
122
- const onPress = tappable
123
- ? () =>
124
- carouselRef &&
125
- carouselRef._snapToItem(carouselRef._getPositionIndex(index))
126
- : undefined;
127
-
128
- return (
129
- <TouchableOpacity
130
- accessible={false}
131
- style={dotContainerStyle}
132
- activeOpacity={tappable ? activeOpacity : 1}
133
- onPress={onPress}>
134
- <Animated.View style={dotStyle} />
135
- </TouchableOpacity>
136
- );
137
- }
138
- }
139
- PaginationDot.propTypes = {
140
- inactiveOpacity: PropTypes.number.isRequired,
141
- active: PropTypes.bool,
142
- activeOpacity: PropTypes.number,
143
- carouselRef: PropTypes.object,
144
- color: PropTypes.string,
145
- inactiveColor: PropTypes.string,
146
- index: PropTypes.number,
147
- tappable: PropTypes.bool,
148
- style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
149
- containerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
150
- inactiveStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
151
- };
@@ -1,24 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
- import { Colors, Spacing } from '@momo-kits/core-v2';
3
-
4
- const DEFAULT_DOT_SIZE = 4;
5
- const DEFAULT_DOT_COLOR = Colors.pink_03;
6
-
7
- export default StyleSheet.create({
8
- sliderPagination: {
9
- alignItems: 'center',
10
- justifyContent: 'center',
11
- paddingHorizontal: 20,
12
- },
13
- sliderPaginationDotContainer: {
14
- alignItems: 'center',
15
- justifyContent: 'center',
16
- marginHorizontal: Spacing.XS,
17
- },
18
- sliderPaginationDot: {
19
- width: DEFAULT_DOT_SIZE,
20
- height: DEFAULT_DOT_SIZE,
21
- borderRadius: DEFAULT_DOT_SIZE / 2,
22
- backgroundColor: DEFAULT_DOT_COLOR,
23
- },
24
- });
package/styles.js DELETED
@@ -1,189 +0,0 @@
1
-
2
- import {
3
- StyleSheet, Dimensions, Platform
4
- } from 'react-native';
5
-
6
- const IS_IOS = Platform.OS === 'ios';
7
- const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');
8
-
9
- function wp(percentage) {
10
- const value = (percentage * viewportWidth) / 100;
11
- return Math.round(value);
12
- }
13
-
14
- const slideHeight = viewportHeight * 0.36;
15
- const slideWidth = wp(75);
16
- const itemHorizontalMargin = wp(2);
17
-
18
- export const sliderWidth = viewportWidth;
19
- export const itemWidth = slideWidth + itemHorizontalMargin * 2;
20
-
21
- const entryBorderRadius = 8;
22
-
23
- const styles = StyleSheet.create({
24
- container: {
25
- flex: 1
26
- },
27
- contentView: {
28
- paddingTop: 20,
29
- backgroundColor: '#1a191c'
30
- },
31
- divide: {
32
- width: viewportWidth,
33
- height: 30
34
- },
35
- txtHeading: {
36
- marginVertical: 15,
37
- marginLeft: 10,
38
- fontSize: 15,
39
- color: '#000'
40
- },
41
- dotsArea: {
42
- paddingVertical: 5,
43
- position: 'absolute',
44
- left: 0,
45
- right: 0,
46
- bottom: 0
47
- },
48
- dotContainer: {
49
- borderWidth: 1,
50
- borderColor: '#DADADA',
51
- width: 8,
52
- height: 8,
53
- borderRadius: 4,
54
- marginHorizontal: 5
55
- },
56
- safeArea: {
57
- flex: 1,
58
- backgroundColor: '#000'
59
- },
60
- gradient: {
61
- ...StyleSheet.absoluteFillObject
62
- },
63
- scrollview: {
64
- flex: 1
65
- },
66
- exampleContainer: {
67
- paddingVertical: 30
68
- },
69
- exampleContainerDark: {
70
- backgroundColor: '#F3F3F3'
71
- },
72
- exampleContainerLight: {
73
- backgroundColor: 'transparent'
74
- },
75
- title: {
76
- paddingHorizontal: 30,
77
- backgroundColor: 'transparent',
78
- color: '#000',
79
- fontSize: 20,
80
- fontWeight: 'bold',
81
- textAlign: 'center'
82
- },
83
- titleDark: {
84
- color: '#000'
85
- },
86
- subtitle: {
87
- marginTop: 5,
88
- paddingHorizontal: 30,
89
- backgroundColor: 'transparent',
90
- color: '#000',
91
- fontSize: 13,
92
- fontStyle: 'italic',
93
- textAlign: 'center'
94
- },
95
- slider: {
96
- marginTop: 15,
97
- overflow: 'visible' // for custom animations
98
- },
99
- sliderContentContainer: {
100
- paddingVertical: 10 // for custom animation
101
- },
102
- paginationContainer: {
103
- paddingVertical: 8
104
- },
105
- paginationDot: {
106
- width: 8,
107
- height: 8,
108
- borderRadius: 4,
109
- marginHorizontal: 8
110
- },
111
- slideInnerContainer: {
112
- width: itemWidth,
113
- height: slideHeight,
114
- paddingHorizontal: itemHorizontalMargin,
115
- paddingBottom: 18 // needed for shadow
116
- },
117
- shadow: {
118
- position: 'absolute',
119
- top: 0,
120
- left: itemHorizontalMargin,
121
- right: itemHorizontalMargin,
122
- bottom: 18,
123
- shadowColor: '#000',
124
- shadowOpacity: 0.25,
125
- shadowOffset: { width: 0, height: 10 },
126
- shadowRadius: 10,
127
- borderRadius: entryBorderRadius
128
- },
129
- imageContainer: {
130
- flex: 1,
131
- marginBottom: IS_IOS ? 0 : -1, // Prevent a random Android rendering issue
132
- backgroundColor: 'white',
133
- borderTopLeftRadius: entryBorderRadius,
134
- borderTopRightRadius: entryBorderRadius
135
- },
136
- imageContainerEven: {
137
- backgroundColor: '#000'
138
- },
139
- image: {
140
- ...StyleSheet.absoluteFillObject,
141
- resizeMode: 'cover',
142
- borderRadius: IS_IOS ? entryBorderRadius : 0,
143
- borderTopLeftRadius: entryBorderRadius,
144
- borderTopRightRadius: entryBorderRadius
145
- },
146
- // image's border radius is buggy on iOS; let's hack it!
147
- radiusMask: {
148
- position: 'absolute',
149
- bottom: 0,
150
- left: 0,
151
- right: 0,
152
- height: entryBorderRadius,
153
- backgroundColor: 'white'
154
- },
155
- radiusMaskEven: {
156
- backgroundColor: '#000'
157
- },
158
- textContainer: {
159
- justifyContent: 'center',
160
- paddingTop: 20 - entryBorderRadius,
161
- paddingBottom: 20,
162
- paddingHorizontal: 16,
163
- backgroundColor: 'white',
164
- borderBottomLeftRadius: entryBorderRadius,
165
- borderBottomRightRadius: entryBorderRadius
166
- },
167
- textContainerEven: {
168
- backgroundColor: '#000'
169
- },
170
- titleItem: {
171
- color: '#000',
172
- fontSize: 13,
173
- fontWeight: 'bold',
174
- letterSpacing: 0.5
175
- },
176
- titleEven: {
177
- color: 'white'
178
- },
179
- subtitleItem: {
180
- marginTop: 6,
181
- color: 'black',
182
- fontSize: 12,
183
- fontStyle: 'italic'
184
- },
185
- subtitleEven: {
186
- color: 'rgba(255, 255, 255, 0.7)'
187
- }
188
- });
189
- export default styles;