# SettingsPage

**Namespace:** `FrymasterBadgeApp`  
**Base Class:** `ContentPage`  
**Purpose:** Configuration interface for managing file storage paths (Photos, Logos, Images) and global UI theme preferences.

## 🔑 Constants & Fields
| Name | Type | Access | Description |
|------|------|--------|-------------|
| `PhotoPathKey` | `const string` | `private` | Preference key: `"PhotoBasePath"` |
| `LogoPathKey` | `const string` | `private` | Preference key: `"LogoBasePath"` |
| `ImagesPathKey` | `const string` | `private` | Preference key: `"ImagesBasePath"` |
| `ThemePrefKey` | `const string` | `private` | Preference key: `"AppTheme"` |

## 🛠 Constructor
### `SettingsPage()`
- **Access:** `public`
- **Behavior:**
  1. Calls `InitializeComponent()`.
  2. Loads current paths and theme via helper methods.
  3. Wires `ThemePicker.SelectedIndexChanged` to `ApplyThemeSelection()`.
  4. Overrides default back button behavior to navigate `Shell.Current.GoToAsync("..")`.

## 📦 Methods

### `LoadCurrentSettings()`
- **Access:** `private`
- **Behavior:** Reads photo, logo, and image paths from `Preferences.Default`. Falls back to `C:\FrymasterData\...` and populates corresponding UI entries.

### `LoadCurrentThemePreference()`
- **Access:** `private`
- **Behavior:** Reads `"AppTheme"` preference. Maps to `Light`/`Dark`/`System`, updates `ThemePicker.SelectedIndex` and `Application.Current.UserAppTheme`.

### `ApplyThemeSelection()`
- **Access:** `private`
- **Behavior:** Reads `ThemePicker.SelectedIndex`. Updates `UserAppTheme` and persists selection to `Preferences.Default`. Handles null picker defensively.

### `OnPickPhotoFolderClicked`, `OnPickLogoFolderClicked`, `OnPickImagesFolderClicked`
- **Access:** `private async void`
- **Behavior:** Wrappers that invoke `PickFolderAsync` with specific update callbacks and dialog titles.

### `PickFolderAsync(Action<FolderPickerResult> onSuccess, string title)`
- **Access:** `private async Task`
- **Parameters:** 
  - `onSuccess` (`Action<FolderPickerResult>`) – Callback on successful selection.
  - `title` (`string`) – Picker dialog title.
- **Behavior:** Invokes `FolderPicker.Default.PickAsync()`. On success, executes callback and calls `VerifyDirectory()`. Catches and displays alerts on failure.

### `OnSaveClicked(object sender, EventArgs e)`
- **Access:** `private async void`
- **Behavior:**
  1. Trims and validates all three paths. Alerts if any are empty.
  2. Saves paths to `Preferences.Default`.
  3. Updates `StatusLabel` with success/error message and color.
  4. Shows `Toast` (non-critical, wrapped in try/catch).
  5. **Intentionally omits auto-navigation** to prevent known Shell navigation crashes.
  6. Logs extensively via `AppLogger`.

### `SafeCreateDirectory(string path)`
- **Access:** `private static`
- **Behavior:** *(Commented out in current code but present)* Creates directory if missing. Logs failures but suppresses crashes.

### `VerifyDirectory(string path)`
- **Access:** `private static`
- **Behavior:** Checks `Directory.Exists(path)`. Creates it if missing. Used immediately after folder selection.

---
**💡 Developer Notes:**
- Uses `CommunityToolkit.Maui.Alerts` and `Storage` for modern picker/toast functionality.
- Hardcoded fallback paths (`C:\FrymasterData\...`) should be platform-aware for iOS/macOS/Android.
- Explicitly avoids `Shell.Current.GoToAsync("..")` after save to maintain navigation stability.