Skip to content

Instantly share code, notes, and snippets.

@likern
Created March 18, 2022 16:16
Show Gist options
  • Save likern/537b152ea0f3f565411a3265e99263f7 to your computer and use it in GitHub Desktop.
Save likern/537b152ea0f3f565411a3265e99263f7 to your computer and use it in GitHub Desktop.
SkiaPatch
diff --git a/package.json b/package.json
index ca83026..0a9c4f2 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,9 @@
"**/react-native/**",
"**/react-native-web",
"**/react-native-svg",
+ "**/@shopify/react-native-skia",
+ "**/@breeffy/react-native-skia",
+ "**/*react-native-skia*",
"**/react-native-reanimated",
"**/react-native-gesture-handler",
"**/react-native-animateable-text",
@@ -48,5 +51,10 @@
"eslint-plugin-react-hooks": "^4.2.0",
"lerna": "^4.0.0",
"typescript": "^4.5.0-beta"
+ },
+ "dependenciesMeta": {
+ "@breeffy/react-native-skia": {
+ "built": false
+ }
}
}
diff --git a/packages/app/android/app/build.gradle b/packages/app/android/app/build.gradle
index 7844656..89bb6c0 100644
--- a/packages/app/android/app/build.gradle
+++ b/packages/app/android/app/build.gradle
@@ -132,10 +132,10 @@ android {
compileSdkVersion rootProject.ext.compileSdkVersion
packagingOptions {
- pickFirst "lib/x86/libfbjni.so"
- pickFirst "lib/x86_64/libfbjni.so"
- pickFirst "lib/armeabi-v7a/libfbjni.so"
- pickFirst "lib/arm64-v8a/libfbjni.so"
+ def arches = ["armeabi-v7a", "x86", "arm64-v8a", "x86_64"]
+ def libNames = ["libfbjni", "libreact_nativemodule_core", "libjsi", "libturbomodulejsijni"]
+
+ arches.collect { arch -> libNames.collect { lib -> pickFirst "lib/${arch}/${lib}.so" } }
}
defaultConfig {
diff --git a/packages/app/package.json b/packages/app/package.json
index 3a70e51..65f1615 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -9,7 +9,7 @@
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
- "postinstall": "patch-package",
+ "postinstall": "cd node_modules/@breeffy/react-native-skia && node scripts/install-npm.js && cd ../../.. && patch-package",
"postversion": "react-native-version --target android --generate-build",
"svgr": "svgr -d . --ext tsx --expand-props end --native --out-dir ./assets",
"upgrade:reanimated": "bash ./upgrade-reanimated.sh",
@@ -27,6 +27,7 @@
"@breeffy/calendars": "=0.9.0",
"@breeffy/icons": "=0.9.0",
"@breeffy/pickers": "=0.9.0",
+ "@breeffy/react-native-skia": "^0.1.107",
"@breeffy/types": "=0.9.0",
"@breeffy/types-react-native": "=0.9.0",
"@formatjs/intl-datetimeformat": "^1.3.2",
diff --git a/packages/app/src/screens/Charts.tsx b/packages/app/src/screens/Charts.tsx
index 1a207a6..30d0152 100644
--- a/packages/app/src/screens/Charts.tsx
+++ b/packages/app/src/screens/Charts.tsx
@@ -26,6 +26,7 @@ import { SegmentedButtons } from './charts/SegmentedButtons';
//import { BarChart } from 'react-native-gifted-charts';
import { TasksChart } from './charts/TasksChart';
import SegmentedControl from './charts/SegmentedControl';
+import { Canvas, Circle, Group } from '@breeffy/react-native-skia';
interface ScrollableTagsProps {
tags: TaskTagProps[];
@@ -98,6 +99,10 @@ export const Charts = ({ style }: ChartsProps) => {
const [taskTags, setTaskTags] = useState<TaskTagProps[]>([]);
const [tabIndex, setTabIndex] = React.useState(0);
+ const width = 256;
+ const height = 256;
+ const r = 215;
+
useEffect(() => {
tagRepository.find().then(dbTags => {
log.debug(`[Charts] tags are [${JSON.stringify(dbTags)}]`);
@@ -229,6 +234,13 @@ export const Charts = ({ style }: ChartsProps) => {
onChange={index => setTabIndex(index)}
currentIndex={tabIndex}
/>
+ <Canvas style={{ flex: 1, width: width, height: height }}>
+ <Group blendMode='multiply'>
+ <Circle cx={r} cy={r} r={r} color='cyan' />
+ <Circle cx={width - r} cy={r} r={r} color='magenta' />
+ <Circle cx={width / 2} cy={height - r} r={r} color='yellow' />
+ </Group>
+ </Canvas>
</View>
{/* <TasksChart /> */}
</View>
diff --git a/yarn.lock b/yarn.lock
index e82b77b..6556e15 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1683,6 +1683,19 @@ __metadata:
languageName: node
linkType: hard
+"@breeffy/react-native-skia@npm:^0.1.107":
+ version: 0.1.107
+ resolution: "@breeffy/react-native-skia@npm:0.1.107"
+ dependencies:
+ react-reconciler: ^0.26.2
+ peerDependencies:
+ react: ">=16.8.1"
+ react-native: ">=0.63.0-rc.0 <1.0.x"
+ react-native-reanimated: ">=2.0.0"
+ checksum: cd9c2a9e1c6e14ae73cee68c10df3127fbbfdb60e3f52a0ee67bd473d348e16aa8871dca5beb75b079630c15acfdec0d9a7e07f0c0ca94fa532181a85c3aca98
+ languageName: node
+ linkType: hard
+
"@breeffy/types-react-native@npm:=0.9.0":
version: 0.9.0
resolution: "@breeffy/types-react-native@npm:0.9.0"
@@ -1810,6 +1823,7 @@ __metadata:
"@breeffy/calendars": =0.9.0
"@breeffy/icons": =0.9.0
"@breeffy/pickers": =0.9.0
+ "@breeffy/react-native-skia": ^0.1.107
"@breeffy/types": =0.9.0
"@breeffy/types-react-native": =0.9.0
"@formatjs/intl-datetimeformat": ^1.3.2
@@ -1925,6 +1939,9 @@ __metadata:
eslint-plugin-react-hooks: ^4.2.0
lerna: ^4.0.0
typescript: ^4.5.0-beta
+ dependenciesMeta:
+ "@breeffy/react-native-skia":
+ built: false
languageName: unknown
linkType: soft
@@ -15165,6 +15182,19 @@ __metadata:
languageName: node
linkType: hard
+"react-reconciler@npm:^0.26.2":
+ version: 0.26.2
+ resolution: "react-reconciler@npm:0.26.2"
+ dependencies:
+ loose-envify: ^1.1.0
+ object-assign: ^4.1.1
+ scheduler: ^0.20.2
+ peerDependencies:
+ react: ^17.0.2
+ checksum: 2ebceace56f547f51eaf142becefef9cca980eae4f42d90ee5a966f54a375f5082d78b71b00c40bbd9bca69e0e0f698c7d4e81cc7373437caa19831fddc1d01b
+ languageName: node
+ linkType: hard
+
"react-refresh@npm:^0.4.0":
version: 0.4.3
resolution: "react-refresh@npm:0.4.3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment