Matthias Nott
2026-03-25 650b02ddcc20266acbb658b6ad669caf99f6aa74
lib/screens/settings_screen.dart
....@@ -1,5 +1,6 @@
11 import 'package:flutter/material.dart';
22 import 'package:flutter_riverpod/flutter_riverpod.dart';
3
+import 'package:shared_preferences/shared_preferences.dart';
34
45 import '../models/server_config.dart';
56 import '../providers/providers.dart';
....@@ -249,6 +250,44 @@
249250 label: const Text('Wake Mac'),
250251 ),
251252 const SizedBox(height: 12),
253
+
254
+ // Reset TLS Trust button
255
+ OutlinedButton.icon(
256
+ onPressed: () async {
257
+ final confirmed = await showDialog<bool>(
258
+ context: context,
259
+ builder: (ctx) => AlertDialog(
260
+ title: const Text('Reset Server Trust?'),
261
+ content: const Text(
262
+ 'This clears the saved server certificate fingerprint. '
263
+ 'Use this if you reinstalled AIBroker or changed servers. '
264
+ 'The app will trust the next server it connects to.',
265
+ ),
266
+ actions: [
267
+ TextButton(
268
+ onPressed: () => Navigator.pop(ctx, false),
269
+ child: const Text('Cancel'),
270
+ ),
271
+ TextButton(
272
+ onPressed: () => Navigator.pop(ctx, true),
273
+ child: const Text('Reset', style: TextStyle(color: AppColors.error)),
274
+ ),
275
+ ],
276
+ ),
277
+ );
278
+ if (confirmed == true && mounted) {
279
+ // Access MqttService through the provider and reset trust
280
+ final prefs = await SharedPreferences.getInstance();
281
+ await prefs.remove('trustedCertFingerprint');
282
+ ScaffoldMessenger.of(context).showSnackBar(
283
+ const SnackBar(content: Text('Server trust reset. Reconnect to trust the new server.')),
284
+ );
285
+ }
286
+ },
287
+ icon: const Icon(Icons.shield_outlined),
288
+ label: const Text('Reset Server Trust'),
289
+ ),
290
+ const SizedBox(height: 12),
252291 ],
253292 ),
254293 ),