Move backend config to a dialog; group settings into cards

Settings screen now splits responsibilities:
- Backend URL + API key move into a Test/Save popup dialog
  (backend_config_dialog.dart), reachable via a "Re-configure" action.
  Per M3 the Test button is left-aligned (neutral) with Cancel/Save
  grouped trailing. On first run the dialog auto-opens non-dismissible.
- The screen shows the connection read-only (URL plain, key masked with
  reveal) in a "Backend connection" card, and groups Theme + Push into an
  "App settings" card. Theme and push apply immediately, no Save button.
- Align all card titles to titleLarge across home/status/settings.

Adds a test seam (dioBuilderForTesting) so reconfigure keeps the mock Dio
in widget tests instead of issuing real requests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-08 18:15:10 -04:00
co-authored by Claude Opus 4.8
parent 1d85ec6f83
commit 67b94b89a1
8 changed files with 564 additions and 217 deletions
+9 -1
View File
@@ -37,12 +37,20 @@ class BackendAPI {
late String _apiKey;
late Dio _dio;
/// Test-only override for how [reconfigureFromPrefs] builds its [Dio], so a
/// reconfigure (e.g. after saving the backend settings) keeps using a client
/// backed by a mock adapter instead of issuing real network requests.
@visibleForTesting
static Dio Function(String baseUrl, String apiKey)? dioBuilderForTesting;
void reconfigureFromPrefs() {
_baseUrl =
PrefUtil.getValue("base_url", "http://localhost:3000/api") as String;
_apiKey = XOR().xorDecode(PrefUtil.getValue("api_key", "") as String);
_dio = buildDio(baseUrl: _baseUrl, apiKey: _apiKey);
_dio =
dioBuilderForTesting?.call(_baseUrl, _apiKey) ??
buildDio(baseUrl: _baseUrl, apiKey: _apiKey);
BackendReachability.instance.setProber(() => _dio.get('/test'));
}