mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
added deeplink support for plugin installation
This commit is contained in:
parent
1fdcdd02bf
commit
2439bd1cd8
2 changed files with 48 additions and 5 deletions
11
App.tsx
11
App.tsx
|
|
@ -205,7 +205,16 @@ const ThemedApp = () => {
|
||||||
<NavigationContainer
|
<NavigationContainer
|
||||||
ref={navigationRef}
|
ref={navigationRef}
|
||||||
theme={customNavigationTheme}
|
theme={customNavigationTheme}
|
||||||
linking={undefined}
|
linking={{
|
||||||
|
prefixes: ['nuvio://'],
|
||||||
|
config: {
|
||||||
|
screens: {
|
||||||
|
ScraperSettings: {
|
||||||
|
path: 'repo',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<DownloadsProvider>
|
<DownloadsProvider>
|
||||||
<View style={[styles.container, { backgroundColor: currentTheme.colors.darkBackground }]}>
|
<View style={[styles.container, { backgroundColor: currentTheme.colors.darkBackground }]}>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ import CustomAlert from '../components/CustomAlert';
|
||||||
import FastImage from '@d11/react-native-fast-image';
|
import FastImage from '@d11/react-native-fast-image';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
|
||||||
|
import { RootStackParamList } from '../navigation/AppNavigator';
|
||||||
import { useSettings } from '../hooks/useSettings';
|
import { useSettings } from '../hooks/useSettings';
|
||||||
import { localScraperService, pluginService, ScraperInfo, RepositoryInfo } from '../services/pluginService';
|
import { localScraperService, pluginService, ScraperInfo, RepositoryInfo } from '../services/pluginService';
|
||||||
import { logger } from '../utils/logger';
|
import { logger } from '../utils/logger';
|
||||||
|
|
@ -901,12 +902,41 @@ const StatusBadge: React.FC<{
|
||||||
|
|
||||||
const PluginsScreen: React.FC = () => {
|
const PluginsScreen: React.FC = () => {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
const route = useRoute<RouteProp<RootStackParamList, 'ScraperSettings'>>();
|
||||||
const { settings, updateSetting } = useSettings();
|
const { settings, updateSetting } = useSettings();
|
||||||
const { currentTheme } = useTheme();
|
const { currentTheme } = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const colors = currentTheme.colors;
|
const colors = currentTheme.colors;
|
||||||
const styles = createStyles(colors);
|
const styles = createStyles(colors);
|
||||||
|
|
||||||
|
// Deep Link Handler
|
||||||
|
useEffect(() => {
|
||||||
|
// Check if opened via deep link with URL param
|
||||||
|
if (route.params && (route.params as any).url) {
|
||||||
|
const url = (route.params as any).url;
|
||||||
|
// Small delay to ensure UI is ready
|
||||||
|
setTimeout(() => {
|
||||||
|
openAlert(
|
||||||
|
'Add Repository',
|
||||||
|
`Do you want to add the repository from:\n${url}`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
label: 'Cancel',
|
||||||
|
onPress: () => { },
|
||||||
|
style: { color: colors.error }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Add',
|
||||||
|
onPress: () => {
|
||||||
|
handleAddRepository(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}, [route.params]);
|
||||||
|
|
||||||
// CustomAlert state
|
// CustomAlert state
|
||||||
const [alertVisible, setAlertVisible] = useState(false);
|
const [alertVisible, setAlertVisible] = useState(false);
|
||||||
const [alertTitle, setAlertTitle] = useState('');
|
const [alertTitle, setAlertTitle] = useState('');
|
||||||
|
|
@ -1040,14 +1070,18 @@ const PluginsScreen: React.FC = () => {
|
||||||
setNewRepositoryUrl(url);
|
setNewRepositoryUrl(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddRepository = async () => {
|
const handleAddRepository = async (urlOverride?: string | any) => {
|
||||||
if (!newRepositoryUrl.trim()) {
|
// Check if urlOverride is a string (to avoid event objects)
|
||||||
|
const validUrlOverride = typeof urlOverride === 'string' ? urlOverride : undefined;
|
||||||
|
const inputUrl = validUrlOverride || newRepositoryUrl;
|
||||||
|
|
||||||
|
if (!inputUrl.trim()) {
|
||||||
openAlert('Error', 'Please enter a valid repository URL');
|
openAlert('Error', 'Please enter a valid repository URL');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate URL format
|
// Validate URL format
|
||||||
const url = newRepositoryUrl.trim();
|
const url = inputUrl.trim();
|
||||||
if (!url.startsWith('https://raw.githubusercontent.com/') && !url.startsWith('http://')) {
|
if (!url.startsWith('https://raw.githubusercontent.com/') && !url.startsWith('http://')) {
|
||||||
openAlert(
|
openAlert(
|
||||||
t('plugins.alert_invalid_url'),
|
t('plugins.alert_invalid_url'),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue