From 6afb30cc13a559b103adcbf8a392f03641166efd Mon Sep 17 00:00:00 2001 From: Michal Sek Date: Mon, 28 Oct 2024 15:46:16 +0100 Subject: [PATCH] chore: cleanup --- .../src/examples/DrumMachine/BGGradient.tsx | 40 +++++++++++++++++++ .../src/examples/DrumMachine/DrumMachine.tsx | 13 ++++-- .../examples/DrumMachine/NotesHighlight.tsx | 40 +++++++++++++++---- .../src/examples/DrumMachine/PlayButton.tsx | 3 +- .../src/examples/DrumMachine/usePlayer.tsx | 2 +- .../common/cpp/core/AudioDestinationNode.cpp | 2 +- yarn.lock | 1 + 7 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 apps/common-app/src/examples/DrumMachine/BGGradient.tsx diff --git a/apps/common-app/src/examples/DrumMachine/BGGradient.tsx b/apps/common-app/src/examples/DrumMachine/BGGradient.tsx new file mode 100644 index 00000000..55f2eb61 --- /dev/null +++ b/apps/common-app/src/examples/DrumMachine/BGGradient.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { StyleSheet } from 'react-native'; +import { useDerivedValue, useSharedValue } from 'react-native-reanimated'; +import { vec, Rect, Canvas, RadialGradient } from '@shopify/react-native-skia'; + +const BGGradient = () => { + const canvasSize = useSharedValue({ width: 0, height: 0 }); + + const gradientRadius = useDerivedValue(() => canvasSize.value.width); + const gradientC = useDerivedValue(() => vec(canvasSize.value.width / 2, 0)); + + return ( + + + + + + ); +}; + +export default BGGradient; + +const styles = StyleSheet.create({ + canvas: { + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, + }, +}); diff --git a/apps/common-app/src/examples/DrumMachine/DrumMachine.tsx b/apps/common-app/src/examples/DrumMachine/DrumMachine.tsx index da739437..2561ef58 100644 --- a/apps/common-app/src/examples/DrumMachine/DrumMachine.tsx +++ b/apps/common-app/src/examples/DrumMachine/DrumMachine.tsx @@ -1,5 +1,6 @@ import { Canvas } from '@shopify/react-native-skia'; import React, { useState, useCallback } from 'react'; +import { SafeAreaView } from 'react-native-safe-area-context'; import { GestureDetector } from 'react-native-gesture-handler'; import { LayoutChangeEvent, StyleSheet, View } from 'react-native'; @@ -11,6 +12,7 @@ import { size, initialBpm } from './constants'; import NotesHighlight from './NotesHighlight'; import PatternShape from './PatternShape'; import useGestures from './useGestures'; +import BGGradient from './BGGradient'; import PlayButton from './PlayButton'; import usePlayer from './usePlayer'; import presets from './presets'; @@ -95,7 +97,8 @@ const DrumMachine: React.FC = () => { const gesture = useGestures({ canvasRect, onPatternChange }); return ( - + +