diff options
author | Scott Murray <scott.murray@konsulko.com> | 2022-12-24 15:30:10 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2022-12-29 01:22:55 -0500 |
commit | fe23ca5ecdabd698917c4e84915151fc32cb335e (patch) | |
tree | e9cad647d01f546107dfa820363a80c48e33c6e2 /lib/widgets/right_climate.dart | |
parent | 467221c592123125d6439871f02ef5e9ca0fe777 (diff) |
Rework temperature controls
Rework the temperature controls to use NumberPicker widgets so they
function more like a user would expect. The associated Riverpod
providers have been updated to track the temperature value directly,
and some minor layout tweaks have also been made.
Bug-AGL: SPEC-4644
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I069e0bd53c79d73cc7a60045309efdfeb9409fbc
Diffstat (limited to 'lib/widgets/right_climate.dart')
-rw-r--r-- | lib/widgets/right_climate.dart | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/widgets/right_climate.dart b/lib/widgets/right_climate.dart new file mode 100644 index 0000000..590b511 --- /dev/null +++ b/lib/widgets/right_climate.dart @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_hvac/provider.dart'; +import 'package:numberpicker/numberpicker.dart'; + +import '../kuksa-server/vehicle_methods.dart'; +import '../size.dart'; + +class RightClimateScrollWidget extends ConsumerWidget { + RightClimateScrollWidget({Key? key, required this.socket}) : super(key: key); + + WebSocket socket; + + @override + Widget build(BuildContext context, ref) { + final int _selectedTemp = ref.watch(RightClimateTempProvider); + + return SizedBox( + width: SizeConfig.screenWidth * 0.25, + height: SizeConfig.screenHeight * 0.30, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.white, + width: 2, + ), + borderRadius: BorderRadius.circular(12), + ), + child: NumberPicker( + minValue: 16, + maxValue: 33, + itemHeight: 100, + itemCount: 5, + value: _selectedTemp, + textMapper: (value) { + return value.toString() + '°'; + }, + onChanged: (value) { + ref.read(RightClimateTempProvider.notifier).update(value); + VISS.set( + socket, + ref, + 'Vehicle.Cabin.HVAC.Station.Row1.Right.Temperature', + value.toString()); + VISS.set( + socket, + ref, + 'Vehicle.Cabin.HVAC.Station.Row2.Right.Temperature', + value.toString()); + }, + selectedTextStyle: TextStyle( + color: Colors.lightBlueAccent, + fontWeight: FontWeight.w700, + fontSize: SizeConfig.fontsize * 4, + ), + textStyle: TextStyle( + color: Colors.white54, + fontWeight: FontWeight.w700, + fontSize: SizeConfig.fontsize * 4, + )))); + } +} |