Skip to content

Commit 988f401

Browse files
authored
Merge pull request #510 from dohooo/develop
Develop
2 parents fd1f4a6 + 766e267 commit 988f401

File tree

92 files changed

+12674
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+12674
-87
lines changed
Lines changed: 5 additions & 0 deletions

.changeset/thick-ties-think.md

Lines changed: 5 additions & 0 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ lib/
6565
!.yarn/plugins
6666
!.yarn/releases
6767
!.yarn/sdks
68-
!.yarn/versions
68+
!.yarn/versions

example/app/.gitignore

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# VSCode
6+
.vscode/
7+
jsconfig.json
8+
9+
# Xcode
10+
#
11+
build/
12+
*.pbxuser
13+
!default.pbxuser
14+
*.mode1v3
15+
!default.mode1v3
16+
*.mode2v3
17+
!default.mode2v3
18+
*.perspectivev3
19+
!default.perspectivev3
20+
xcuserdata
21+
*.xccheckout
22+
*.moved-aside
23+
DerivedData
24+
*.hmap
25+
*.ipa
26+
*.xcuserstate
27+
project.xcworkspace
28+
29+
# Android/IJ
30+
#
31+
.idea
32+
.gradle
33+
local.properties
34+
android.iml
35+
36+
# Cocoapods
37+
#
38+
exampleBare/ios/Pods
39+
40+
# node.js
41+
#
42+
node_modules/
43+
scripts/gif-works-directory/*
44+
npm-debug.log
45+
yarn-debug.log
46+
yarn-error.log
47+
\.env
48+
49+
# BUCK
50+
buck-out/
51+
\.buckd/
52+
android/app/libs
53+
android/keystores/debug.keystore
54+
55+
# Expo
56+
.expo/*
57+
web-build
58+
59+
# generated by bob
60+
lib/
61+
62+
# Yarn
63+
.yarn/*
64+
!.yarn/patches
65+
!.yarn/plugins
66+
!.yarn/releases
67+
!.yarn/sdks
68+
!.yarn/versions

example/app/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
"main": "./src/index",
55
"react-native": "./src/index",
66
"private": true,
7+
"dependencies": {
8+
"@faker-js/faker": "^8.0.2",
9+
"@react-navigation/native": "^6.1.6",
10+
"@react-navigation/native-stack": "^6.9.12",
11+
"@react-navigation/stack": "^6.3.16",
12+
"expo": "^49.0.0",
13+
"expo-blur": "~12.4.1",
14+
"expo-constants": "~14.4.2",
15+
"expo-haptics": "~12.4.0",
16+
"expo-image": "~1.3.5",
17+
"expo-status-bar": "~1.6.0",
18+
"expo-updates": "~0.18.10",
19+
"jest": "^29.2.1",
20+
"jest-expo": "^47.0.1",
21+
"react": "18.2.0",
22+
"react-dom": "18.2.0",
23+
"react-native": "0.72.3",
24+
"react-native-gesture-handler": "~2.12.0",
25+
"react-native-reanimated": "~3.3.0",
26+
"react-native-safe-area-context": "4.6.3",
27+
"react-native-screens": "~3.22.0"
28+
},
729
"peerDependencies": {
830
"@faker-js/faker": "^8.0.2",
931
"@react-navigation/native": "^6.1.6",
@@ -12,6 +34,8 @@
1234
"expo": "^49.0.0",
1335
"expo-blur": "~12.4.1",
1436
"expo-constants": "~14.4.2",
37+
"expo-haptics": "~12.4.0",
38+
"expo-image": "~1.3.5",
1539
"expo-status-bar": "~1.6.0",
1640
"expo-updates": "~0.18.10",
1741
"jest": "^29.2.1",

example/app/src/Home.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import ScaleFadeInOutComponent from "./pages/scale-fade-in-out";
3636
import StackComponent from "./pages/stack";
3737
import StackCards from "./pages/stack-cards";
3838
import Tear from "./pages/tear";
39+
import QuickSwipe from "./pages/quick-swipe";
3940
import { useWebContext } from "./store/WebProvider";
4041
import { convertName } from "./utils/helpers";
4142
import { useColor } from "./hooks/useColor";
@@ -61,6 +62,10 @@ export const LayoutsPage = [
6162
];
6263

6364
export const CustomAnimations = [
65+
{
66+
name: 'quick-swipe',
67+
page: QuickSwipe,
68+
},
6469
{
6570
name: 'tinder',
6671
page: Tinder,
@@ -153,7 +158,7 @@ export const ExperimentPage = [
153158
const ListItem = ({ name, onPress, color }: { name: string; onPress: () => void; color: string }) => (
154159
<TouchableOpacity onPress={onPress}>
155160
<View style={styles.listItem}>
156-
<Text style={[styles.text, { color: color }]}>{convertName(name)}</Text>
161+
<Text style={[styles.text, { color: color }]}>{name.split('-').join(' ')}</Text>
157162
</View>
158163
</TouchableOpacity>
159164
);

example/app/src/components/SBImageItem.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,54 @@ import type {
33
StyleProp,
44
ViewStyle,
55
ImageURISource,
6+
ImageSourcePropType,
67
} from "react-native";
78
import {
89
StyleSheet,
910
View,
1011
ActivityIndicator,
11-
Image,
1212
Text,
1313
} from "react-native";
14+
import { Image } from 'expo-image';
1415

1516
interface Props {
1617
style?: StyleProp<ViewStyle>
1718
index?: number
1819
showIndex?: boolean
20+
img?: ImageSourcePropType
1921
}
2022

2123
export const SBImageItem: React.FC<Props> = ({
2224
style,
2325
index: _index,
2426
showIndex = true,
27+
img
2528
}) => {
26-
const index = (_index || 0) + 1;
29+
const index = _index ?? 0;
2730
const source = React.useRef<ImageURISource>({
2831
uri: `https://picsum.photos/id/${index}/400/300`,
2932
}).current;
3033

3134
return (
3235
<View style={[styles.container, style]}>
3336
<ActivityIndicator size="small" />
34-
<Image key={index} style={styles.image} source={source} />
35-
<Text
36-
style={{
37-
position: "absolute",
38-
color: "white",
39-
fontSize: 40,
40-
backgroundColor: "#333333",
41-
borderRadius: 5,
42-
overflow: "hidden",
43-
paddingHorizontal: 10,
44-
paddingTop: 2,
45-
}}
46-
>
47-
{showIndex ? index : ""}
48-
</Text>
37+
<Image cachePolicy={'memory-disk'} key={index} style={styles.image} source={img ?? source} />
38+
{
39+
showIndex && <Text
40+
style={{
41+
position: "absolute",
42+
color: "#6E6E6E",
43+
fontSize: 40,
44+
backgroundColor: "#EAEAEA",
45+
borderRadius: 5,
46+
overflow: "hidden",
47+
paddingHorizontal: 10,
48+
paddingTop: 2,
49+
}}
50+
>
51+
{index}
52+
</Text>
53+
}
4954
</View>
5055
);
5156
};
@@ -55,15 +60,13 @@ const styles = StyleSheet.create({
5560
flex: 1,
5661
justifyContent: "center",
5762
alignItems: "center",
58-
backgroundColor: "#fff",
63+
backgroundColor: "transparent",
5964
borderRadius: 8,
6065
overflow: "hidden",
6166
},
6267
image: {
68+
width: "100%",
69+
height: "100%",
6370
position: "absolute",
64-
top: 0,
65-
left: 0,
66-
bottom: 0,
67-
right: 0,
6871
},
6972
});

example/app/src/components/SBItem.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import type { StyleProp, ViewStyle, ViewProps } from "react-native";
2+
import type { StyleProp, ViewStyle, ViewProps, ImageSourcePropType } from "react-native";
33
import { LongPressGestureHandler } from "react-native-gesture-handler";
44
import type { AnimateProps } from "react-native-reanimated";
55
import Animated from "react-native-reanimated";
@@ -13,10 +13,12 @@ interface Props extends AnimateProps<ViewProps> {
1313
style?: StyleProp<ViewStyle>
1414
index?: number
1515
pretty?: boolean
16+
showIndex?: boolean
17+
img?: ImageSourcePropType
1618
}
1719

1820
export const SBItem: React.FC<Props> = (props) => {
19-
const { style, index, pretty, testID, ...animatedViewProps } = props;
21+
const { style, showIndex = true, index, pretty, img, testID, ...animatedViewProps } = props;
2022
const enablePretty = Constants?.expoConfig?.extra?.enablePretty || false;
2123
const [isPretty, setIsPretty] = React.useState(pretty || enablePretty);
2224
return (
@@ -26,9 +28,9 @@ export const SBItem: React.FC<Props> = (props) => {
2628
}}
2729
>
2830
<Animated.View testID={testID} style={{ flex: 1 }} {...animatedViewProps}>
29-
{isPretty
31+
{isPretty || img
3032
? (
31-
<SBImageItem style={style} index={index} showIndex={typeof index === "number"} />
33+
<SBImageItem style={style} index={index} showIndex={typeof index === "number" && showIndex} img={img} />
3234
)
3335
: (
3436
<SBTextItem style={style} index={index} />

example/app/src/pages/curve/index.tsx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,6 @@ function Index() {
3838
alignItems: "center",
3939
}}
4040
>
41-
<View
42-
style={{
43-
position: "absolute",
44-
width: 50,
45-
height: 51,
46-
backgroundColor: "white",
47-
borderRadius: 35,
48-
transform: [{ scaleX: 10 }, { scaleY: 2 }],
49-
zIndex: 2,
50-
}}
51-
/>
52-
<View
53-
style={{
54-
position: "absolute",
55-
width: 50,
56-
height: 51,
57-
backgroundColor: "white",
58-
borderRadius: 35,
59-
transform: [{ scaleX: 10 }, { scaleY: 2 }],
60-
zIndex: 2,
61-
top: 145,
62-
}}
63-
/>
6441
<Carousel
6542
{...baseOptions}
6643
loop

example/app/src/pages/normal/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const PAGE_WIDTH = window.width;
1414

1515
function Index() {
1616
const windowWidth = useWindowDimensions().width;
17-
17+
const scrollOffsetValue = useSharedValue<number>(0);
1818
const [data, setData] = React.useState([...new Array(4).keys()]);
1919
const [isVertical, setIsVertical] = React.useState(false);
2020
const [isFast, setIsFast] = React.useState(false);
@@ -34,16 +34,14 @@ function Index() {
3434
height: PAGE_WIDTH / 2,
3535
} as const);
3636

37-
const a = useSharedValue<number>(0);
38-
3937
return (
4038
<SafeAreaView edges={["bottom"]} style={{ flex: 1 }}>
4139
<Carousel
4240
{...baseOptions}
4341
loop
4442
enabled // Default is true, just for demo
4543
ref={ref}
46-
defaultScrollOffsetValue={a}
44+
defaultScrollOffsetValue={scrollOffsetValue}
4745
testID={"xxx"}
4846
style={{ width: "100%" }}
4947
autoPlay={isAutoPlay}

0 commit comments

Comments
 (0)