summaryrefslogtreecommitdiffstats
path: root/lib/bottom_panel.dart
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-12-28 15:05:26 -0500
committerScott Murray <scott.murray@konsulko.com>2022-12-29 06:35:38 +0000
commit4fbd3fdb9e01c197d972b78961f0d033534a5cc7 (patch)
treedef7bfc0d0f11746006439b33019b61dfc16e1b8 /lib/bottom_panel.dart
parente21709c9601209e26d09dea0a45e37f0636bb605 (diff)
Add volume control to bottom panel
Changes: - Import a reworked version of the KUKSA.val client code from the Flutter dashboard app, with the aggregated signal Riverpod provider replaced with per-signal providers for the signal the homescreen needs and a couple of temperature ones it might use. Using separate providers is more in-line with recommended Riverpod best practices. - Various tweaks to enable using Riverpod. - Split the bottom panel out into its own widget, and add a stack in it to layer the default logo panel with the volume control slider, which has been added as a new widget definition to provide the hook to drive timer based lowering behavior like the Qt homescreen does. - The KUKSA.val connection widget has been added to the bottom panel rather than overriding the top-level widget as in the dashboard and HVAC apps. This seems preferable with respect to still providing some functionality in the event KUKSA.val is unavailable. - Remove the old demo dashboard and HVAC pages that are now unused, along with the image assets they needed, to allow cleaning up pubspec.yaml and ease maintenance. Bug-AGL: SPEC-4659 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I5d9180a3461948a58321564e71134c4961ce0ef7
Diffstat (limited to 'lib/bottom_panel.dart')
-rw-r--r--lib/bottom_panel.dart84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/bottom_panel.dart b/lib/bottom_panel.dart
new file mode 100644
index 0000000..f61c59d
--- /dev/null
+++ b/lib/bottom_panel.dart
@@ -0,0 +1,84 @@
+import 'package:async/async.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:jovial_svg/jovial_svg.dart';
+import 'package:flutter_homescreen/volume_slider.dart';
+
+final StackIndexProvider = StateProvider<int>((ref) => 0);
+
+class BottomPanelWidget extends ConsumerStatefulWidget {
+ final double height;
+ final Color? color;
+
+ BottomPanelWidget({Key? key, required this.height, required this.color})
+ : super(key: key);
+
+ @override
+ _BottomPanelWidgetState createState() => _BottomPanelWidgetState();
+}
+
+class _BottomPanelWidgetState extends ConsumerState<BottomPanelWidget> {
+ final iconColor = const Color(0xff4ee6f5);
+ late RestartableTimer timer;
+
+ initState() {
+ super.initState();
+ timer = new RestartableTimer(Duration(seconds: 3), _timerExpired);
+ }
+
+ void _timerExpired() {
+ ref.read(StackIndexProvider.notifier).state = 0;
+ timer.cancel();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final int index = ref.watch(StackIndexProvider);
+
+ return SizedBox(
+ height: widget.height,
+ child: IndexedStack(index: index, children: <Widget>[
+ GestureDetector(
+ child: Container(
+ color: widget.color,
+ child: Align(
+ alignment: Alignment.center,
+ child: ScalableImageWidget.fromSISource(
+ si: ScalableImageSource.fromSvg(
+ rootBundle, 'images/Utility_Logo_Grey-01.svg')))),
+ onTap: () {
+ ref.read(StackIndexProvider.notifier).state = 1;
+ timer.reset();
+ },
+ ),
+ Container(
+ color: widget.color,
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(24, 8, 24, 8),
+ child: Stack(children: [
+ Column(children: [
+ Center(
+ child: Text("Volume",
+ style: TextStyle(
+ fontSize: 32, color: Colors.white))),
+ Spacer()
+ ]),
+ Row(children: [
+ Container(width: 24),
+ Text("0 %",
+ style: TextStyle(fontSize: 32, color: Colors.white)),
+ Expanded(
+ child: VolumeSlider(
+ thumbColor: Colors.white,
+ activeColor: iconColor,
+ inactiveColor: Colors.grey.shade600,
+ activityTimer: timer)),
+ Text("100 %",
+ style: TextStyle(fontSize: 32, color: Colors.white)),
+ Container(width: 24)
+ ]),
+ ])))
+ ]));
+ }
+}