diff --git a/app/mobile/ios/Podfile.lock b/app/mobile/ios/Podfile.lock index 53838531..8216c13b 100644 --- a/app/mobile/ios/Podfile.lock +++ b/app/mobile/ios/Podfile.lock @@ -238,6 +238,8 @@ PODS: - React-jsinspector (0.69.5) - React-logger (0.69.5): - glog + - react-native-document-picker (8.1.1): + - React-Core - react-native-safe-area-context (4.3.3): - RCT-Folly - RCTRequired @@ -387,6 +389,7 @@ DEPENDENCIES: - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-document-picker (from `../node_modules/react-native-document-picker`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`) - react-native-video (from `../node_modules/react-native-video`) @@ -467,6 +470,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsinspector" React-logger: :path: "../node_modules/react-native/ReactCommon/logger" + react-native-document-picker: + :path: "../node_modules/react-native-document-picker" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" react-native-sqlite-storage: @@ -535,6 +540,7 @@ SPEC CHECKSUMS: React-jsiexecutor: e42f0b46de293a026c2fb20e524d4fe09f81f575 React-jsinspector: e385fb7a1440ae3f3b2cd1a139ca5aadaab43c10 React-logger: 15c734997c06fe9c9b88e528fb7757601e7a56df + react-native-document-picker: f68191637788994baed5f57d12994aa32cf8bf88 react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261 react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253 diff --git a/app/mobile/package.json b/app/mobile/package.json index 81af89f3..2790ce1e 100644 --- a/app/mobile/package.json +++ b/app/mobile/package.json @@ -21,6 +21,7 @@ "react-dom": "18.0.0", "react-native": "0.69.5", "react-native-base64": "^0.2.1", + "react-native-document-picker": "^8.1.1", "react-native-gesture-handler": "^2.6.1", "react-native-image-crop-picker": "^0.38.0", "react-native-reanimated": "^2.10.0", diff --git a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx index 8ec89f9d..f8e74608 100644 --- a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx +++ b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx @@ -8,7 +8,14 @@ import Colors from 'constants/Colors'; import { SafeAreaView } from 'react-native-safe-area-context'; import ImagePicker from 'react-native-image-crop-picker' import { VideoFile } from './videoFile/VideoFile'; +import { AudioFile } from './audioFile/AudioFile'; import { ImageFile } from './imageFile/ImageFile'; +import DocumentPicker, { + DirectoryPickerResponse, + DocumentPickerResponse, + isInProgress, + types, +} from 'react-native-document-picker' export function AddTopic() { @@ -34,6 +41,19 @@ export function AddTopic() { } } + const addAudio = async () => { + try { + const audio = await DocumentPicker.pickSingle({ + presentationStyle: 'fullScreen', + copyTo: 'cachesDirectory', + type: DocumentPicker.types.audio, + }) + actions.addAudio(audio.fileCopyUri, audio.name.replace(/\.[^/.]+$/, "")); + } catch (err) { + console.log(err); + } + } + const remove = (item) => { Alert.alert( `Removing ${item.type} from message.`, @@ -62,7 +82,13 @@ export function AddTopic() { setPosition={(position) => actions.setVideoPosition(item.key, position)} /> ) - } + } + if (item.type === 'audio') { + return ( + remove(item)} + setLabel={(label) => actions.setAudioLabel(item.key, label)} /> + ) + } else { return ( @@ -88,7 +114,7 @@ export function AddTopic() { - + diff --git a/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.jsx b/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.jsx new file mode 100644 index 00000000..8199f554 --- /dev/null +++ b/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.jsx @@ -0,0 +1,14 @@ +import { Image, View, TextInput } from 'react-native'; +import audio from 'images/audio.png'; +import { styles } from './AudioFile.styled'; + +export function AudioFile({ path, remove, label, setLabel }) { + return ( + + + + + ) +} + diff --git a/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.styled.js b/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.styled.js new file mode 100644 index 00000000..b203b714 --- /dev/null +++ b/app/mobile/src/session/conversation/addTopic/audioFile/AudioFile.styled.js @@ -0,0 +1,23 @@ +import { StyleSheet } from 'react-native'; +import { Colors } from 'constants/Colors'; + +export const styles = StyleSheet.create({ + audio: { + width: 92, + height: 92, + backgroundColor: Colors.white, + borderRadius: 4, + marginRight: 16, + }, + image: { + width: 92, + height: 92, + }, + input: { + position: 'absolute', + maxHeight: 50, + textAlign: 'center', + padding: 4, + } +}) + diff --git a/app/mobile/src/session/conversation/addTopic/imageFile/ImageFile.jsx b/app/mobile/src/session/conversation/addTopic/imageFile/ImageFile.jsx index e1320c88..14d63024 100644 --- a/app/mobile/src/session/conversation/addTopic/imageFile/ImageFile.jsx +++ b/app/mobile/src/session/conversation/addTopic/imageFile/ImageFile.jsx @@ -14,11 +14,8 @@ export function ImageFile({ path, setPosition, remove }) { }, [path]); return ( - + - - - ); } diff --git a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js index 49f51236..5244d8cd 100644 --- a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js +++ b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js @@ -29,27 +29,14 @@ export function useAddTopic(cardId, channelId) { }, addVideo: (data) => { assetId.current++; - const asset = { key: assetId.current, type: 'video', data: data, ratio: 1, duration: 0, position: 0, ref: null }; + const asset = { key: assetId.current, type: 'video', data: data, ratio: 1, duration: 0, position: 0 }; updateState({ assets: [ ...state.assets, asset ] }); }, - setVideoInfo: (key, width, height, duration) => { - updateState({ assets: state.assets.map((item) => { - if(item.key === key) { - return { ...item, ratio: width / height, duration }; - } - return item; - }) - }); - }, - setVideoRef: (key, ref) => { - updateState({ assets: state.assets.map((item) => { - if(item.key === key) { - return { ...item, ref }; - } - return item; - }) - }); - }, + addAudio: (data, label) => { + assetId.current++; + const asset = { key: assetId.current, type: 'audio', data: data, label }; + updateState({ assets: [ ...state.assets, asset ] }); + }, setVideoPosition: (key, position) => { updateState({ assets: state.assets.map((item) => { if(item.key === key) { @@ -59,6 +46,15 @@ export function useAddTopic(cardId, channelId) { }) }); }, + setAudioLabel: (key, label) => { + updateState({ assets: state.assets.map((item) => { + if(item.key === key) { + return { ...item, label }; + } + return item; + }) + }); + }, removeAsset: (key) => { updateState({ assets: state.assets.filter(item => (item.key !== key))}); }, diff --git a/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.jsx b/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.jsx index 3cc7303b..1518c0d1 100644 --- a/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.jsx +++ b/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.jsx @@ -26,7 +26,7 @@ export function VideoFile({ path, setPosition, remove }) { ref={(ref) => video.current = ref} /> - + ); diff --git a/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.styled.js b/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.styled.js index 9c879c72..db332c1e 100644 --- a/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.styled.js +++ b/app/mobile/src/session/conversation/addTopic/videoFile/VideoFile.styled.js @@ -9,9 +9,6 @@ export const styles = StyleSheet.create({ right: 0, padding: 2, borderTopLeftRadius: 4, - backgroundColor: Colors.white, - borderWidth: 1, - borderColor: Colors.divider, }, }) diff --git a/app/mobile/yarn.lock b/app/mobile/yarn.lock index 50973132..b3986c3e 100644 --- a/app/mobile/yarn.lock +++ b/app/mobile/yarn.lock @@ -5520,6 +5520,13 @@ react-native-codegen@^0.69.2: jscodeshift "^0.13.1" nullthrows "^1.1.1" +react-native-document-picker@^8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/react-native-document-picker/-/react-native-document-picker-8.1.1.tgz#642bbe25752cc428b96416318f8dc07cef29ee10" + integrity sha512-mH0oghd7ndgU9/1meVJdqts1sAkOfUQW1qbrqTTsvR5f2K9r0BAj/X02dve5IBMOMZvlGd7qWrNVuIFg5AUXWg== + dependencies: + invariant "^2.2.4" + react-native-gesture-handler@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.6.1.tgz#66c40c8d720eb4729b301836a40fd34d14ec840f"