This commit is contained in:
wyf
2025-08-02 14:10:07 +08:00
parent 9dc0f55ab6
commit ff00ed60c0
40 changed files with 150 additions and 126 deletions

View File

@@ -4,6 +4,7 @@ import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/home_page/SleepDataModuleWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
import 'package:vbvs_app/language/AppLanguage.dart';
class SleepCard extends StatefulWidget {
final dynamic sleepReport;
@@ -30,9 +31,10 @@ class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
_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 _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
}
}
});
_animationController!.forward();
}
@@ -85,7 +87,8 @@ class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
widget.sleepReport.isEmpty) {
return Container();
}
String lcode = mhLanguageController.selectLanguage.value!.language_code!;
int num = AppLanguage().isChinese() ? 3 : 2;
List data = widget.sleepReport['bs'] ?? [];
return Container(
@@ -104,11 +107,10 @@ class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
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,
width: (MediaQuery.of(context).size.width - 160.rpx) / num,
child: AnimatedBuilder(
animation: _animationController ?? AlwaysStoppedAnimation(0),
builder: (context, child) {
@@ -118,13 +120,17 @@ class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
? BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc2
.withOpacity(_animationController?.value ?? 0),
.withOpacity(
_animationController?.value ?? 0),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8),
)
: null,
child: SleepDataModuleWidget(data: item,sleepReportData: widget.sleepReport,),
child: SleepDataModuleWidget(
data: item,
sleepReportData: widget.sleepReport,
),
);
},
),
@@ -138,4 +144,4 @@ class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
return Container();
}
}
}
}