基本完成
This commit is contained in:
41
lib/page/record/detail/record_detail_page.dart
Normal file
41
lib/page/record/detail/record_detail_page.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:food_health/api/dto/food_scan_dto.dart';
|
||||
|
||||
import 'widget/detailed_analysis.dart';
|
||||
import 'widget/health_recommend.dart';
|
||||
import 'widget/result_chip.dart';
|
||||
|
||||
class RecordDetailPage extends StatefulWidget {
|
||||
final FoodScanDto detail;
|
||||
|
||||
const RecordDetailPage({super.key, required this.detail});
|
||||
|
||||
@override
|
||||
State<RecordDetailPage> createState() => _RecordDetailPageState();
|
||||
}
|
||||
|
||||
class _RecordDetailPageState extends State<RecordDetailPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.dark, // 状态栏图标深色
|
||||
statusBarBrightness: Brightness.light, // iOS
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15, bottom: 15),
|
||||
children: [
|
||||
ResultChip(detail: widget.detail),
|
||||
DetailedAnalysis(detail: widget.detail),
|
||||
HealthRecommend(
|
||||
detail: widget.detail,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
76
lib/page/record/detail/widget/detailed_analysis.dart
Normal file
76
lib/page/record/detail/widget/detailed_analysis.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_health/api/dto/food_scan_dto.dart';
|
||||
import 'package:markdown_widget/widget/markdown.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class DetailedAnalysis extends StatelessWidget {
|
||||
final FoodScanDto detail;
|
||||
|
||||
const DetailedAnalysis({super.key, required this.detail});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(
|
||||
RemixIcons.eye_line,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
Text(
|
||||
"Detailed Analysis",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
MarkdownWidget(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
data: detail.explanation ?? "",
|
||||
),
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(RemixIcons.menu_2_line),
|
||||
Text(
|
||||
"Detected Ingredients",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: detail.ingredientsList!.map((item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(item, style: Theme.of(context).textTheme.labelMedium),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
53
lib/page/record/detail/widget/health_recommend.dart
Normal file
53
lib/page/record/detail/widget/health_recommend.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_health/config/theme/custom_colors.dart';
|
||||
import 'package:markdown_widget/widget/markdown.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../../../../api/dto/food_scan_dto.dart';
|
||||
|
||||
class HealthRecommend extends StatelessWidget {
|
||||
final FoodScanDto detail;
|
||||
|
||||
const HealthRecommend({super.key, required this.detail});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.shadow,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(
|
||||
RemixIcons.heart_line,
|
||||
color: Theme.of(context).colorScheme.danger,
|
||||
),
|
||||
Text(
|
||||
"Health Recommendations",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
MarkdownWidget(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
data: detail.suggestions ?? "",
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
96
lib/page/record/detail/widget/result_chip.dart
Normal file
96
lib/page/record/detail/widget/result_chip.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_health/api/dto/food_scan_dto.dart';
|
||||
import 'package:food_health/config/theme/custom_colors.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class ResultChip extends StatelessWidget {
|
||||
final FoodScanDto detail;
|
||||
|
||||
const ResultChip({super.key, required this.detail});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color currentColor = Colors.transparent; //设置主体颜色
|
||||
IconData iconData = Icons.check; //图标
|
||||
String title = "";
|
||||
String desc = "";
|
||||
|
||||
if (detail.foodType == 1) {
|
||||
currentColor = Theme.of(context).colorScheme.success;
|
||||
iconData = RemixIcons.shield_check_line;
|
||||
title = "Safe to Eat";
|
||||
desc = "This food appears safe for your health profile";
|
||||
} else if (detail.foodType == 2) {
|
||||
currentColor = Theme.of(context).colorScheme.warning;
|
||||
iconData = RemixIcons.error_warning_fill;
|
||||
title = "Proceed with Caution";
|
||||
desc = "This food may have some concerns for your health profile";
|
||||
} else if (detail.foodType == 3) {
|
||||
currentColor = Theme.of(context).colorScheme.danger;
|
||||
iconData = RemixIcons.close_circle_line;
|
||||
title = "Avoid This Food";
|
||||
desc = "This food is not recommended for your health profile";
|
||||
}
|
||||
return Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: currentColor.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: currentColor, width: 1),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 20,
|
||||
children: [
|
||||
Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: currentColor,
|
||||
),
|
||||
child: Icon(
|
||||
iconData,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
desc,
|
||||
style: TextStyle(color: currentColor, fontSize: 14),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
width: 150,
|
||||
height: 150,
|
||||
child: Image.network(
|
||||
detail.imageUrl!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer),
|
||||
child: Icon(RemixIcons.error_warning_fill),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Text(
|
||||
detail.foodName ?? "",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Text(
|
||||
detail.foodDesc ?? "",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user