summaryrefslogtreecommitdiff
path: root/lib/widgets/device_details.dart
diff options
context:
space:
mode:
authoruvok2025-08-02 10:26:31 +0200
committeruvok2025-08-02 10:26:31 +0200
commite82083b9e2166b4e427ae23630871914dc72f276 (patch)
treea70a4182b61f8381e69500e03e3a926d08df0707 /lib/widgets/device_details.dart
parentc74b7197d7e120a63733dbcf3326097aacbad795 (diff)
DD: Pull up button, error text, ViewModel
ListView should really only be a list. Makes more sense to add error after rfresh button.
Diffstat (limited to 'lib/widgets/device_details.dart')
-rw-r--r--lib/widgets/device_details.dart38
1 files changed, 31 insertions, 7 deletions
diff --git a/lib/widgets/device_details.dart b/lib/widgets/device_details.dart
index 17319f4..0463522 100644
--- a/lib/widgets/device_details.dart
+++ b/lib/widgets/device_details.dart
@@ -30,14 +30,19 @@ class DeviceDetailsScreen extends StatefulWidget {
final Device device;
final DeviceConnection deviceConnection;
- final BadgeMotiveSelection _motiveSelection;
+ late final BadgeMotiveSelection _motiveSelection;
+ late final BadgeMotiveViewModel _motiveVM;
DeviceDetailsScreen({
super.key,
required this.device,
required this.deviceConnection,
- }) : _motiveSelection =
- BadgeMotiveSelectionFactory.createBadgeMotiveSelection(device);
+ }) {
+ _motiveSelection = BadgeMotiveSelectionFactory.createBadgeMotiveSelection(
+ device,
+ );
+ _motiveVM = BadgeMotiveViewModel(motivSelect: _motiveSelection);
+ }
@override
State<StatefulWidget> createState() {
@@ -77,11 +82,30 @@ class DeviceDetailsState extends State<DeviceDetailsScreen> {
children: [
SizedBox(height: 20),
Text("Connection state: ${value.toString()}"),
- BadgeMotiveList(
- motiveVM: BadgeMotiveViewModel(
- motivSelect: widget._motiveSelection,
- ),
+ ElevatedButton(
+ child: Text("Refresh"),
+ onPressed: () async {
+ await widget._motiveVM.updateMotives();
+ await widget._motiveVM.getCurrentMotive();
+ },
+ ),
+ ListenableBuilder(
+ listenable: widget._motiveVM,
+ builder: (errorCtx, child) {
+ if (widget._motiveVM.errorMessage != null) {
+ var theme = Theme.of(errorCtx);
+ return Text(
+ widget._motiveVM.errorMessage!,
+ style: TextStyle(
+ color: theme.colorScheme.error,
+ fontWeight: FontWeight.bold,
+ ),
+ );
+ }
+ return Container();
+ },
),
+ BadgeMotiveList(motiveVM: widget._motiveVM),
],
);
},