diff options
| author | xengineering <me@xengineering.eu> | 2026-04-08 11:29:27 +0200 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-04-08 11:29:27 +0200 |
| commit | 9048de5d0ad7611fb92a51b59be332921a93b943 (patch) | |
| tree | 9789c4af85f680d877be9af9e5fff1614b4e8c05 /lib/ui.dart | |
| parent | c2110a2098d475c5fa06d265833e229fad938e8d (diff) | |
| parent | e4c61d1b669a43d292be1f40d5b36dbcb93500a4 (diff) | |
| download | sia-app-9048de5d0ad7611fb92a51b59be332921a93b943.tar sia-app-9048de5d0ad7611fb92a51b59be332921a93b943.tar.zst sia-app-9048de5d0ad7611fb92a51b59be332921a93b943.zip | |
Merge cover control
This allows the user to move covers controlled by the Sia server to move
up, down and to stop them.
Diffstat (limited to 'lib/ui.dart')
| -rw-r--r-- | lib/ui.dart | 94 |
1 files changed, 87 insertions, 7 deletions
diff --git a/lib/ui.dart b/lib/ui.dart index 3a98be9..66078da 100644 --- a/lib/ui.dart +++ b/lib/ui.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:mqtt_client/mqtt_client.dart'; import 'data.dart'; @@ -90,14 +91,25 @@ class DevicesPage extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text("Contacts")), - body: const Column( - children: <Widget>[ - Expanded(child: ContactList()), - ], + return const Scaffold( + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: <Widget>[ + Padding( + padding: EdgeInsets.all(15.0), + child: Text("Contacts", style: TextStyle(fontSize: 22)), + ), + ContactList(), + Padding( + padding: EdgeInsets.all(15.0), + child: Text("Covers", style: TextStyle(fontSize: 22)), + ), + CoverList(), + ], + ), ), - bottomNavigationBar: const ConnectionStatus(), + bottomNavigationBar: ConnectionStatus(), ); } } @@ -110,6 +122,8 @@ class ContactList extends StatelessWidget { return Consumer<AppState>( builder: (BuildContext context, AppState state, Widget? child) { return ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), itemCount: state.contacts.length, itemBuilder: (BuildContext context, int index) { MapEntry<String, bool> data = state.contacts.entries.elementAt(index); @@ -129,6 +143,72 @@ class ContactList extends StatelessWidget { } } +class CoverList extends StatelessWidget { + const CoverList({super.key}); + + @override + Widget build(BuildContext context) { + return Consumer<AppState>( + builder: (BuildContext context, AppState state, Widget? child) { + return ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: state.covers.length, + itemBuilder: (BuildContext context, int index) { + String cover = state.covers.elementAt(index); + return Column( + children: <Widget>[ + ListTile( + leading: const Icon(Icons.roller_shades), + title: Text(cover), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: <Widget>[ + IconButton( + icon: const Icon(Icons.arrow_upward), + constraints: const BoxConstraints(), + onPressed: () { + state.publish( + 'cover/$cover/movement', + 'retract', + MqttQos.exactlyOnce + ); + }, + ), + IconButton( + icon: const Icon(Icons.stop), + constraints: const BoxConstraints(), + onPressed: () { + state.publish( + 'cover/$cover/movement', + 'stop', + MqttQos.exactlyOnce + ); + }, + ), + IconButton( + icon: const Icon(Icons.arrow_downward), + constraints: const BoxConstraints(), + onPressed: () { + state.publish( + 'cover/$cover/movement', + 'extend', + MqttQos.exactlyOnce + ); + }, + ), + ], + ), + ), + ], + ); + }, + ); + }, + ); + } +} + class ConnectionStatus extends StatelessWidget { const ConnectionStatus({super.key}); |
