Rocket.Chat.ReactNative/app/views/MediaAutoDownloadView/index.tsx

66 lines
2.1 KiB
TypeScript
Raw Normal View History

import React, { useLayoutEffect } from 'react';
import { useNavigation } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
2023-05-09 14:49:13 +00:00
import * as List from '../../containers/List';
import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar';
import ListPicker from './ListPicker';
2023-05-30 14:07:34 +00:00
import { useUserPreferences } from '../../lib/methods/userPreferences';
import {
AUDIO_PREFERENCE_DOWNLOAD,
IMAGES_PREFERENCE_DOWNLOAD,
MediaDownloadOption,
VIDEO_PREFERENCE_DOWNLOAD
} from '../../lib/constants';
import i18n from '../../i18n';
import { SettingsStackParamList } from '../../stacks/types';
2023-05-09 14:49:13 +00:00
const MediaAutoDownload = () => {
2023-05-30 14:07:34 +00:00
const [imagesPreference, setImagesPreference] = useUserPreferences<MediaDownloadOption>(
IMAGES_PREFERENCE_DOWNLOAD,
'wifi_mobile_data'
);
const [videoPreference, setVideoPreference] = useUserPreferences<MediaDownloadOption>(VIDEO_PREFERENCE_DOWNLOAD, 'wifi');
const [audioPreference, setAudioPreference] = useUserPreferences<MediaDownloadOption>(AUDIO_PREFERENCE_DOWNLOAD, 'wifi');
const navigation = useNavigation<StackNavigationProp<SettingsStackParamList, 'MediaAutoDownloadView'>>();
useLayoutEffect(() => {
navigation.setOptions({
title: i18n.t('Media_auto_download')
});
}, [navigation]);
2023-05-09 14:49:13 +00:00
return (
<SafeAreaView testID='media-auto-download-view'>
2023-05-09 14:49:13 +00:00
<StatusBar />
<List.Container testID='media-auto-download-view-list'>
2023-06-27 19:56:43 +00:00
<List.Section>
<ListPicker
onChangeValue={setImagesPreference}
value={imagesPreference}
title='Images'
testID='media-auto-download-view-images'
/>
<List.Separator />
<ListPicker
onChangeValue={setVideoPreference}
value={videoPreference}
title='Video'
testID='media-auto-download-view-video'
/>
<List.Separator />
<ListPicker
onChangeValue={setAudioPreference}
value={audioPreference}
title='Audio'
testID='media-auto-download-view-audio'
/>
</List.Section>
2023-05-09 14:49:13 +00:00
</List.Container>
</SafeAreaView>
);
};
export default MediaAutoDownload;