Skip to content

Commit 12b3dff

Browse files
committed
cosmetics
1 parent f5e6970 commit 12b3dff

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

mobile/lib/providers/config_provider.dart

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ConfigProvider with ChangeNotifier {
3636
fetchConfig();
3737
}
3838

39-
Future<void> fetchConfig({int retries = 3}) async {
39+
Future<void> fetchConfig({int retries = 9}) async {
4040
_isLoading = true;
4141
_error = null;
4242
notifyListeners();
@@ -50,11 +50,13 @@ class ConfigProvider with ChangeNotifier {
5050
} catch (e) {
5151
attempt++;
5252
final msg = e.toString();
53-
if (attempt <= retries &&
54-
(msg.contains("Invalid response line") || msg.contains("Connection closed") || msg.contains("Connection refused"))) {
53+
if (attempt <= retries &&
54+
(msg.contains("Invalid response line") ||
55+
msg.contains("Connection closed") ||
56+
msg.contains("Connection refused"))) {
5557
// Wait a bit for server to come back up
5658
await Future.delayed(Duration(milliseconds: 500 * attempt));
57-
continue;
59+
continue;
5860
}
5961
_error = "Attempt $attempt failed:\n$msg";
6062
}
@@ -71,14 +73,15 @@ class ConfigProvider with ChangeNotifier {
7173

7274
try {
7375
await _apiService.saveConfig(newConfig);
74-
_config = newConfig;
75-
// After a successful save, the server will restart.
76+
_config = newConfig;
77+
// After a successful save, the server will restart.
7678
// We give it a moment then fetch the latest state to confirm.
7779
await Future.delayed(const Duration(milliseconds: 500));
7880
await fetchConfig();
7981
} catch (e) {
8082
final msg = e.toString();
81-
if (msg.contains("Invalid response line") || msg.contains("Connection closed")) {
83+
if (msg.contains("Invalid response line") ||
84+
msg.contains("Connection closed")) {
8285
// Server likely restarted immediately after save. Treat as success and reload.
8386
await fetchConfig();
8487
return;
@@ -89,19 +92,31 @@ class ConfigProvider with ChangeNotifier {
8992
notifyListeners();
9093
}
9194
}
92-
95+
9396
void toggleProducer(String producerName, bool isEnabled) {
94-
if (_config == null) return;
95-
97+
if (_config == null) return;
98+
9699
switch (producerName) {
97-
case 'SensorLED': _config!.sensorLED.enabled = isEnabled; break;
98-
case 'NightLED': _config!.nightLED.enabled = isEnabled; break;
99-
case 'ClockLED': _config!.clockLED.enabled = isEnabled; break;
100-
case 'AudioLED': _config!.audioLED.enabled = isEnabled; break;
101-
case 'CylonLED': _config!.cylonLED.enabled = isEnabled; break;
102-
case 'MultiBlobLED': _config!.multiBlobLED.enabled = isEnabled; break;
100+
case 'SensorLED':
101+
_config!.sensorLED.enabled = isEnabled;
102+
break;
103+
case 'NightLED':
104+
_config!.nightLED.enabled = isEnabled;
105+
break;
106+
case 'ClockLED':
107+
_config!.clockLED.enabled = isEnabled;
108+
break;
109+
case 'AudioLED':
110+
_config!.audioLED.enabled = isEnabled;
111+
break;
112+
case 'CylonLED':
113+
_config!.cylonLED.enabled = isEnabled;
114+
break;
115+
case 'MultiBlobLED':
116+
_config!.multiBlobLED.enabled = isEnabled;
117+
break;
103118
}
104-
119+
105120
updateConfig(_config!);
106121
}
107122
}

mobile/lib/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ List<double> toRgbList(Color c) {
1515
/// while preserving its hue and saturation.
1616
Color toDisplayColor(Color actualColor) {
1717
final hsv = HSVColor.fromColor(actualColor);
18-
// Make the minimum hsv.value 0.3 and scale accordingly with lower slope.
18+
// Make the minimum hsv.value 0.4 and scale accordingly with lower slope.
1919
// But let's make sure black remains black.'
2020
if (hsv.value == 0) {
2121
return Color(0xFF000000);
2222
}
23-
return hsv.withValue(0.3 + (0.7 * hsv.value)).toColor();
23+
return hsv.withValue(0.4 + (0.6 * hsv.value)).toColor();
2424
}
2525

2626
/// Generates a glow effect proportional to the actual color's intensity.

0 commit comments

Comments
 (0)