Skip to content

Commit 44248d8

Browse files
committed
style: Adjust padding and margin in DeviceCard and DevicesScreen for improved layout consistency
1 parent a2966a2 commit 44248d8

3 files changed

Lines changed: 24 additions & 19 deletions

File tree

client/lib/devices/borneo/lyfi/manifest.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ class LyfiDeviceModuleMetadata extends DeviceModuleMetadata {
4747
);
4848

4949
static Widget _buildDeviceIcon(BuildContext context, double iconSize, bool isOnline) {
50-
return Icon(
51-
Icons.light_outlined,
52-
size: iconSize,
53-
color: isOnline
54-
? Theme.of(context).colorScheme.primary
55-
: Theme.of(context).colorScheme.primary.withValues(alpha: 0.38),
56-
);
50+
return Icon(Icons.light_outlined, size: iconSize, color: Theme.of(context).colorScheme.primary);
5751
}
5852

5953
static Widget _buildPrimaryStateIcon(BuildContext context, double iconSize) {
@@ -115,7 +109,7 @@ class LyfiDeviceModuleMetadata extends DeviceModuleMetadata {
115109
case LyfiMode.scheduled:
116110
return context.translate('Scheduled');
117111
case LyfiMode.sun:
118-
return context.translate('Sun Simulation');
112+
return context.translate('Sun');
119113
default:
120114
return '-';
121115
}
@@ -214,7 +208,7 @@ class _LyfiBrightnessChart extends StatelessWidget {
214208

215209
Widget _buildBarChart(BuildContext context, int channelCount) {
216210
final colorScheme = Theme.of(context).colorScheme;
217-
final barBackColor = colorScheme.surfaceContainerLow;
211+
final isDark = Theme.of(context).brightness == Brightness.dark;
218212

219213
// Adaptive bar width: shrink as channel count grows
220214
final barWidth =
@@ -243,6 +237,16 @@ class _LyfiBrightnessChart extends StatelessWidget {
243237
final fraction = (value / lyfiBrightnessMax).clamp(0.0, 1.0);
244238
final currentEndColor = Color.lerp(lightStart, primaryColor, fraction)!;
245239

240+
// Background rod: desaturate the channel color heavily and blend with the
241+
// surface so it looks muted but still carries a hint of the original hue.
242+
final hslColor = HSLColor.fromColor(primaryColor);
243+
final mutedColor = hslColor
244+
.withSaturation((hslColor.saturation * 0.25).clamp(0.0, 1.0))
245+
.withLightness(isDark ? 0.15 : 0.85)
246+
.toColor();
247+
// Blend with surface for a softer look
248+
final barBackColor = Color.lerp(colorScheme.surfaceContainerLow, mutedColor, 0.65)!;
249+
246250
groups.add(
247251
BarChartGroupData(
248252
x: i,
@@ -288,7 +292,7 @@ class _LyfiBrightnessChart extends StatelessWidget {
288292
label,
289293
style: Theme.of(context).textTheme.labelSmall?.copyWith(
290294
fontSize: channelCount > 6 ? 8.0 : 9.0,
291-
color: colorScheme.onSurface.withValues(alpha: 0.7),
295+
color: colorScheme.onSurface.withValues(alpha: 0.38),
292296
),
293297
);
294298
},

client/lib/features/devices/views/device_card.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class DeviceCard extends StatelessWidget {
3030
selector: (_, vm) => (isOnline: vm.isOnline, isPowerOn: vm.isPowerOn, name: vm.deviceEntity.name),
3131
builder: (context, status, _) {
3232
final colorScheme = Theme.of(context).colorScheme;
33-
final isActive = status.isOnline && status.isPowerOn;
34-
final bgColor = isActive ? colorScheme.surfaceContainerHighest : colorScheme.surfaceContainerLow;
33+
final bgColor = colorScheme.surfaceContainerHighest;
3534
final fgColor = colorScheme.onSurface;
3635

3736
return ClipRRect(
@@ -46,7 +45,7 @@ class DeviceCard extends StatelessWidget {
4645
onTap: vm.isBusy ? null : () => _openDevicePage(context, vm.deviceEntity),
4746
borderRadius: BorderRadius.circular(12),
4847
child: Padding(
49-
padding: const EdgeInsets.fromLTRB(10, 4, 4, 10),
48+
padding: const EdgeInsets.fromLTRB(8, 0, 4, 8),
5049
child: Column(
5150
crossAxisAlignment: CrossAxisAlignment.stretch,
5251
children: [
@@ -61,7 +60,9 @@ class DeviceCard extends StatelessWidget {
6160
status.name,
6261
maxLines: 1,
6362
overflow: TextOverflow.ellipsis,
64-
style: Theme.of(context).textTheme.labelMedium?.copyWith(color: fgColor),
63+
style: Theme.of(
64+
context,
65+
).textTheme.labelMedium?.copyWith(color: Theme.of(context).colorScheme.primary),
6566
),
6667
),
6768
_buildPopupMenu(context, fgColor),
@@ -70,7 +71,7 @@ class DeviceCard extends StatelessWidget {
7071
// Central content area
7172
Expanded(
7273
child: Padding(
73-
padding: const EdgeInsets.fromLTRB(2, 4, 8, 0),
74+
padding: const EdgeInsets.fromLTRB(2, 4, 8, 8),
7475
child: moduleMeta.summaryContentBuilder != null
7576
? moduleMeta.summaryContentBuilder!(context, vm)
7677
: Center(

client/lib/features/devices/views/devices_screen.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class DevicesScreen extends StatelessWidget {
253253
children: [
254254
// Group header
255255
Container(
256-
margin: const EdgeInsets.fromLTRB(16, 0, 16, 0),
256+
margin: const EdgeInsets.fromLTRB(8, 0, 8, 0),
257257
height: 48,
258258
child: Row(
259259
children: [
@@ -279,14 +279,14 @@ class DevicesScreen extends StatelessWidget {
279279
),
280280
// Device card grid
281281
GridView.builder(
282-
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
282+
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
283283
shrinkWrap: true,
284284
physics: const NeverScrollableScrollPhysics(),
285285
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
286286
crossAxisCount: crossAxisCount,
287287
childAspectRatio: 1.0,
288-
crossAxisSpacing: 16,
289-
mainAxisSpacing: 16,
288+
crossAxisSpacing: 8,
289+
mainAxisSpacing: 8,
290290
),
291291
itemCount: groupData.deviceCount,
292292
itemBuilder: (context, index) {

0 commit comments

Comments
 (0)