-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
56 deletions.
There are no files selected for viewing
36 changes: 7 additions & 29 deletions
36
src/screens/HomeScreen/components/FloatingButton/hooks/useAudioRecorder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PermissionsAndroid, Platform } from 'react-native'; | ||
|
||
export const usePermissions = () => { | ||
const requestAudioPermissions = async (): Promise<boolean> => { | ||
if (Platform.OS === 'android') { | ||
try { | ||
const grants = await PermissionsAndroid.requestMultiple([ | ||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, | ||
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, | ||
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, | ||
]); | ||
|
||
console.log('Permissions status:', grants); | ||
|
||
return ( | ||
grants['android.permission.WRITE_EXTERNAL_STORAGE'] === | ||
PermissionsAndroid.RESULTS.GRANTED && | ||
grants['android.permission.READ_EXTERNAL_STORAGE'] === | ||
PermissionsAndroid.RESULTS.GRANTED && | ||
grants['android.permission.RECORD_AUDIO'] === | ||
PermissionsAndroid.RESULTS.GRANTED | ||
); | ||
} catch (err) { | ||
console.warn('Permission request failed:', err); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
return { requestAudioPermissions }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1 @@ | ||
function formatTimestampToDate(timestamp: number): string { | ||
const date = new Date(timestamp); | ||
return new Intl.DateTimeFormat('en-US', { | ||
month: 'short', // "Jan" | ||
day: 'numeric', // "6" | ||
year: 'numeric', // "2023" | ||
}).format(date); | ||
} | ||
|
||
function formatTimestampToDateTime(timestamp: number): string { | ||
const date = new Date(timestamp); | ||
const formattedDate = new Intl.DateTimeFormat('en-US', { | ||
month: 'short', // "Jan" | ||
day: 'numeric', // "6" | ||
year: 'numeric', // "2023" | ||
}).format(date); | ||
|
||
const formattedTime = new Intl.DateTimeFormat('en-US', { | ||
hour: 'numeric', // "6" | ||
minute: 'numeric', // "49" | ||
hour12: true, // "AM/PM" | ||
}).format(date); | ||
|
||
return `${formattedDate} at ${formattedTime}`; | ||
} | ||
|
||
export { formatTimestampToDate, formatTimestampToDateTime }; | ||
export { formatTimestampToDate, formatTimestampToDateTime } from './time'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function formatTimestampToDate(timestamp: number): string { | ||
const date = new Date(timestamp); | ||
return new Intl.DateTimeFormat('en-US', { | ||
month: 'short', // "Jan" | ||
day: 'numeric', // "6" | ||
year: 'numeric', // "2023" | ||
}).format(date); | ||
} | ||
|
||
function formatTimestampToDateTime(timestamp: number): string { | ||
const date = new Date(timestamp); | ||
const formattedDate = new Intl.DateTimeFormat('en-US', { | ||
month: 'short', // "Jan" | ||
day: 'numeric', // "6" | ||
year: 'numeric', // "2023" | ||
}).format(date); | ||
|
||
const formattedTime = new Intl.DateTimeFormat('en-US', { | ||
hour: 'numeric', // "6" | ||
minute: 'numeric', // "49" | ||
hour12: true, // "AM/PM" | ||
}).format(date); | ||
|
||
return `${formattedDate} at ${formattedTime}`; | ||
} | ||
|
||
export { formatTimestampToDate, formatTimestampToDateTime }; |