Expo UI Playground

repository·main·Indexed 42 days ago

https://github.com/betomoedano/expo-ui-playground

An experimental playground for exploring and showcasing Expo UI components version 1.0.0. It features comprehensive examples of buttons, gauges, pickers, and date/time components, utilizing React 19, Expo SDK 54.0.3, and a Swift-like modifier pattern for styling. The project demonstrates a modular architecture with centralized state management using the React 19 use() hook and React Context.

Tokens
2.4K
Snippets
7
Records
11
Agent score
54%

What's inside Expo UI Playground

  1. Explore Expo UI components in the playground

    main

    The playground showcases a variety of Expo UI components through a productivity app interface. Key components available for inspection include:

    • Buttons: 7 different variants (default, bordered, plain, glass, etc.).
    • Gauges: 6 types including circular, capacity, and linear.
    • Pickers: Segmented and menu variants, including ColorPicker with opacity support.
    • Date & Time: DateTimePicker with multiple display modes (compact, graphical, wheel) and modes (date, time, date+time).
    • Layout & Containers: VStack, HStack, Section, DisclosureGroup, and ContentUnavailableView for empty states.
    • Interactivity: Slider with real-time updates, Switch configurations, and ContextMenu with nested submenus.
  2. Understand the State Management Architecture

    main

    The project uses a centralized state management pattern leveraging React 19's use() hook and React Context.

    • AppContext.tsx: Acts as the single source of truth for the application state.
    • use() hook: Components consume the context using the new React 19 use() pattern rather than useContext.
    • Real-time synchronization: All modular UI sections (Profile, Dashboard, Task Management, etc.) share and update this common state, ensuring that interactions in one component (e.g., a theme change in the Profile section) immediately reflect across the entire app.
    • Type Safety: The state is fully integrated with TypeScript, using comprehensive interfaces for all state properties and updater functions.
    // React 19 use() hook pattern
    const { profile, updateProfile } = use(AppContext) as AppState;
  3. Technical implementation details

    main

    The playground utilizes modern React and TypeScript patterns to demonstrate Expo UI capabilities:

    • State Management: Uses React Context combined with the React 19 use() hook for managing shared state across components.
    • Type Safety: Comprehensive TypeScript integration with interface definitions for all components and data structures.
    • Architecture: A modular approach where components interact via a shared state, enabling realistic data flow (e.g., changing a setting in the SettingsSection affects the ProfileSection).
  4. Use the Expo UI Modifiers pattern for styling

    main

    The application implements a Swift-like modifier pattern for styling Expo UI components. Instead of traditional style objects, components accept a modifiers prop containing a list of modifier functions.

    Common modifiers include:

    • frame({ width, height })
    • background(color/theme)
    • cornerRadius(value)

    This pattern is optimized for the Expo UI Swift components (Buttons, Gauges, Sliders, etc.) and provides a declarative way to apply layout and visual properties.

    // Modifiers pattern for styling
    modifiers={[
      frame({ width: 100, height: 100 }),
      background(profile.theme),
      cornerRadius(100)
    ]}
  5. Understand the project structure

    main

    The project is organized into a modular structure to separate core playground logic from screen implementations:

    • app/: Contains the root navigation and tab layouts (_layout.tsx) and main entry points.
    • components/liquid-glass/: Contains the primary interactive playground components (e.g., ProfileSection.tsx, DashboardSection.tsx, TaskManagementSection.tsx) and the shared AppContext.tsx.
    • components/screens/: Contains the high-level screen components that compose the playground experience.
    app/
    ├── _layout.tsx              # Root native tabs layout
    ├── index.tsx               # Root redirect
    ├── home/
    │   ├── _layout.tsx         # Home tab layout
    │   └── index.tsx           # Main playground
    ├── basic/
    │   ├── _layout.tsx         # Basic examples layout
    │   ├── index.tsx           # Basic usage examples
    │   └── modifiers.tsx       # Modifiers examples
    └── settings.tsx            # Settings tab
    
    components/
    ├── liquid-glass/
    │   ├── AppContext.tsx      # React Context with use() hook
    │   ├── types.ts            # TypeScript definitions
    │   ├── ProfileSection.tsx  # Profile management
    │   ├── DashboardSection.tsx # Interactive gauges & metrics
    │   ├── TaskManagementSection.tsx # Task filtering & completion
    │   ├── ContextMenuSection.tsx # Context menus & submenus
    │   ├── DateTimeSection.tsx  # Date/time pickers
    │   ├── ButtonsSection.tsx   # Button variants showcase
    │   └── SettingsSection.tsx  # App settings
    └── screens/
        ├── liquid-glass-example.tsx # Main playground screen
        ├── basic-usage-video.tsx    # Basic usage examples
        ├── basic-usage.tsx          # Alternative basic examples
        └── habit-tracker.tsx         # Additional demo screen
  6. Follow project-specific development rules

    main

    When contributing to or developing within this repository, adhere to these specific implementation rules:

    • Styling: Do not use legacy shadow styles; use box shadow instead. Always implement dark mode support.
    • Layout: Do not use SafeAreaView (it is deprecated). Instead, use contentInsetAdjustmentBehavior="automatic" with ScrollView components.
    • Containers: Each screen should use a ScrollView as its primary container.
    • Platform Priority: Prioritize iOS development and testing (iOS 16+) as many Expo UI components and glass effects are designed with an iOS-first approach.
    • Architecture: Maintain the modular, section-based architecture where components are interactive and connected to the shared AppContext.
  7. Install and run the Expo UI Playground

    main

    To set up the development environment and start the application, use the following commands:

    1. Install dependencies: Run npm install to install all required packages.
    2. Start the development server: Use npx expo start or expo start.
    3. Run on specific platforms:
      • iOS: expo run:ios (Recommended for best Expo UI support; requires iOS 16+)
      • Android: expo run:android
      • Web: expo start --web
    4. Linting: Run expo lint to check code quality.
    # Install dependencies
    npm install
    
    # Start development server
    npx expo start
    
    # Run on specific platforms
    expo run:ios
    expo run:android
    expo start --web
    
    # Linting
    expo lint
  8. Configure ESLint for Expo projects

    main

    This project uses the ESLint Flat Config format. To ensure compatibility with Expo's environment and rules, it utilizes eslint-config-expo/flat. The configuration is wrapped in defineConfig from eslint/config to provide type safety and structure.

    By default, the configuration ignores the dist/* directory to prevent linting build artifacts.

    const { defineConfig } = require('eslint/config');
    const expoConfig = require('eslint-config-expo/flat');
    
    module.exports = defineConfig([
      expoConfig,
      {
        ignores: ['dist/*'],
      },
    ]);
  9. Reference the project configuration and environment

    main

    The project is configured with the following technical specifications:

    FeatureValue
    Expo SDK54.0.3
    React19.1.0
    React Native0.81.4
    TypeScriptStrict mode enabled
    New ArchitectureEnabled (newArchEnabled: true)
    Edge-to-edgeEnabled on Android
    Typed routesExperimental feature enabled
    Path Aliases@/* for root-relative imports
  10. Navigate to the Liquid Glass Example via the Home entry point

    main

    The app/home/index.tsx file serves as the primary entry point for the home route in the Expo router. Currently, it is configured to export the liquid-glass-example screen as the default component, redirecting users from the home path to the Liquid Glass UI demonstration.

    export { default } from "@/components/screens/liquid-glass-example";