mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
feat: Linear-style UI redesign with improved mobile experience
Major changes: - Redesign cabinet with Linear-style components and top navigation - Replace detail modals with dedicated pages (users, broadcasts, email templates) - Add email channel support for broadcasts - Remove pull-to-refresh, improve drag-and-drop on touch devices - Fix Telegram Mini App: fullscreen, back button, scroll restoration - Unify admin pages color scheme to design system - Mobile-first improvements: horizontal tabs for settings, better touch targets
This commit is contained in:
43
src/platform/PlatformProvider.tsx
Normal file
43
src/platform/PlatformProvider.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useMemo, type ReactNode } from 'react';
|
||||
import { PlatformContext } from '@/platform/PlatformContext';
|
||||
import { createTelegramAdapter } from '@/platform/adapters/TelegramAdapter';
|
||||
import { createWebAdapter } from '@/platform/adapters/WebAdapter';
|
||||
import type { PlatformContext as PlatformContextType } from '@/platform/types';
|
||||
|
||||
interface PlatformProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
function detectPlatform(): 'telegram' | 'web' {
|
||||
// Check if Telegram WebApp is available and actually initialized with data
|
||||
// initData is an empty string when not in real Telegram context
|
||||
if (
|
||||
typeof window !== 'undefined' &&
|
||||
window.Telegram?.WebApp?.initData &&
|
||||
window.Telegram.WebApp.initData.length > 0
|
||||
) {
|
||||
return 'telegram';
|
||||
}
|
||||
return 'web';
|
||||
}
|
||||
|
||||
function createAdapter(): PlatformContextType {
|
||||
const platform = detectPlatform();
|
||||
|
||||
if (platform === 'telegram') {
|
||||
return createTelegramAdapter();
|
||||
}
|
||||
|
||||
return createWebAdapter();
|
||||
}
|
||||
|
||||
export function PlatformProvider({ children }: PlatformProviderProps) {
|
||||
// Create adapter once on mount
|
||||
// Using useMemo to ensure stable reference
|
||||
const platformContext = useMemo(() => createAdapter(), []);
|
||||
|
||||
return <PlatformContext.Provider value={platformContext}>{children}</PlatformContext.Provider>;
|
||||
}
|
||||
|
||||
// Re-export types for convenience
|
||||
export type { PlatformContextType as PlatformContext };
|
||||
Reference in New Issue
Block a user