feat: show minion on shake (android/ios) and fix CI workflow
This commit is contained in:
15
.github/workflows/ci.yml
vendored
Normal file
15
.github/workflows/ci.yml
vendored
Normal file
@@ -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
|
||||
28
App.js
28
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 (
|
||||
<>
|
||||
<Modal visible={showMinion} transparent={true} animationType="fade">
|
||||
<View style={StyleSheet.absoluteFill}>
|
||||
<Image
|
||||
source={{ uri: 'https://shx.reversed.dev/u/XHuDcA.jpg' }}
|
||||
style={{ flex: 1 }}
|
||||
resizeMode="contain"
|
||||
/>
|
||||
</View>
|
||||
</Modal>
|
||||
<StatusBar barStyle={barStyle} backgroundColor={theme.bg} />
|
||||
<TimerScreen
|
||||
styles={styles}
|
||||
|
||||
23
package-lock.json
generated
23
package-lock.json
generated
@@ -10,6 +10,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",
|
||||
@@ -55,7 +56,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
|
||||
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.29.0",
|
||||
"@babel/generator": "^7.29.0",
|
||||
@@ -3822,7 +3822,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.9.0",
|
||||
"caniuse-lite": "^1.0.30001759",
|
||||
@@ -4430,7 +4429,6 @@
|
||||
"resolved": "https://registry.npmjs.org/expo/-/expo-54.0.33.tgz",
|
||||
"integrity": "sha512-3yOEfAKqo+gqHcV8vKcnq0uA5zxlohnhA3fu4G43likN8ct5ZZ3LjAh9wDdKteEkoad3tFPvwxmXW711S5OHUw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.0",
|
||||
"@expo/cli": "54.0.23",
|
||||
@@ -4587,6 +4585,19 @@
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-sensors": {
|
||||
"version": "55.0.8",
|
||||
"resolved": "https://registry.npmjs.org/expo-sensors/-/expo-sensors-55.0.8.tgz",
|
||||
"integrity": "sha512-aYDw/IBqJtWQgCIJh12oyj5N4ldT88Aa0V/Vag88xG8K2hOQuM2SLGeNlxGRFRtgLJ4m7pzXhQW7CJRj6p1uHQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"invariant": "^2.2.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-server": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/expo-server/-/expo-server-1.0.5.tgz",
|
||||
@@ -4942,7 +4953,6 @@
|
||||
"resolved": "https://registry.npmjs.org/expo-font/-/expo-font-14.0.11.tgz",
|
||||
"integrity": "sha512-ga0q61ny4s/kr4k8JX9hVH69exVSIfcIc19+qZ7gt71Mqtm7xy2c6kwsPTCyhBW2Ro5yXTT8EaZOpuRi35rHbg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"fontfaceobserver": "^2.1.0"
|
||||
},
|
||||
@@ -7492,7 +7502,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz",
|
||||
"integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=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"
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user