Skip to content

Commit 73c6270

Browse files
committed
fix: eew intensity area
1 parent 28672e8 commit 73c6270

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:dpip/utils/instrumental_intensity_color.dart';
1818
import 'package:dpip/utils/intensity_color.dart';
1919
import 'package:dpip/utils/log.dart';
2020
import 'package:dpip/widgets/map/map.dart';
21+
import 'package:dpip/widgets/map/intensity_legend.dart';
2122
import 'package:dpip/widgets/responsive/responsive_container.dart';
2223
import 'package:dpip/widgets/sheet/morphing_sheet.dart';
2324
import 'package:flutter/material.dart';
@@ -1633,6 +1634,21 @@ class _MonitorMapLayerSheetState extends State<MonitorMapLayerSheet> {
16331634
},
16341635
),
16351636
),
1637+
// Intensity legend - positioned at top right, just below buttons
1638+
// Show RTS mode when no EEW, show EEW mode during EEW
1639+
// Hide when sheet is expanded
1640+
if (_isCollapsed)
1641+
Positioned(
1642+
top: 80,
1643+
right: 16,
1644+
child: SafeArea(
1645+
child: IntensityLegend(
1646+
mode: activeEew.isNotEmpty
1647+
? IntensityLegendMode.eew
1648+
: IntensityLegendMode.rts,
1649+
),
1650+
),
1651+
),
16361652
Positioned(
16371653
top: 26,
16381654
left: 95,
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import 'package:dpip/utils/instrumental_intensity_color.dart';
2+
import 'package:dpip/utils/intensity_color.dart';
3+
import 'package:flutter/material.dart';
4+
5+
enum IntensityLegendMode {
6+
/// EEW mode: shows intensity 1-9
7+
eew,
8+
9+
/// RTS mode: shows instrumental intensity -3 to 7
10+
rts,
11+
}
12+
13+
class IntensityLegend extends StatelessWidget {
14+
final IntensityLegendMode mode;
15+
16+
const IntensityLegend({super.key, this.mode = IntensityLegendMode.eew});
17+
18+
List<Color> get _colors => mode == IntensityLegendMode.eew
19+
? List.generate(9, (i) => IntensityColor.intensity(i + 1))
20+
: List.generate(11, (i) => InstrumentalIntensityColor.intensity(i - 3));
21+
22+
List<String> get _labels => mode == IntensityLegendMode.eew
23+
? const ['1', '2', '3', '4', '5⁻', '5⁺', '6⁻', '6⁺', '7']
24+
: const ['-3', '-2', '-1', '0', '1', '2', '3', '4', '5', '6', '7'];
25+
26+
@override
27+
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+
),
42+
);
43+
}
44+
45+
Widget _buildColorBar(double width) {
46+
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+
);
60+
} 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+
}
72+
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,
85+
),
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(),
102+
),
103+
);
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)