更新样式

This commit is contained in:
wyf
2025-12-01 15:41:34 +08:00
parent 991bf97fd1
commit 1cc26aa46d
18 changed files with 502 additions and 677 deletions

View File

@@ -15,7 +15,8 @@ class HeartRateCard extends StatefulWidget {
State<HeartRateCard> createState() => _HeartRateCardState();
}
class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateMixin {
class _HeartRateCardState extends State<HeartRateCard>
with TickerProviderStateMixin {
final GlobalKey _highlightKey = GlobalKey();
AnimationController? _animationController;
bool _shouldAnimate = false;
@@ -30,9 +31,10 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
_shouldAnimate = true;
_initAnimation();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.highlightItem != null && _highlightKey.currentContext != null) {
if (widget.highlightItem != null &&
_highlightKey.currentContext != null) {
Scrollable.ensureVisible(
_highlightKey.currentContext!,
duration: Duration(milliseconds: 500),
@@ -67,7 +69,7 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
}
}
});
_animationController!.forward();
}
@@ -86,8 +88,16 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
return Container();
}
// List data = widget.sleepReport['hrs'] ?? [];
// data = data.where((item) {
// return item['show'] != false; // 只保留 show 不为 false 的元素
// });
List data = widget.sleepReport['hrs'] ?? [];
data = data.where((item) {
return item['show'] != false; // 只保留 show 不为 false 的元素
}).toList(); // 添加 .toList()
return Container(
width: double.infinity,
decoration: BoxDecoration(
@@ -104,9 +114,9 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
final bool isHighlighted = _shouldAnimate &&
item['id'] == _highlightedId;
final bool isHighlighted =
_shouldAnimate && item['id'] == _highlightedId;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: AnimatedBuilder(
@@ -118,7 +128,8 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
? BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc2
.withOpacity(_animationController?.value ?? 0),
.withOpacity(
_animationController?.value ?? 0),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8),
@@ -138,4 +149,4 @@ class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateM
return Container();
}
}
}
}