diff options
| -rw-r--r-- | lib/data.dart | 5 | ||||
| -rw-r--r-- | lib/ui.dart | 31 |
2 files changed, 22 insertions, 14 deletions
diff --git a/lib/data.dart b/lib/data.dart index eaf301a..365f5bc 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart'; -const String brokerHostname = 'sia.xengineering.eu'; const int brokerPort = 1883; const String topicPrefix = 'sia'; @@ -47,6 +46,8 @@ class AppState with ChangeNotifier { Map<String, bool> contacts = <String, bool>{}; late MqttServerClient _client; + String fqdn = ''; + AppState(); void process(MachineEvent event) { @@ -86,7 +87,7 @@ class AppState with ChangeNotifier { void _initMqtt() { _client = MqttServerClient( - brokerHostname, + fqdn, 'sia_app_${DateTime.now().millisecondsSinceEpoch}', ); diff --git a/lib/ui.dart b/lib/ui.dart index 7a97f32..a191f5f 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -29,19 +29,26 @@ class ConnectionPage extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text("Connection")), - body: const Padding( - padding: EdgeInsets.all(16.0), - child: TextField( - decoration: InputDecoration( - labelText: "Server name", - hintText: "iot.example.org", - border: OutlineInputBorder(), + return Consumer<AppState>( + builder: (_, AppState state, _) { + return Scaffold( + appBar: AppBar(title: const Text("Connection")), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: TextField( + decoration: const InputDecoration( + labelText: "Server name", + hintText: "iot.example.org", + border: OutlineInputBorder(), + ), + onChanged: (String value) { + state.fqdn = value; + }, + ), ), - ), - ), - bottomNavigationBar: const ConnectionStatus(), + bottomNavigationBar: const ConnectionStatus(), + ); + } ); } } |
