更新
This commit is contained in:
119
lib/pages/sleep_report/chart/AdviceComponnetWidget.dart
Normal file
119
lib/pages/sleep_report/chart/AdviceComponnetWidget.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
class AdviceComponnetWidget extends StatefulWidget {
|
||||
final String title; // 建议标题
|
||||
final String description; // 建议说明
|
||||
|
||||
const AdviceComponnetWidget({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AdviceComponnetWidget> createState() => _AdviceComponnetWidgetState();
|
||||
}
|
||||
|
||||
class _AdviceComponnetWidgetState extends State<AdviceComponnetWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
// 显示标题
|
||||
Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: stringToColor("#313541"),
|
||||
borderRadius: BorderRadius.circular(20.rpx),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
28.rpx, 30.rpx, 28.rpx, 30.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Text(
|
||||
widget.title, // 使用传入的标题
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 显示描述
|
||||
Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
28.rpx, 30.rpx, 28.rpx, 30.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: 26.rpx, // 设置文字大小
|
||||
height: 1.3, // 设置行高,控制文字上下间距
|
||||
),
|
||||
children: [
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle, // 图标和文字垂直居中
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 4.rpx, // 调整底部间距
|
||||
right: 10.rpx, // 适当调整图标右边距
|
||||
top: 4.rpx, // 增加顶部间距
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/ai.svg', // 替换为你的 SVG 文件路径
|
||||
width: 37.rpx, // 设置适中的 SVG 图标大小
|
||||
height: 31.rpx, // 使图标和文字大小一致
|
||||
color:
|
||||
themeController.currentColor.sc2, // 设置 SVG 颜色
|
||||
),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: widget.description, // 使用传入的描述
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize, // 文字大小
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user