-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
891 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
import { | ||
Blur, | ||
Canvas, | ||
Circle, | ||
ColorMatrix, | ||
Group, | ||
Image, | ||
ImageSVG, | ||
Paint, | ||
RadialGradient, | ||
Shadow, | ||
fitbox, | ||
rect, | ||
useImage, | ||
useSVG, | ||
vec, | ||
} from "@shopify/react-native-skia"; | ||
import React from "react"; | ||
import { View, useWindowDimensions } from "react-native"; | ||
import { | ||
Easing, | ||
runOnJS, | ||
useDerivedValue, | ||
useSharedValue, | ||
withDelay, | ||
withSequence, | ||
withSpring, | ||
withTiming, | ||
} from "react-native-reanimated"; | ||
|
||
import { palette, sharedStyles as ss } from "@/src/styles"; | ||
import { router } from "expo-router"; | ||
import { useSafeAreaInsets } from "react-native-safe-area-context"; | ||
|
||
function Orb({ cx, cy, r }: { cx: number; cy: number; r: number }) { | ||
const win = useWindowDimensions(); | ||
|
||
const fullHeight = win.height; // + insets.top + insets.bottom; | ||
|
||
const radius = useSharedValue(0); | ||
const shadowPos = useDerivedValue(() => { | ||
return radius.value / 5; | ||
}); | ||
const shadowNeg = useDerivedValue(() => { | ||
return -radius.value / 5; | ||
}); | ||
const shadowBlur = (r / 80) * 10; | ||
|
||
const computedelayMs = fullHeight - cy + cx * 4; | ||
|
||
React.useEffect(() => { | ||
radius.value = withDelay( | ||
computedelayMs, | ||
withSpring(r, { | ||
mass: 1.2, | ||
damping: 10, | ||
stiffness: 100, | ||
restDisplacementThreshold: 0.01, | ||
restSpeedThreshold: 2, | ||
}), | ||
); | ||
}, []); | ||
|
||
return ( | ||
<Circle cx={cx} cy={cy} r={radius}> | ||
<Shadow | ||
dx={shadowPos} | ||
dy={shadowPos} | ||
blur={shadowBlur} | ||
color={palette.purple} | ||
inner | ||
/> | ||
<Shadow | ||
dx={shadowNeg} | ||
dy={shadowNeg} | ||
blur={shadowBlur} | ||
color={palette.blue} | ||
inner | ||
/> | ||
<RadialGradient | ||
c={vec(cx, cy)} | ||
r={radius} | ||
colors={[palette.redShade3, palette.black]} | ||
/> | ||
<Blur blur={Math.floor((cy * 2) / fullHeight) * 1} /> | ||
</Circle> | ||
); | ||
} | ||
|
||
export default function IntroScreen() { | ||
const win = useWindowDimensions(); | ||
const insets = useSafeAreaInsets(); | ||
|
||
const fullHeight = win.height + insets.top + insets.bottom; | ||
const fullWidth = win.width + insets.left + insets.right; | ||
|
||
const opacity = useSharedValue(0); | ||
|
||
const backgroundEarthPng = useImage( | ||
require("@/assets/images/view-of-earth.png"), | ||
); | ||
const backgroundPanX = useSharedValue(0); | ||
const orbsPanTransform = useDerivedValue(() => { | ||
return [{ translateX: backgroundPanX.value }]; | ||
}); | ||
|
||
const conduitWordMarkSvg = useSVG( | ||
require("@/assets/images/psiphon-conduit-wordmark.svg"), | ||
); | ||
const originalWordMarkWidth = 141; | ||
const originalWordMarkHeight = 44; | ||
const wordMarkSrc = rect( | ||
0, | ||
0, | ||
originalWordMarkWidth, | ||
originalWordMarkHeight, | ||
); | ||
const wordMarkDst = rect( | ||
fullWidth * 0.1, | ||
fullHeight * 0.1, | ||
fullWidth * 0.8, | ||
fullHeight * 0.2, | ||
); | ||
const wordMarkResizeTransform = fitbox("contain", wordMarkSrc, wordMarkDst); | ||
|
||
React.useEffect(() => { | ||
opacity.value = withSequence( | ||
withTiming(1, { duration: 1000 }), | ||
withDelay( | ||
3000, | ||
withTiming(0, { duration: 1000 }, () => { | ||
runOnJS(router.replace)("/(app)/onboarding"); | ||
}), | ||
), | ||
); | ||
backgroundPanX.value = withTiming(-win.width, { | ||
duration: 5000, | ||
easing: Easing.inOut(Easing.ease), | ||
}); | ||
}, []); | ||
|
||
const opacityMatrix = useDerivedValue(() => { | ||
// prettier-ignore | ||
return [ | ||
// R, G, B, A, Bias | ||
1, 0, 0, 0, 0, | ||
0, 1, 0, 0, 0, | ||
0, 0, 1, 0, 0, | ||
0, 0, 0, opacity.value, 0, | ||
]; | ||
}); | ||
|
||
if (!backgroundEarthPng) { | ||
return null; | ||
} | ||
|
||
const bgWidth = win.width * 2; | ||
const bgHeight = | ||
(bgWidth / backgroundEarthPng.width()) * backgroundEarthPng.height(); | ||
|
||
return ( | ||
<View | ||
style={{ | ||
width: fullWidth, | ||
height: fullHeight, | ||
}} | ||
> | ||
<Canvas style={[ss.flex]}> | ||
<Image | ||
image={backgroundEarthPng} | ||
fit="fitHeight" | ||
x={backgroundPanX} | ||
y={0} | ||
width={bgWidth} | ||
height={bgHeight} | ||
opacity={opacity} | ||
/> | ||
<Group | ||
layer={ | ||
<Paint> | ||
<ColorMatrix matrix={opacityMatrix} /> | ||
</Paint> | ||
} | ||
> | ||
<Group transform={wordMarkResizeTransform}> | ||
<ImageSVG svg={conduitWordMarkSvg} x={0} y={0} /> | ||
</Group> | ||
</Group> | ||
<Group transform={orbsPanTransform} opacity={opacity}> | ||
<Orb cx={fullWidth * 0.2} cy={fullHeight * 0.9} r={50} /> | ||
<Orb cx={fullWidth * 0.1} cy={fullHeight * 0.66} r={20} /> | ||
<Orb cx={fullWidth * 0.42} cy={fullHeight * 0.61} r={15} /> | ||
<Orb cx={fullWidth * 0.4} cy={fullHeight * 0.75} r={35} /> | ||
<Orb cx={fullWidth * 0.65} cy={fullHeight * 0.95} r={59} /> | ||
<Orb cx={fullWidth * 1.3} cy={fullHeight * 0.9} r={80} /> | ||
<Orb cx={fullWidth * 0.72} cy={fullHeight * 0.58} r={17} /> | ||
<Orb cx={fullWidth * 0.78} cy={fullHeight * 0.78} r={40} /> | ||
<Orb cx={fullWidth * 1.25} cy={fullHeight * 0.66} r={30} /> | ||
<Orb cx={fullWidth * 1.05} cy={fullHeight * 0.56} r={12} /> | ||
<Orb cx={fullWidth * 1.5} cy={fullHeight * 0.54} r={11} /> | ||
<Orb cx={fullWidth * 1.8} cy={fullHeight * 0.8} r={66} /> | ||
<Orb cx={fullWidth * 1.8} cy={fullHeight * 0.6} r={27} /> | ||
</Group> | ||
</Canvas> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.