|
1 | 1 | # SettingActivity |
2 | 2 |
|
3 | | -`SettingActivity` is used to edit a single setting with various UI options. It provides a flexible framework for collecting user input with support for text input, radio buttons, dropdowns, and custom Activity implementations. |
| 3 | +`SettingActivity` is used to edit a single setting with various UI options. It provides a flexible framework for collecting user input with support for text input, radio buttons, dropdowns, sliders, and custom Activity implementations. |
4 | 4 |
|
5 | 5 | ## Overview |
6 | 6 |
|
@@ -36,13 +36,15 @@ Each setting is defined as a dictionary with the following properties: |
36 | 36 | - **`key`** (string): Unique identifier used as the SharedPreferences key |
37 | 37 |
|
38 | 38 | ### Optional Properties |
39 | | -- **`ui`** (string): UI type to use for editing. Options: `"textarea"` (default), `"radiobuttons"`, `"dropdown"`, `"activity"` |
| 39 | +- **`ui`** (string): UI type to use for editing. Options: `"textarea"` (default), `"radiobuttons"`, `"dropdown"`, `"slider"`, `"activity"` |
40 | 40 | - **`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types |
41 | 41 | - **`placeholder`** (string): Placeholder text for textarea input |
42 | 42 | - **`default_value`** (string): Default value to select or fill in |
43 | 43 | - **`changed_callback`** (function): Callback function called when the setting value changes |
44 | 44 | - **`should_show`** (function): Function to determine if this setting should be displayed |
45 | 45 | - **`dont_persist`** (bool): If `True`, the setting won't be saved to SharedPreferences |
| 46 | +- **`min`** (int): Minimum value for `"slider"` UI (default: `0`) |
| 47 | +- **`max`** (int): Maximum value for `"slider"` UI (default: `100`) |
46 | 48 | - **`activity_class`** (class): Custom Activity class for `"activity"` UI type |
47 | 49 | - **`value_label`** (widget): Internal reference to the value label (set by SettingsActivity) |
48 | 50 | - **`cont`** (widget): Internal reference to the container (set by SettingsActivity) |
@@ -140,7 +142,36 @@ ui_options = [ |
140 | 142 | - Shows label and value if different |
141 | 143 | - Automatically selects the current value |
142 | 144 |
|
143 | | -### 4. Custom Activity |
| 145 | +### 4. Slider |
| 146 | + |
| 147 | +Slider widget for integer values with real-time value display. |
| 148 | + |
| 149 | +**When to use:** For numeric settings like volume, brightness, speed, or any integer within a range. |
| 150 | + |
| 151 | +**Keys:** |
| 152 | +- **`min`** (int, default `0`): Minimum value (leftmost position) |
| 153 | +- **`max`** (int, default `100`): Maximum value (rightmost position) |
| 154 | + |
| 155 | +**Example:** |
| 156 | +```python |
| 157 | +{ |
| 158 | + "title": "Volume", |
| 159 | + "key": "volume", |
| 160 | + "ui": "slider", |
| 161 | + "default_value": "50", |
| 162 | + "min": 0, |
| 163 | + "max": 100, |
| 164 | + "changed_callback": self.on_volume_changed |
| 165 | +} |
| 166 | +``` |
| 167 | + |
| 168 | +**Features:** |
| 169 | +- Large label showing the current value above the slider |
| 170 | +- Real-time value updates as the user drags |
| 171 | +- Automatic clamping to `[min, max]` range |
| 172 | +- Value is persisted as a string (e.g. `"50"`) |
| 173 | + |
| 174 | +### 5. Custom Activity |
144 | 175 |
|
145 | 176 | Use a custom Activity class for advanced UI implementations. |
146 | 177 |
|
|
0 commit comments