From 3e7f51e9ae2fcc0949aadd4eb9775549eaee6b99 Mon Sep 17 00:00:00 2001 From: nyagami Date: Thu, 18 Jan 2024 14:56:31 +0700 Subject: [PATCH] feat: custom UserAgent --- .../settings/SettingsAdvancedScreen.tsx | 97 ++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/src/screens/settings/SettingsAdvancedScreen.tsx b/src/screens/settings/SettingsAdvancedScreen.tsx index f2b2ee9d..efccde19 100644 --- a/src/screens/settings/SettingsAdvancedScreen.tsx +++ b/src/screens/settings/SettingsAdvancedScreen.tsx @@ -1,8 +1,15 @@ import React, { useState } from 'react'; -import { Dialog, Portal } from 'react-native-paper'; +import { + Dialog, + Modal, + Portal, + Text, + TextInput, + overlay, +} from 'react-native-paper'; -import { useTheme } from '@hooks/persisted'; +import { useTheme, useUserAgent } from '@hooks/persisted'; import { showToast } from '@utils/showToast'; import { deleteCachedNovels } from '@database/queries/NovelQueries'; @@ -19,10 +26,13 @@ import { importEpub } from '@services/epub/import'; import { AdvancedSettingsScreenProps } from '@navigators/types'; import { useMMKVString } from 'react-native-mmkv'; import { BACKGROUND_ACTION } from '@services/constants'; +import { StyleSheet, View } from 'react-native'; +import { getUserAgentSync } from 'react-native-device-info'; const AdvancedSettings = ({ navigation }: AdvancedSettingsScreenProps) => { const theme = useTheme(); - + const { userAgent, setUserAgent } = useUserAgent(); + const [userAgentInput, setUserAgentInput] = useState(userAgent); /** * Confirm Clear Database Dialog */ @@ -40,6 +50,12 @@ const AdvancedSettings = ({ navigation }: AdvancedSettingsScreenProps) => { setFalse: hideDeleteReadChaptersDialog, } = useBoolean(); + const { + value: userAgentModalVisible, + setTrue: showUserAgentModal, + setFalse: hideUserAgentModal, + } = useBoolean(); + const [hasAction] = useMMKVString(BACKGROUND_ACTION); return ( @@ -74,6 +90,12 @@ const AdvancedSettings = ({ navigation }: AdvancedSettingsScreenProps) => { theme={theme} disabled={Boolean(hasAction)} /> + { + + + User Agent + + {userAgent} + setUserAgentInput(text.trim())} + placeholderTextColor={theme.onSurfaceDisabled} + underlineColor={theme.outline} + style={[{ color: theme.onSurface }, styles.textInput]} + theme={{ colors: { ...theme } }} + /> + +