feat: add background sound

main
Torpenn 2025-04-08 21:04:33 +02:00
parent 6cb9eb9e8b
commit 459571979b
No known key found for this signature in database
GPG Key ID: 56C8A89C974E3ED2
8 changed files with 332 additions and 232 deletions

View File

@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<queries> <queries>
<intent> <intent>
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW"/>
@ -17,11 +18,10 @@
</intent> </intent>
</queries> </queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme"> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/> <meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/> <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/d301ba68-1a3d-44b4-937e-ada774c6f67c"/>
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait"> <activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>

View File

@ -1,5 +1,6 @@
import { Stack } from 'expo-router'; import { Stack } from 'expo-router';
import { StyleSheet } from 'react-native'; import { StyleSheet } from 'react-native';
import React from 'react';
import { Text, View } from '@/components/shared/Themed'; import { Text, View } from '@/components/shared/Themed';

View File

@ -9,7 +9,7 @@ export function useAudio(soundFile: any, soundEnabled: boolean) {
const configureAudio = async () => { const configureAudio = async () => {
await Audio.setAudioModeAsync({ await Audio.setAudioModeAsync({
allowsRecordingIOS: false, allowsRecordingIOS: false,
staysActiveInBackground: false, staysActiveInBackground: true,
playsInSilentModeIOS: true, playsInSilentModeIOS: true,
shouldDuckAndroid: true, shouldDuckAndroid: true,
playThroughEarpieceAndroid: false, playThroughEarpieceAndroid: false,

View File

@ -1,25 +1,22 @@
import React from 'react';
import { Text, View } from '@/components/shared/Themed'; import { Text, View } from '@/components/shared/Themed';
import styled from '@emotion/native'; import styled from '@emotion/native';
import { useNavigation } from 'expo-router'; import { useRouter } from 'expo-router';
import { NativeStackNavigationProp } from 'react-native-screens/lib/typescript/native-stack/types';
import Button from '@/components/shared/Button'; import Button from '@/components/shared/Button';
import { HorizontalSpacer, VerticalSpacer } from '@/components/shared/Spacers'; import { HorizontalSpacer, VerticalSpacer } from '@/components/shared/Spacers';
import { RootStackParamList } from '@/app/RootStackParamList';
import { i18n } from '@/app/i18n/i18n'; import { i18n } from '@/app/i18n/i18n';
type FinishContentProps = { type FinishContentProps = {
handleStart: () => void; handleStart: () => void;
}; };
type NavigationProp = NativeStackNavigationProp<RootStackParamList, 'Dashboard'>;
const t = i18n.scoped('timer.finishContent'); const t = i18n.scoped('timer.finishContent');
export default function FinishContent({ export default function FinishContent({
handleStart handleStart
}: FinishContentProps) { }: FinishContentProps) {
const navigation = useNavigation<NavigationProp>(); const router = useRouter();
return ( return (
<> <>
@ -32,7 +29,7 @@ export default function FinishContent({
<HorizontalSpacer widthUnits={3} /> <HorizontalSpacer widthUnits={3} />
<Button label={i18n.t('back')} onPress={() => navigation.navigate('Dashboard')} /> <Button label={i18n.t('back')} onPress={() => router.push('/')} />
</Row> </Row>
</> </>
); );

View File

@ -1,12 +1,11 @@
import React from 'react';
import { Text, View } from '@/components/shared/Themed'; import { Text, View } from '@/components/shared/Themed';
import styled from '@emotion/native'; import styled from '@emotion/native';
import { formatTime } from '@/components/shared/business/timeHelpers'; import { formatTime } from '@/components/shared/business/timeHelpers';
import Button from '@/components/shared/Button'; import Button from '@/components/shared/Button';
import { ElasticSpacer, HorizontalSpacer, VerticalSpacer } from '@/components/shared/Spacers'; import { ElasticSpacer, VerticalSpacer } from '@/components/shared/Spacers';
import { TimerBgColor } from '@/components/useCases/timer/business/type'; import { TimerBgColor } from '@/components/useCases/timer/business/type';
import { useNavigation } from 'expo-router'; import { useRouter } from 'expo-router';
import { NativeStackNavigationProp } from 'react-native-screens/lib/typescript/native-stack/types';
import { RootStackParamList } from '@/app/RootStackParamList';
import { i18n } from '@/app/i18n/i18n'; import { i18n } from '@/app/i18n/i18n';
interface TimerContentProps { interface TimerContentProps {
@ -22,8 +21,6 @@ interface TimerContentProps {
bgColor: TimerBgColor; bgColor: TimerBgColor;
} }
type NavigationProp = NativeStackNavigationProp<RootStackParamList, 'Dashboard'>;
const t = i18n.scoped('timer.timerContent'); const t = i18n.scoped('timer.timerContent');
export default function TimerContent({ export default function TimerContent({
@ -38,7 +35,7 @@ export default function TimerContent({
previousRep, previousRep,
bgColor, bgColor,
}: TimerContentProps ) { }: TimerContentProps ) {
const navigation = useNavigation<NavigationProp>(); const router = useRouter();
return ( return (
<> <>
@ -74,7 +71,7 @@ export default function TimerContent({
<VerticalSpacer heightUnits={4} /> <VerticalSpacer heightUnits={4} />
<Button label={i18n.t('back')} onPress={() => navigation.navigate('Dashboard')} /> <Button label={i18n.t('back')} onPress={() => router.push('/')} />
</> </>
); );
} }

View File

@ -64,6 +64,7 @@
<array> <array>
<string>fetch</string> <string>fetch</string>
<string>remote-notification</string> <string>remote-notification</string>
<string>audio</string>
</array> </array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>SplashScreen</string> <string>SplashScreen</string>

527
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,8 @@
"types": "tsc --noEmit", "types": "tsc --noEmit",
"lint": "eslint --ext .ts,.tsx .", "lint": "eslint --ext .ts,.tsx .",
"lint:fix": "eslint --fix --ext .ts,.tsx .", "lint:fix": "eslint --fix --ext .ts,.tsx .",
"prepare": "husky" "prepare": "husky",
"build:android": "eas build --profile development --platform android"
}, },
"jest": { "jest": {
"preset": "jest-expo", "preset": "jest-expo",
@ -30,7 +31,6 @@
"@react-native-async-storage/async-storage": "1.23.1", "@react-native-async-storage/async-storage": "1.23.1",
"@react-native-picker/picker": "2.7.5", "@react-native-picker/picker": "2.7.5",
"@react-navigation/native": "^6.0.2", "@react-navigation/native": "^6.0.2",
"@testing-library/react-native": "^12.7.2",
"expo": "~51.0.39", "expo": "~51.0.39",
"expo-av": "~14.0.7", "expo-av": "~14.0.7",
"expo-dev-client": "~4.0.29", "expo-dev-client": "~4.0.29",
@ -60,6 +60,7 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",
"@testing-library/jest-native": "^5.4.3", "@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^13.2.0",
"@types/react": "~18.2.45", "@types/react": "~18.2.45",
"@types/react-native-background-timer": "^2.0.2", "@types/react-native-background-timer": "^2.0.2",
"@types/react-native-push-notification": "^8.1.4", "@types/react-native-push-notification": "^8.1.4",