| .. | .. |
|---|
| 5 | 5 | import 'package:vibration/vibration.dart'; |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import '../providers/providers.dart'; |
|---|
| 8 | +import '../services/navigate_notifier.dart'; |
|---|
| 8 | 9 | import '../theme/app_theme.dart'; |
|---|
| 9 | 10 | |
|---|
| 10 | 11 | /// Terminal navigation screen with screenshot display and key grid. |
|---|
| .. | .. |
|---|
| 196 | 197 | final activeSessionId = ref.read(activeSessionIdProvider); |
|---|
| 197 | 198 | |
|---|
| 198 | 199 | // Send a key press to the AIBroker daemon via the MQTT service. |
|---|
| 199 | | - // NavigateNotifier bridges the navigate screen to the chat screen's MQTT service. |
|---|
| 200 | + // navigateNotifierProvider bridges the navigate screen to the chat screen's MQTT service. |
|---|
| 200 | 201 | |
|---|
| 201 | | - NavigateNotifier.instance?.sendKey(key, activeSessionId); |
|---|
| 202 | + ref.read(navigateNotifierProvider)?.sendKey(key, activeSessionId); |
|---|
| 202 | 203 | |
|---|
| 203 | 204 | // Request updated screenshot after key |
|---|
| 204 | 205 | Future.delayed(const Duration(milliseconds: 500), _requestScreenshot); |
|---|
| .. | .. |
|---|
| 206 | 207 | |
|---|
| 207 | 208 | void _requestScreenshot() { |
|---|
| 208 | 209 | final activeSessionId = ref.read(activeSessionIdProvider); |
|---|
| 209 | | - NavigateNotifier.instance?.requestScreenshot(activeSessionId); |
|---|
| 210 | + ref.read(navigateNotifierProvider)?.requestScreenshot(activeSessionId); |
|---|
| 210 | 211 | } |
|---|
| 211 | 212 | |
|---|
| 212 | 213 | Future<void> _haptic() async { |
|---|
| .. | .. |
|---|
| 219 | 220 | } |
|---|
| 220 | 221 | } |
|---|
| 221 | 222 | |
|---|
| 222 | | -/// Global notifier to bridge navigate screen to MQTT service. |
|---|
| 223 | | -/// Set by ChatScreen when MQTT is initialized. |
|---|
| 224 | | -class NavigateNotifier { |
|---|
| 225 | | - static NavigateNotifier? instance; |
|---|
| 226 | | - |
|---|
| 227 | | - final void Function(String key, String? sessionId) sendKey; |
|---|
| 228 | | - final void Function(String? sessionId) requestScreenshot; |
|---|
| 229 | | - |
|---|
| 230 | | - NavigateNotifier({ |
|---|
| 231 | | - required this.sendKey, |
|---|
| 232 | | - required this.requestScreenshot, |
|---|
| 233 | | - }); |
|---|
| 234 | | -} |
|---|