Skip to content

Commit 5d6b28e

Browse files
committed
fix: eew intensity legend to vertical left
1 parent 776cf30 commit 5d6b28e

2 files changed

Lines changed: 75 additions & 77 deletions

File tree

lib/app/map/_lib/managers/monitor.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'package:dpip/utils/extensions/number.dart';
1717
import 'package:dpip/utils/instrumental_intensity_color.dart';
1818
import 'package:dpip/utils/intensity_color.dart';
1919
import 'package:dpip/utils/log.dart';
20+
import 'package:dpip/widgets/blurred_container.dart';
2021
import 'package:dpip/widgets/map/intensity_legend.dart';
2122
import 'package:dpip/widgets/map/map.dart';
2223
import 'package:dpip/widgets/responsive/responsive_container.dart';
@@ -1635,17 +1636,20 @@ class _MonitorMapLayerSheetState extends State<MonitorMapLayerSheet> {
16351636
},
16361637
),
16371638
),
1638-
// Intensity legend - positioned at top right, just below buttons
1639+
// Intensity legend - positioned at top left
16391640
// Show RTS mode when no EEW, show EEW mode during EEW
1640-
// Hide when sheet is expanded
16411641
Positioned(
1642-
top: 80,
1643-
right: 16,
1642+
top: 24 + 48 + 16,
1643+
left: 24,
16441644
child: SafeArea(
1645-
child: IntensityLegend(
1646-
mode: activeEew.isNotEmpty
1647-
? IntensityLegendMode.eew
1648-
: IntensityLegendMode.rts,
1645+
child: BlurredContainer(
1646+
elevation: 4,
1647+
shadowColor: context.colors.shadow.withValues(alpha: 0.4),
1648+
child: IntensityLegend(
1649+
mode: activeEew.isNotEmpty
1650+
? IntensityLegendMode.eew
1651+
: IntensityLegendMode.rts,
1652+
),
16491653
),
16501654
),
16511655
),

lib/widgets/map/intensity_legend.dart

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,90 +17,84 @@ class IntensityLegend extends StatelessWidget {
1717

1818
List<Color> get _colors => mode == IntensityLegendMode.eew
1919
? List.generate(9, (i) => IntensityColor.intensity(i + 1))
20-
: List.generate(11, (i) => InstrumentalIntensityColor.intensity(i - 3));
20+
: List.generate(11, (i) => InstrumentalIntensityColor.intensity(7 - i));
2121

2222
List<String> get _labels => mode == IntensityLegendMode.eew
2323
? const ['1', '2', '3', '4', '5⁻', '5⁺', '6⁻', '6⁺', '7']
2424
: const ['-3', '-2', '-1', '0', '1', '2', '3', '4', '5', '6', '7'];
2525

2626
@override
2727
Widget build(BuildContext context) {
28-
final screenWidth = MediaQuery.of(context).size.width;
29-
final width = screenWidth / 2;
30-
31-
return SizedBox(
32-
width: width,
33-
child: Column(
34-
mainAxisSize: MainAxisSize.min,
35-
crossAxisAlignment: CrossAxisAlignment.end,
36-
children: [
37-
_buildColorBar(width),
38-
const SizedBox(height: 2),
39-
_buildLabels(width),
40-
],
41-
),
28+
return Column(
29+
mainAxisSize: MainAxisSize.min,
30+
crossAxisAlignment: CrossAxisAlignment.start,
31+
children: _buildLegendItems(),
4232
);
4333
}
4434

45-
Widget _buildColorBar(double width) {
35+
List<Widget> _buildLegendItems() {
36+
final colors = mode == IntensityLegendMode.eew ? _colors.reversed.toList() : _colors;
37+
final labels = _labels.reversed.toList();
38+
4639
if (mode == IntensityLegendMode.eew) {
47-
// EEW mode: discrete color blocks
48-
return ClipRRect(
49-
borderRadius: BorderRadius.circular(4),
50-
child: SizedBox(
51-
height: 8,
52-
width: width,
53-
child: Row(
54-
children: _colors.map((color) {
55-
return Expanded(child: Container(color: color));
56-
}).toList(),
57-
),
58-
),
59-
);
40+
return List.generate(colors.length, (index) {
41+
return Row(
42+
mainAxisSize: MainAxisSize.min,
43+
crossAxisAlignment: CrossAxisAlignment.center,
44+
children: [
45+
Container(
46+
height: 12,
47+
width: 16,
48+
color: colors[index],
49+
),
50+
const SizedBox(width: 6),
51+
Text(
52+
labels[index],
53+
style: const TextStyle(fontSize: 10, height: 1),
54+
),
55+
],
56+
);
57+
});
6058
} else {
61-
// RTS mode: gradient
62-
return Container(
63-
height: 8,
64-
width: width,
65-
decoration: BoxDecoration(
66-
borderRadius: BorderRadius.circular(4),
67-
gradient: LinearGradient(colors: _colors),
68-
),
69-
);
70-
}
71-
}
59+
final labelWidgets = labels.map((label) {
60+
return Expanded(
61+
child: Text(
62+
label,
63+
style: const TextStyle(fontSize: 9, height: 1),
64+
textAlign: TextAlign.left,
65+
),
66+
);
67+
}).toList();
7268

73-
Widget _buildLabels(double width) {
74-
if (mode == IntensityLegendMode.eew) {
75-
// EEW mode: labels centered under each color block
76-
return SizedBox(
77-
width: width,
78-
child: Row(
79-
children: _labels.map((label) {
80-
return Expanded(
81-
child: Text(
82-
label,
83-
style: const TextStyle(fontSize: 9),
84-
textAlign: TextAlign.center,
69+
return [
70+
Row(
71+
mainAxisSize: MainAxisSize.min,
72+
crossAxisAlignment: CrossAxisAlignment.start,
73+
children: [
74+
Container(
75+
height: 12.0 * colors.length,
76+
width: 16,
77+
decoration: BoxDecoration(
78+
borderRadius: BorderRadius.circular(4),
79+
gradient: LinearGradient(
80+
colors: colors,
81+
begin: Alignment.topCenter,
82+
end: Alignment.bottomCenter,
83+
),
8584
),
86-
);
87-
}).toList(),
88-
),
89-
);
90-
} else {
91-
// RTS mode: labels at edges
92-
return SizedBox(
93-
width: width,
94-
child: Row(
95-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
96-
children: _labels.map((label) {
97-
return Text(
98-
label,
99-
style: const TextStyle(fontSize: 9),
100-
);
101-
}).toList(),
85+
),
86+
const SizedBox(width: 6),
87+
SizedBox(
88+
height: 12.0 * colors.length,
89+
child: Column(
90+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
91+
crossAxisAlignment: CrossAxisAlignment.start,
92+
children: labelWidgets,
93+
),
94+
),
95+
],
10296
),
103-
);
97+
];
10498
}
10599
}
106100
}

0 commit comments

Comments
 (0)