You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.3 KiB

Profile Manager Screen Modules

This folder contains individual screen modules for the Profile Manager, providing a clean separation of concerns and modular architecture.

Structure

screens/
├── __init__.py                 # Module exports
├── base_screen.py              # Abstract base class for all screens
├── screen_manager.py           # Manages screen modules and navigation
├── main_menu_screen.py         # Main menu interface
├── profile_list_screen.py      # Profile selection and management
├── create_profile_screen.py    # Profile creation with virtual keyboard
├── edit_profile_screen.py      # Profile settings editing
├── leaderboard_screen.py       # Leaderboard display (device/global)
├── profile_stats_screen.py     # Detailed profile statistics
└── README.md                   # This file

Architecture

BaseScreen

  • Abstract base class providing common interface
  • Standard navigation methods (up, down, left, right)
  • Input handling framework
  • State management utilities

Screen Modules

Each screen is a self-contained module with:

  • Rendering: Complete screen display logic
  • Input Handling: Screen-specific input processing
  • State Management: Internal state tracking
  • Navigation: Transitions to other screens

ModularScreenManager

  • Manages all screen module instances
  • Handles screen transitions
  • Provides error dialog overlay
  • Maintains current screen state

Usage

Adding New Screens

  1. Create Screen Module:
from .base_screen import BaseScreen

class NewScreen(BaseScreen):
    def render(self) -> None:
        # Implement rendering logic
        pass
    
    def handle_input(self, action: str) -> bool:
        # Implement input handling
        pass
  1. Register in ScreenManager:
# In screen_manager.py _initialize_screens()
"new_screen": NewScreen(self.data_manager, self.ui_renderer, self)
  1. Add to Exports:
# In __init__.py
from .new_screen import NewScreen

Screen Integration

To integrate with the main Profile Manager:

from screens import ModularScreenManager

# Replace existing screen manager
self.screen_manager = ModularScreenManager(self.data_manager, self.ui_renderer)

# Handle input
result = self.screen_manager.handle_input(action)

# Render
self.screen_manager.render()

Screen Responsibilities

MainMenuScreen

  • Primary navigation hub
  • Profile status display
  • API connection status
  • Menu option availability

ProfileListScreen

  • Display existing profiles
  • Profile selection
  • Profile deletion
  • Active profile indication

CreateProfileScreen

  • Virtual keyboard interface
  • Profile name input
  • Input validation
  • Profile creation

EditProfileScreen

  • Settings adjustment interface
  • Real-time value display
  • Setting validation
  • Changes persistence

LeaderboardScreen

  • Leaderboard data display
  • Device/Global toggle
  • Data refresh functionality
  • User highlighting

ProfileStatsScreen

  • Comprehensive statistics
  • Server sync status
  • Settings summary
  • Achievements display

Benefits

Modularity

  • Each screen is independent and testable
  • Clear separation of concerns
  • Easy to add/remove/modify screens

Maintainability

  • Isolated screen logic
  • Consistent interface pattern
  • Reduced coupling between screens

Extensibility

  • Simple to add new screens
  • Common functionality in base class
  • Flexible navigation system

Testability

  • Individual screen unit tests
  • Mock dependencies easily
  • Isolated functionality testing

Navigation Flow

Main Menu ─┬─ Create Profile
           ├─ Profile List
           ├─ Edit Profile (if profile active)
           ├─ Leaderboard (if API enabled)
           ├─ Profile Stats (if profile active)
           └─ Exit

All screens ─→ Back to Main Menu (ESC)

Input Actions

Standard actions handled by screens:

  • up: Navigate selection up
  • down: Navigate selection down
  • left: Navigate left / Adjust setting
  • right: Navigate right / Adjust setting
  • confirm: Confirm selection / Enter
  • back: Return to previous screen / ESC
  • delete: Delete item / Backspace

Error Handling

Screens can show error messages via:

self.show_error("Error message")

The ModularScreenManager handles error dialog display and auto-dismissal.