From bb543182b78127a7b0422d62c196649b5533ab3d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Mar 2026 21:51:35 +0100 Subject: [PATCH] feat: show minion on shake (android/ios) and fix CI workflow --- .github/workflows/ci.yml | 15 +++++++++++++++ App.js | 28 +++++++++++++++++++++++++++- package-lock.json | 23 ++++++++++++++--------- package.json | 1 + 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fa46900 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Install dependencies + run: npm install diff --git a/App.js b/App.js index 77e20b4..cac44c4 100644 --- a/App.js +++ b/App.js @@ -1,7 +1,8 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { BackHandler, Platform, StatusBar } from 'react-native'; +import { BackHandler, Platform, StatusBar, Modal, View, Image, StyleSheet } from 'react-native'; import * as ScreenOrientation from 'expo-screen-orientation'; import * as SplashScreen from 'expo-splash-screen'; +import { Accelerometer } from 'expo-sensors'; import FocusScreen from './src/screens/FocusScreen'; import HomeScreen from './src/screens/HomeScreen'; import TimeUntilScreen from './src/screens/TimeUntilScreen'; @@ -23,6 +24,8 @@ export default function App() { const [pinkMode, setPinkMode] = useState(false); const [isFullscreen, setIsFullscreen] = useState(false); const [now, setNow] = useState(new Date()); + + const [showMinion, setShowMinion] = useState(false); const [targetTime, setTargetTime] = useState(null); const [tuHour, setTuHour] = useState(''); @@ -50,6 +53,20 @@ export default function App() { } }, []); + useEffect(() => { + if (Platform.OS === 'android' || Platform.OS === 'ios') { + Accelerometer.setUpdateInterval(500); + const subscription = Accelerometer.addListener(({ x, y, z }) => { + const acceleration = Math.sqrt(x * x + y * y + z * z); + if (acceleration > 2.5) { + setShowMinion(true); + setTimeout(() => setShowMinion(false), 3000); + } + }); + return () => subscription.remove(); + } + }, []); + useEffect(() => { const interval = setInterval(() => setNow(new Date()), 1000); return () => clearInterval(interval); @@ -251,6 +268,15 @@ export default function App() { return ( <> + + + + + =0.10.0" } @@ -7512,7 +7521,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.26.0" }, @@ -7531,7 +7539,6 @@ "resolved": "https://registry.npmjs.org/react-native/-/react-native-0.81.5.tgz", "integrity": "sha512-1w+/oSjEXZjMqsIvmkCRsOc8UBYv163bTWKTI8+1mxztvQPhCRYGTvZ/PL1w16xXHneIj/SLGfxWg2GWN2uexw==", "license": "MIT", - "peer": true, "dependencies": { "@jest/create-cache-key-function": "^29.7.0", "@react-native/assets-registry": "0.81.5", @@ -7715,7 +7722,6 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -8593,7 +8599,6 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, diff --git a/package.json b/package.json index 6b9bddc..5d3608f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "expo": "~54.0.33", "expo-screen-orientation": "~9.0.8", + "expo-sensors": "^55.0.8", "expo-splash-screen": "^55.0.10", "expo-status-bar": "~3.0.9", "react": "19.1.0",