@@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
22import 'package:flutter_gettext/flutter_gettext/context_ext.dart' ;
33import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart' ;
44import 'package:provider/provider.dart' ;
5+
6+ import 'package:borneo_app/features/devices/widgets/dashboard_tile.dart' ;
7+
58import '../../view_models/lyfi_view_model.dart' ;
69import '../dimming_screen.dart' ;
710import 'package:borneo_kernel/drivers/borneo/lyfi/models.dart' ;
@@ -22,79 +25,65 @@ class DashboardDimmingTile extends StatelessWidget {
2225 final Color effectiveFgColor = isDisabled ? fgColor.withValues (alpha: disabledAlpha) : fgColor;
2326 final Color iconColor = theme.colorScheme.primary;
2427 final Color effectiveIconColor = isDisabled ? iconColor.withValues (alpha: disabledAlpha) : iconColor;
25- return AspectRatio (
26- aspectRatio: 2.0 ,
27- child: Container (
28- decoration: BoxDecoration (color: bgColor, borderRadius: BorderRadius .circular (16 )),
29- child: Material (
30- color: Colors .transparent,
31- child: InkWell (
32- borderRadius: BorderRadius .circular (16 ),
33- onTap: (canUnlock && context.read <LyfiViewModel >().isOnline)
34- ? () async {
35- final vm = context.read <LyfiViewModel >();
36- // Request entering dimming (unlock) then wait for readiness event-driven
37- await vm.toggleLock (false );
38- await vm.onDimmingReady ();
28+ return DashboardTile (
29+ backgroundColor: bgColor,
30+ disabled: ! (canUnlock && context.read <LyfiViewModel >().isOnline),
31+ onPressed: (canUnlock && context.read <LyfiViewModel >().isOnline)
32+ ? () async {
33+ final vm = context.read <LyfiViewModel >();
34+ // Request entering dimming (unlock) then wait for readiness event-driven
35+ await vm.toggleLock (false );
36+ await vm.onDimmingReady ();
3937
40- if (context.mounted) {
41- await PersistentNavBarNavigator .pushNewScreen (
42- context,
43- screen: ChangeNotifierProvider .value (value: vm, child: const DimmingScreen ()),
44- withNavBar: false ,
45- pageTransitionAnimation: PageTransitionAnimation .slideRight,
46- );
47- }
48- }
49- : null ,
50- child: Padding (
51- padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 ),
52- child: Row (
53- crossAxisAlignment: CrossAxisAlignment .center,
54- children: [
55- Selector <LyfiViewModel , LyfiMode >(
56- selector: (_, vm) => vm.mode,
57- builder: (context, mode, _) {
58- final modeIcon = switch (mode) {
59- LyfiMode .manual => Icons .bar_chart_outlined,
60- LyfiMode .scheduled => Icons .alarm_outlined,
61- LyfiMode .sun => Icons .wb_sunny_outlined,
62- };
63- return Icon (modeIcon, size: 32 , color: effectiveIconColor);
64- },
65- ),
66- const SizedBox (width: 8 ),
67- Expanded (
68- child: Column (
69- mainAxisAlignment: MainAxisAlignment .center,
70- crossAxisAlignment: CrossAxisAlignment .start,
71- children: [
72- Text (
73- context.translate ('Dimming' ),
74- style: theme.textTheme.titleMedium? .copyWith (color: effectiveFgColor),
75- ),
76- Selector <LyfiViewModel , LyfiMode >(
77- selector: (_, vm) => vm.mode,
78- builder: (context, mode, _) {
79- final modeText = switch (mode) {
80- LyfiMode .manual => context.translate ('Manual' ),
81- LyfiMode .scheduled => context.translate ('Scheduled' ),
82- LyfiMode .sun => context.translate ('Sun Simulation' ),
83- };
84- return Text (
85- modeText,
86- style: theme.textTheme.bodySmall? .copyWith (color: effectiveFgColor),
87- );
88- },
89- ),
90- ],
91- ),
92- ),
93- ],
94- ),
38+ if (context.mounted) {
39+ await PersistentNavBarNavigator .pushNewScreen (
40+ context,
41+ screen: ChangeNotifierProvider .value (value: vm, child: const DimmingScreen ()),
42+ withNavBar: false ,
43+ pageTransitionAnimation: PageTransitionAnimation .slideRight,
44+ );
45+ }
46+ }
47+ : null ,
48+ child: Row (
49+ crossAxisAlignment: CrossAxisAlignment .center,
50+ children: [
51+ Selector <LyfiViewModel , LyfiMode >(
52+ selector: (_, vm) => vm.mode,
53+ builder: (context, mode, _) {
54+ final modeIcon = switch (mode) {
55+ LyfiMode .manual => Icons .bar_chart_outlined,
56+ LyfiMode .scheduled => Icons .alarm_outlined,
57+ LyfiMode .sun => Icons .wb_sunny_outlined,
58+ };
59+ return Icon (modeIcon, size: 32 , color: effectiveIconColor);
60+ },
61+ ),
62+ const SizedBox (width: 8 ),
63+ Expanded (
64+ child: Column (
65+ mainAxisAlignment: MainAxisAlignment .center,
66+ crossAxisAlignment: CrossAxisAlignment .start,
67+ children: [
68+ Text (
69+ context.translate ('Dimming' ),
70+ style: theme.textTheme.titleMedium? .copyWith (color: effectiveFgColor),
71+ ),
72+ Selector <LyfiViewModel , LyfiMode >(
73+ selector: (_, vm) => vm.mode,
74+ builder: (context, mode, _) {
75+ final modeText = switch (mode) {
76+ LyfiMode .manual => context.translate ('Manual' ),
77+ LyfiMode .scheduled => context.translate ('Scheduled' ),
78+ LyfiMode .sun => context.translate ('Sun Simulation' ),
79+ };
80+ return Text (modeText, style: theme.textTheme.bodySmall? .copyWith (color: effectiveFgColor));
81+ },
82+ ),
83+ ],
9584 ),
9685 ),
97- ) ,
86+ ] ,
9887 ),
9988 );
10089 },
0 commit comments