281 lines
11 KiB
Dart
281 lines
11 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:lamiter/Class/API/api.dart';
|
|
import 'package:lamiter/Class/Diagnosis/diagnosis.dart';
|
|
import 'package:lamiter/Component/AppBar/title_app_bar.dart';
|
|
import 'package:lamiter/Component/tap_container.dart';
|
|
import 'package:lamiter/Extension/build_context.dart';
|
|
import 'package:lamiter/Extension/iterable.dart';
|
|
import 'package:lamiter/Page/Service/MedicalFacility/medical_facility_page.dart';
|
|
import 'package:lamiter/Page/Service/MeridianNetwork/meridian_network_page.dart';
|
|
import 'package:lamiter/Page/Service/course_page.dart';
|
|
import 'package:lamiter/Page/Service/product_page.dart';
|
|
import 'package:lamiter/Page/Service/SeasonalRecipe/seasonal_recipe_page.dart';
|
|
import 'package:lamiter/Page/Service/treatment_page.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
import 'package:lamiter/Page/create_edit_client_page.dart';
|
|
import 'package:lamiter/Provider/Diagnosis/diagnosis_provider.dart';
|
|
import 'package:lamiter/Provider/User/Client/client_provider.dart';
|
|
import 'package:lamiter/Provider/User/manager_provider.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class ServicePage extends StatelessWidget {
|
|
final Diagnosis diagnosis;
|
|
|
|
const ServicePage({
|
|
super.key,
|
|
required this.diagnosis,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
|
child: Stack(
|
|
alignment: Alignment.bottomCenter,
|
|
children: [
|
|
Scaffold(
|
|
appBar: TitleAppBar(
|
|
title: AppLocalizations.of(context).service,
|
|
actions: [
|
|
Padding(
|
|
padding: EdgeInsets.only(right: 16.sp),
|
|
child: GestureDetector(
|
|
onTap: () async {
|
|
final client = context.read<ClientProvider>().self;
|
|
var diagnosis =
|
|
context.read<DiagnosisProvider>().diagnosis;
|
|
if (client == null && diagnosis != null) {
|
|
var flag = false;
|
|
await showCupertinoDialog<void>(
|
|
context: context,
|
|
builder: (BuildContext context) =>
|
|
CupertinoAlertDialog(
|
|
content: Text('總評報告尚未保存。是否要創建新的客戶保存總評報告?'),
|
|
actions: <CupertinoDialogAction>[
|
|
CupertinoDialogAction(
|
|
/// This parameter indicates this action is the default,
|
|
/// and turns the action's text to bold text.
|
|
isDefaultAction: true,
|
|
onPressed: () async {
|
|
flag = true;
|
|
Navigator.pop(context);
|
|
},
|
|
child: const Text('是'),
|
|
),
|
|
CupertinoDialogAction(
|
|
/// This parameter indicates the action would perform
|
|
/// a destructive action such as deletion, and turns
|
|
/// the action's text color to red.
|
|
isDestructiveAction: true,
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: const Text('否'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (flag) {
|
|
final clientId = await Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
const CreateEditClientPage()),
|
|
);
|
|
if (clientId != null) {
|
|
diagnosis.clientId = clientId;
|
|
diagnosis.endTime = DateTime.now();
|
|
await API().create_diagnosis(diagnosis);
|
|
}
|
|
}
|
|
}
|
|
Navigator.pop(context);
|
|
Navigator.pop(context);
|
|
context.read<ManagerProvider>().refresh();
|
|
},
|
|
child: const Icon(Icons.close, size: 30),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
body: SafeArea(
|
|
bottom: false,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
ListView(
|
|
children: [
|
|
_ServiceListLayout(
|
|
title: AppLocalizations.of(context).fundamental_care,
|
|
items: [
|
|
_ServiceUnitLayout(
|
|
title:
|
|
AppLocalizations.of(context).meridian_network,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
MeridianNetworkPage(diagnosis: diagnosis),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
_ServiceUnitLayout(
|
|
title: AppLocalizations.of(context).seasonal_recipe,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
SeasonalRecipePage(diagnosis: diagnosis),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
// note:
|
|
// '基本調理提供「療程」、「經絡穴位」與「節氣食譜」,量身推薦專屬選擇,幫助進一步調理身體,維持健康與活力。',
|
|
),
|
|
_ServiceListLayout(
|
|
title: AppLocalizations.of(context).service_item,
|
|
items: [
|
|
_ServiceUnitLayout(
|
|
title: AppLocalizations.of(context).product,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
ProductPage(diagnosis: diagnosis),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
_ServiceUnitLayout(
|
|
title: AppLocalizations.of(context).treatment,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
TreatmentPage(diagnosis: diagnosis),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
_ServiceUnitLayout(
|
|
title: AppLocalizations.of(context).course,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
CoursePage(diagnosis: diagnosis),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
// note: '配對產品提供「商品」,透過更進階的康養方案,幫助改善亞健康狀態,提升整體健康水平。',
|
|
),
|
|
_ServiceListLayout(
|
|
title: AppLocalizations.of(context).healthcare_resource,
|
|
items: [
|
|
_ServiceUnitLayout(
|
|
title: AppLocalizations.of(context).hospital_link,
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) =>
|
|
const MedicalFacilityPage(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
// note: '醫療資源提供「院所鏈接」,協助快速聯繫專業的醫療機構,獲得專業的醫療建議與支持。',
|
|
),
|
|
]
|
|
.lastPadding(
|
|
EdgeInsets.only(bottom: context.height(0.1)))
|
|
.toList(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ServiceListLayout extends StatelessWidget {
|
|
final String title;
|
|
final List<Widget> items;
|
|
final String? note;
|
|
|
|
const _ServiceListLayout({
|
|
required this.title,
|
|
required this.items,
|
|
this.note,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CupertinoFormSection(
|
|
backgroundColor: context.surface,
|
|
header: Text(title),
|
|
footer: note != null
|
|
? Padding(
|
|
padding: EdgeInsets.only(top: 12.sp),
|
|
child: Text(note!, textAlign: TextAlign.justify),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
children: items,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ServiceUnitLayout extends StatelessWidget {
|
|
final String title;
|
|
final Function()? onTap;
|
|
|
|
const _ServiceUnitLayout({
|
|
required this.title,
|
|
this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Column(
|
|
children: [
|
|
TapContainer(
|
|
onTap: onTap,
|
|
child: CupertinoFormRow(
|
|
padding: EdgeInsets.all(16.sp),
|
|
prefix: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontFamily: 'CupertinoSystemText',
|
|
inherit: false,
|
|
fontSize: 17.0,
|
|
fontWeight: FontWeight.w400,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
color: context.inversePrimary,
|
|
),
|
|
),
|
|
child: Icon(CupertinoIcons.forward, color: context.primary),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|