259 lines
9.4 KiB
Dart
259 lines
9.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:lamiter/Class/Diagnosis/diagnosis.dart';
|
|
import 'package:lamiter/Class/Screenshot/screenshot.dart';
|
|
import 'package:lamiter/Class/Screenshot/screenshot_widget.dart';
|
|
import 'package:lamiter/Component/AppBar/title_app_bar.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Result/muscles_result_page.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Screenshot/posture_issue_result_screenshot_page.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Screenshot/zong_fu_meridians_result_screenshot_page.dart';
|
|
import 'package:lamiter/Component/Diagnosis/diagnosis_result_display_topbar.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Report/basic_health_report_page.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Report/constitution_report_page.dart';
|
|
import 'package:lamiter/Component/Diagnosis/Report/posture_issue_report_page.dart';
|
|
import 'package:lamiter/Component/bottom_popup_message.dart';
|
|
import 'package:lamiter/Extension/build_context.dart';
|
|
import 'package:lamiter/Extension/iterable.dart';
|
|
import 'package:lamiter/Page/Service/service_page.dart';
|
|
import 'package:lamiter/Provider/Language/language_provider.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
enum DiagnosisReportType { basicHealth, constitution, postureIssue }
|
|
|
|
class DiagnosisReportPage extends StatefulWidget {
|
|
final Diagnosis diagnosis;
|
|
// final bool canMoveOnToServicePage;
|
|
|
|
const DiagnosisReportPage({
|
|
super.key,
|
|
required this.diagnosis,
|
|
});
|
|
|
|
@override
|
|
State<DiagnosisReportPage> createState() => _DiagnosisReportPageState();
|
|
}
|
|
|
|
class _DiagnosisReportPageState extends State<DiagnosisReportPage> {
|
|
final GlobalKey<BottomPopupMessageState> messageKey =
|
|
GlobalKey<BottomPopupMessageState>();
|
|
|
|
int _index = 0;
|
|
|
|
void onValueChanged(DiagnosisReportType? value) {
|
|
if (value == null) return;
|
|
_index = value.index;
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final languageProvider = Provider.of<LanguageProvider>(context);
|
|
|
|
final Map<DiagnosisReportType, List<Screenshot>> screenshot = {
|
|
DiagnosisReportType.basicHealth: [
|
|
Screenshot(
|
|
children: [
|
|
ScreenshotWidget(
|
|
width: 360,
|
|
child: BasicHealthReportPage(
|
|
healthIndexResult: widget.diagnosis.healthIndexResult,
|
|
physicalIndexResult: widget.diagnosis.physicalIndexResult,
|
|
urbanDiseaseResult: widget.diagnosis.urbanDiseaseResult,
|
|
stressIndexResult: widget.diagnosis.stressIndexResult,
|
|
sleepWellIndexResult: widget.diagnosis.sleepWellIndexResult,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
DiagnosisReportType.constitution: [
|
|
Screenshot(
|
|
children: [
|
|
ScreenshotWidget(
|
|
width: 360,
|
|
child: ConstitutionReportPage(
|
|
constitutionResult: widget.diagnosis.constitutionResult,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
DiagnosisReportType.postureIssue: [
|
|
Screenshot(
|
|
children: [
|
|
ScreenshotWidget(
|
|
width: 560,
|
|
child: PostureIssueResultScreenshotPage(
|
|
postureIssueResult: widget.diagnosis.postureIssueResult,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Screenshot(
|
|
children: [
|
|
ScreenshotWidget(
|
|
width: 512,
|
|
child: MusclesResultPage(
|
|
postureIssueResult: widget.diagnosis.postureIssueResult,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Screenshot(
|
|
children: [
|
|
ScreenshotWidget(
|
|
width: 512,
|
|
child: ZongFuMeridiansResultScreenshotPage(
|
|
postureIssueResult: widget.diagnosis.postureIssueResult,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
};
|
|
|
|
void screenshot_success() {
|
|
messageKey.currentState?.showMessage(
|
|
AppLocalizations.of(context).screenshot_success,
|
|
context.inversePrimary,
|
|
);
|
|
}
|
|
|
|
void copy_success() {}
|
|
|
|
return GestureDetector(
|
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
|
child: Scaffold(
|
|
appBar: TitleAppBar(
|
|
title: AppLocalizations.of(context).diagnosis_report,
|
|
// leading:
|
|
actions: [
|
|
Padding(
|
|
padding: EdgeInsets.only(right: 16.sp),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
showCupertinoModalPopup(
|
|
context: context,
|
|
builder: (BuildContext context) => CupertinoActionSheet(
|
|
actions: [
|
|
CupertinoActionSheetAction(
|
|
child: Text(AppLocalizations.of(context)
|
|
.copy_diagnosis_report_link),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
messageKey.currentState?.showMessage(
|
|
AppLocalizations.of(context).copy_success,
|
|
context.inversePrimary,
|
|
);
|
|
},
|
|
),
|
|
CupertinoActionSheetAction(
|
|
child: Text(AppLocalizations.of(context)
|
|
.screenshot_diagnosis_report),
|
|
onPressed: () async {
|
|
Navigator.pop(context);
|
|
DiagnosisReportType type =
|
|
DiagnosisReportType.values[_index];
|
|
if (widget.diagnosis.hasReport(type)) {
|
|
for (var ss in screenshot[type]!) {
|
|
await ss.screenshot(languageProvider.locale);
|
|
}
|
|
}
|
|
screenshot_success();
|
|
},
|
|
),
|
|
],
|
|
cancelButton: CupertinoActionSheetAction(
|
|
isDefaultAction: true,
|
|
child: Text(AppLocalizations.of(context).cancel),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
child: const Icon(Icons.share),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.only(right: 16.sp),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
ServicePage(diagnosis: widget.diagnosis),
|
|
),
|
|
);
|
|
},
|
|
child: const Icon(Icons.arrow_forward_ios),
|
|
),
|
|
)
|
|
],
|
|
shadowColor: Colors.transparent,
|
|
),
|
|
body: Stack(
|
|
alignment: Alignment.bottomCenter,
|
|
children: [
|
|
// _BackgroundImage(),
|
|
SafeArea(
|
|
bottom: false,
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: Column(
|
|
children: [
|
|
DiagnosisResultDisplayTopbar(
|
|
onValueChanged: onValueChanged,
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
<Widget>[
|
|
BasicHealthReportPage(
|
|
healthIndexResult:
|
|
widget.diagnosis.healthIndexResult,
|
|
physicalIndexResult:
|
|
widget.diagnosis.physicalIndexResult,
|
|
urbanDiseaseResult:
|
|
widget.diagnosis.urbanDiseaseResult,
|
|
stressIndexResult:
|
|
widget.diagnosis.stressIndexResult,
|
|
sleepWellIndexResult:
|
|
widget.diagnosis.sleepWellIndexResult,
|
|
),
|
|
ConstitutionReportPage(
|
|
constitutionResult:
|
|
widget.diagnosis.constitutionResult,
|
|
),
|
|
PostureIssueReportPage(
|
|
postureIssueResult:
|
|
widget.diagnosis.postureIssueResult,
|
|
),
|
|
][_index],
|
|
]
|
|
.lastPadding(EdgeInsets.only(bottom: 32.sp))
|
|
.toList(),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
BottomPopupMessage(
|
|
key: messageKey,
|
|
height: 32.sp,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|