Skip to content

Commit

Permalink
feat. maskedView
Browse files Browse the repository at this point in the history
  • Loading branch information
devym-37 committed Jun 29, 2022
1 parent 9edde7f commit 671c2aa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
9 changes: 9 additions & 0 deletions reanimatedRN/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Transitions from "./src/Transitions";
import FlatList from "./src/FlatList";
import StickyFooter from "./src/StickyFooter";
import ProgressBar from "./src/ProgressBar";
import MaskedView from "./src/MaskedView";

const Stack = createStackNavigator();

Expand Down Expand Up @@ -91,6 +92,14 @@ const AppNavigator = () => (
header: () => null,
}}
/>
<Stack.Screen
name='MaskedView'
component={MaskedView}
options={{
title: "MaskedView",
header: () => null,
}}
/>
</Stack.Navigator>
);

Expand Down
3 changes: 3 additions & 0 deletions reanimatedRN/src/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const Main = ({ navigation }: any) => {
<Pressable onPress={() => navigation.navigate("ProgressBar")} style={styles.buttonContainer}>
<Text style={styles.text}>ProgressBar</Text>
</Pressable>
<Pressable onPress={() => navigation.navigate("Masked View")} style={styles.buttonContainer}>
<Text style={styles.text}>Masked View</Text>
</Pressable>
</View>
</ScrollView>
);
Expand Down
45 changes: 45 additions & 0 deletions reanimatedRN/src/MaskedView/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react";
import { View, Image } from "react-native";
import MaskedView from "@react-native-community/masked-view";

interface ComponentProps {
ring: Ring;
}

type Color = string;

interface Ring {
start: Color;
end: Color;
bg: Color;
theta: number;
size: number;
}

export default ({ ring }: ComponentProps) => {
const maskElement = (
<Image
style={{
width: ring.size,
height: ring.size,
backgroundColor: "transparent",
borderRadius: ring.size / 2,
}}
source={require("./mask.png")}
/>
);
return (
<View
style={{
width: ring.size,
height: ring.size,
borderRadius: ring.size / 2,
backgroundColor: ring.start,
}}
>
<MaskedView style={{ flex: 1, backgroundColor: "transparent" }} {...{ maskElement }}>
<View style={{ flex: 1, borderRadius: ring.size / 2, backgroundColor: ring.start }} />
</MaskedView>
</View>
);
};
Binary file added reanimatedRN/src/MaskedView/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion reanimatedRN/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@

"@react-native-community/masked-view@^0.1.11":
version "0.1.11"
resolved "https://registry.npmjs.org/@react-native-community/masked-view/-/masked-view-0.1.11.tgz"
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.11.tgz#2f4c6e10bee0786abff4604e39a37ded6f3980ce"
integrity sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw==

"@react-native/[email protected]":
Expand Down

0 comments on commit 671c2aa

Please sign in to comment.