From 13da7177070eef349d58b9b5ecdde5201662f8cf Mon Sep 17 00:00:00 2001 From: Egor Date: Thu, 22 Jan 2026 23:54:02 +0300 Subject: [PATCH] Update ConnectionModal.tsx --- src/components/ConnectionModal.tsx | 219 ++++++++++++++++++++--------- 1 file changed, 154 insertions(+), 65 deletions(-) diff --git a/src/components/ConnectionModal.tsx b/src/components/ConnectionModal.tsx index bab8768..1dcb078 100644 --- a/src/components/ConnectionModal.tsx +++ b/src/components/ConnectionModal.tsx @@ -132,6 +132,7 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { const [selectedApp, setSelectedApp] = useState(null) const [copied, setCopied] = useState(false) const [showAppSelector, setShowAppSelector] = useState(false) + const [selectedPlatform, setSelectedPlatform] = useState(null) const { isTelegramWebApp, isFullscreen, safeAreaInset, contentSafeAreaInset, webApp } = useTelegramWebApp() const isMobileScreen = useIsMobile() @@ -180,8 +181,12 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { }, [onClose]) const handleBack = useCallback(() => { - setShowAppSelector(false) - }, []) + if (selectedPlatform) { + setSelectedPlatform(null) + } else { + setShowAppSelector(false) + } + }, [selectedPlatform]) useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { @@ -332,82 +337,166 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { macos: 'macOS', linux: 'Linux', androidTV: 'Android TV', appleTV: 'Apple TV' } + const platformIcons: Record = { + ios: ( + + + + ), + android: ( + + + + ), + windows: ( + + + + ), + macos: ( + + + + ), + linux: ( + + + + ), + androidTV: ( + + + + ), + appleTV: ( + + + + ), + } + + // Step 1: Platform selection + if (!selectedPlatform) { + return ( + +
+ +

{t('subscription.connection.selectPlatform') || 'Выберите платформу'}

+
+
+ {availablePlatforms.map(platform => { + const apps = appConfig.platforms[platform] + if (!apps?.length) return null + const isCurrentPlatform = platform === detectedPlatform + const appCount = apps.length + + return ( + + ) + })} +
+
+ ) + } + + // Step 2: App selection for chosen platform + const apps = appConfig.platforms[selectedPlatform] || [] + const isCurrentPlatform = selectedPlatform === detectedPlatform + return (
-

{t('subscription.connection.selectApp')}

+
+

{platformNames[selectedPlatform] || selectedPlatform}

+ {isCurrentPlatform && ( + {t('subscription.connection.yourDevice')} + )} +
- {availablePlatforms.map(platform => { - const apps = appConfig.platforms[platform] - if (!apps?.length) return null - const isCurrentPlatform = platform === detectedPlatform - return ( -
-
- - {platformNames[platform] || platform} - - {isCurrentPlatform && ( - - {t('subscription.connection.yourDevice')} - +
+ {apps.map(app => { + const isSelected = selectedApp?.id === app.id + return ( +
-
- {apps.map(app => { - const isSelected = selectedApp?.id === app.id - return ( - - ) - })} -
-
- ) - })} + {/* App icon */} +
+ {getAppIcon(app.name)} +
+ {/* App name */} + + {app.name} + + {/* Selection indicator */} + {isSelected && ( +
+ )} + + ) + })} +
)