1
This commit is contained in:
63
lib/page/education/detail/education_detail_page.dart
Normal file
63
lib/page/education/detail/education_detail_page.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:markdown_widget/markdown_widget.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
|
||||
import '../../../api/dto/article_detail_dto.dart';
|
||||
import '../../../api/endpoints/skin_api.dart';
|
||||
|
||||
class EducationDetailPage extends StatefulWidget {
|
||||
final String id;
|
||||
|
||||
const EducationDetailPage({super.key, required this.id});
|
||||
|
||||
@override
|
||||
State<EducationDetailPage> createState() => _EducationDetailPageState();
|
||||
}
|
||||
|
||||
class _EducationDetailPageState extends State<EducationDetailPage> {
|
||||
ArticleDetailDto? _detailDto;
|
||||
bool _loading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_init();
|
||||
}
|
||||
|
||||
void _init() async {
|
||||
var res = await articleDetailApi(widget.id);
|
||||
setState(() {
|
||||
_detailDto = res;
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_detailDto?.title ?? ""),
|
||||
),
|
||||
body: Skeletonizer(
|
||||
enabled: _loading,
|
||||
child: _loading
|
||||
? ListView.builder(
|
||||
padding: EdgeInsets.all(15),
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 6),
|
||||
height: 14,
|
||||
width: double.infinity,
|
||||
color: Colors.grey[300],
|
||||
);
|
||||
},
|
||||
itemCount: 10,
|
||||
)
|
||||
: MarkdownWidget(
|
||||
padding: EdgeInsets.all(15),
|
||||
data: _detailDto?.content ?? "",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
103
lib/page/education/list/education_list_page.dart
Normal file
103
lib/page/education/list/education_list_page.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:derma_flutter/api/dto/article_dto.dart';
|
||||
import 'package:derma_flutter/api/endpoints/skin_api.dart';
|
||||
import 'package:derma_flutter/widgets/common/app_backend.dart';
|
||||
import 'package:derma_flutter/widgets/ui_kit/empty/index.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../router/config/route_paths.dart';
|
||||
|
||||
class EducationListPage extends StatefulWidget {
|
||||
const EducationListPage({super.key});
|
||||
|
||||
@override
|
||||
State<EducationListPage> createState() => _EducationListPageState();
|
||||
}
|
||||
|
||||
class _EducationListPageState extends State<EducationListPage> {
|
||||
var _loading = false;
|
||||
final List<ArticleDto> _list = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_init();
|
||||
}
|
||||
|
||||
void _init() async {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
});
|
||||
var list = await articleListApi();
|
||||
setState(() {
|
||||
_list.clear();
|
||||
_list.addAll(list);
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _handToDetail(ArticleDto item) {
|
||||
context.push(RoutePaths.articleDetail(item.id));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Skin Health Education"),
|
||||
),
|
||||
body: AppBackend(
|
||||
child: SafeArea(
|
||||
child: Visibility(
|
||||
visible: !_loading && _list.isNotEmpty,
|
||||
replacement: Empty(),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
var item = _list[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_handToDetail(item);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffE9E9E9),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 9,
|
||||
offset: Offset(1, 2), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.title ?? ''),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
item.subtitle ?? "",
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Container(
|
||||
height: 15,
|
||||
);
|
||||
},
|
||||
itemCount: _list.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
76
lib/page/home/home_page.dart
Normal file
76
lib/page/home/home_page.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:derma_flutter/router/config/route_paths.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../../api/endpoints/skin_api.dart';
|
||||
import '../../widgets/common/app_backend.dart';
|
||||
import '../../widgets/common/app_header.dart';
|
||||
import 'widget/tip_widget.dart';
|
||||
import 'widget/upload_widget.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
|
||||
///打开相机拍照
|
||||
void _handTakePhoto() async {
|
||||
var photo = await _picker.pickImage(source: ImageSource.camera);
|
||||
if (photo != null) {
|
||||
_startDetect(photo.path);
|
||||
}
|
||||
}
|
||||
|
||||
///选择图片
|
||||
void _handPickImage() async {
|
||||
var result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.image,
|
||||
allowMultiple: false,
|
||||
);
|
||||
if (result != null) {
|
||||
_startDetect(result.files[0].path!);
|
||||
}
|
||||
}
|
||||
|
||||
///开始检测
|
||||
void _startDetect(String path) async {
|
||||
EasyLoading.show(
|
||||
status: 'Skin analysis in progress, please wait...',
|
||||
maskType: EasyLoadingMaskType.clear,
|
||||
);
|
||||
var res = await skinDetectApi(path);
|
||||
EasyLoading.dismiss();
|
||||
context.push(RoutePaths.detail, extra: res);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: AppBackend(
|
||||
child: Column(
|
||||
children: [
|
||||
AppHeader(),
|
||||
UploadBox(
|
||||
onPhoto: _handTakePhoto,
|
||||
onSelect: _handPickImage,
|
||||
),
|
||||
TipBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
57
lib/page/home/widget/tip_widget.dart
Normal file
57
lib/page/home/widget/tip_widget.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TipBox extends StatelessWidget {
|
||||
TipBox({super.key});
|
||||
|
||||
final List<String> tips = [
|
||||
"Ensure good lighting",
|
||||
"Keep the camera steady",
|
||||
"Fill the frame with the skin area",
|
||||
"Avoid shadows and glare",
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).cardColor,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffE9E9E9),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 9,
|
||||
offset: Offset(1, 2), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
style: TextStyle(color: Color(0xff1A8C8C)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Tips:",
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
color: Color(0xff1A8C8C),
|
||||
),
|
||||
),
|
||||
ListView.builder(
|
||||
itemExtent: 25,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.all(10),
|
||||
itemBuilder: (_, index) {
|
||||
return Text("-${tips[index]}.");
|
||||
},
|
||||
itemCount: tips.length,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
117
lib/page/home/widget/upload_widget.dart
Normal file
117
lib/page/home/widget/upload_widget.dart
Normal file
@@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class UploadBox extends StatelessWidget {
|
||||
final Function() onSelect;
|
||||
final Function() onPhoto;
|
||||
|
||||
const UploadBox({
|
||||
super.key,
|
||||
required this.onSelect,
|
||||
required this.onPhoto,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 30),
|
||||
width: double.infinity,
|
||||
height: 350,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffE9E9E9),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 9,
|
||||
offset: Offset(1, 2), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
child: Image.asset(
|
||||
"assets/image/bg_hushi.png",
|
||||
width: 0.7.sw,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Text(
|
||||
"Take a clear photo of the skin area you’d like to analyze.Our AI will provide instant health insights.",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
spacing: 20,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Analyze Your Skin",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
_btn(
|
||||
colors: [Color(0xff107870), Color(0xff1EDECF)],
|
||||
title: "Take photo",
|
||||
onTap: (){
|
||||
onPhoto();
|
||||
},
|
||||
),
|
||||
_btn(
|
||||
colors: [Color(0xffFFFFFF), Color(0xffC6C6C6)],
|
||||
title: "Upload Photo",
|
||||
textColor: Color(0xff000000),
|
||||
onTap: (){
|
||||
onSelect();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _btn({
|
||||
required List<Color> colors,
|
||||
Color textColor = Colors.white,
|
||||
required String title,
|
||||
required Function() onTap,
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 120,
|
||||
height: 38,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
gradient: LinearGradient(
|
||||
colors: colors,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
63
lib/page/record/detail/record_detail_page.dart
Normal file
63
lib/page/record/detail/record_detail_page.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
|
||||
import 'package:derma_flutter/data/models/skin_check_status.dart';
|
||||
import 'package:derma_flutter/page/record/detail/widget/error_box.dart';
|
||||
import 'package:derma_flutter/page/record/detail/widget/warning_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
import 'widget/success_box.dart';
|
||||
|
||||
class RecordDetailPage extends StatefulWidget {
|
||||
final SkinCheckDto data;
|
||||
|
||||
// final String id;
|
||||
|
||||
const RecordDetailPage({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<RecordDetailPage> createState() => _RecordDetailPageState();
|
||||
}
|
||||
|
||||
class _RecordDetailPageState extends State<RecordDetailPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
systemOverlayStyle: const SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(left: 15, right: 15, top: 0.05.sh, bottom: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
switch (widget.data.skinStatus) {
|
||||
case SkinCheckStatus.normal:
|
||||
return SuccessBox(data: widget.data);
|
||||
case SkinCheckStatus.warning:
|
||||
return WarningBox(
|
||||
data: widget.data,
|
||||
);
|
||||
case SkinCheckStatus.danger:
|
||||
return ErrorBox(
|
||||
data: widget.data,
|
||||
);
|
||||
case SkinCheckStatus.unknown:
|
||||
return SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
88
lib/page/record/detail/widget/common_box.dart
Normal file
88
lib/page/record/detail/widget/common_box.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StatusBox extends StatelessWidget {
|
||||
final Color color;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String desc;
|
||||
|
||||
const StatusBox({
|
||||
super.key,
|
||||
required this.color,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.desc,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
desc,
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CardBox extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const CardBox({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(15),
|
||||
margin: const EdgeInsets.only(top: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: Text(
|
||||
"Detected Signs:",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
child
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
45
lib/page/record/detail/widget/error_box.dart
Normal file
45
lib/page/record/detail/widget/error_box.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
|
||||
import 'package:derma_flutter/config/theme/custom_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import 'common_box.dart';
|
||||
|
||||
class ErrorBox extends StatefulWidget {
|
||||
final SkinCheckDto data;
|
||||
const ErrorBox({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<ErrorBox> createState() => _ErrorBoxState();
|
||||
}
|
||||
|
||||
class _ErrorBoxState extends State<ErrorBox> {
|
||||
void _handBack() {
|
||||
context.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
StatusBox(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
icon: RemixIcons.alert_fill,
|
||||
title: "Need to see a doctor",
|
||||
desc: "Your skin shows signs of concern that require attention.Please visit the hospital for examination immediately.",
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
margin: const EdgeInsets.only(top: 50),
|
||||
child: ElevatedButton(
|
||||
onPressed: _handBack,
|
||||
child: Text("Know"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
67
lib/page/record/detail/widget/success_box.dart
Normal file
67
lib/page/record/detail/widget/success_box.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
|
||||
import 'package:derma_flutter/config/theme/custom_colors.dart';
|
||||
import 'package:derma_flutter/page/record/detail/widget/common_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class SuccessBox extends StatefulWidget {
|
||||
final SkinCheckDto data;
|
||||
|
||||
const SuccessBox({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<SuccessBox> createState() => _SuccessBoxState();
|
||||
}
|
||||
|
||||
class _SuccessBoxState extends State<SuccessBox> {
|
||||
void _handBack() {
|
||||
context.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
StatusBox(
|
||||
color: Theme.of(context).colorScheme.success,
|
||||
icon: RemixIcons.check_fill,
|
||||
title: "Healthy Skin",
|
||||
desc: "Your skin appears to be in good condition.",
|
||||
),
|
||||
CardBox(
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: widget.data.tags.map((item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.success.withValues(alpha: 0.3),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
child: Text(
|
||||
item,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.success,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
margin: const EdgeInsets.only(top: 50),
|
||||
child: ElevatedButton(
|
||||
onPressed: _handBack,
|
||||
child: Text("Return"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
93
lib/page/record/detail/widget/warning_box.dart
Normal file
93
lib/page/record/detail/widget/warning_box.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
|
||||
import 'package:derma_flutter/api/endpoints/skin_api.dart';
|
||||
import 'package:derma_flutter/config/theme/custom_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import 'common_box.dart';
|
||||
|
||||
class WarningBox extends StatefulWidget {
|
||||
final SkinCheckDto data;
|
||||
|
||||
const WarningBox({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<WarningBox> createState() => _WarningBoxState();
|
||||
}
|
||||
|
||||
class _WarningBoxState extends State<WarningBox> {
|
||||
final _emailController = TextEditingController();
|
||||
|
||||
///提交
|
||||
void _handSubmit() async {
|
||||
if (_emailController.text.isEmpty) {
|
||||
EasyLoading.showToast("Contact email is required");
|
||||
return;
|
||||
}
|
||||
EasyLoading.show(status: 'Sending request...');
|
||||
await skinContactApi(widget.data.id!, _emailController.text);
|
||||
EasyLoading.dismiss();
|
||||
context.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
StatusBox(
|
||||
color: Theme.of(context).colorScheme.warning,
|
||||
icon: RemixIcons.error_warning_fill,
|
||||
title: "Troubled Skin",
|
||||
desc: widget.data.concise ?? "",
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 20),
|
||||
child: Text(
|
||||
"Find out more:",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"We will contact you shortly.Please check your e-mail promptly for further information.",
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
"Please confirm/enter your e-mail address:",
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 15),
|
||||
child: TextField(
|
||||
controller: _emailController,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Email",
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 60),
|
||||
height: 45,
|
||||
child: ElevatedButton(
|
||||
onPressed: _handSubmit,
|
||||
child: Text("Continue"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
151
lib/page/record/list/record_list_page.dart
Normal file
151
lib/page/record/list/record_list_page.dart
Normal file
@@ -0,0 +1,151 @@
|
||||
import 'package:derma_flutter/api/dto/record_list_dto.dart';
|
||||
import 'package:derma_flutter/api/endpoints/skin_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../widgets/ui_kit/empty/index.dart';
|
||||
import 'widget/item_widget.dart';
|
||||
|
||||
class RecordListPage extends StatefulWidget {
|
||||
const RecordListPage({super.key});
|
||||
|
||||
@override
|
||||
State<RecordListPage> createState() => _RecordListPageState();
|
||||
}
|
||||
|
||||
class _RecordListPageState extends State<RecordListPage> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
//tab
|
||||
late TabController _tabController;
|
||||
List<TabItem> tabList = [
|
||||
TabItem(name: "All", value: 0),
|
||||
TabItem(name: "Healthy", value: 1),
|
||||
TabItem(name: "Unhealthy", value: 2),
|
||||
];
|
||||
|
||||
//列表
|
||||
List<RecordItemDto> _recordList = [];
|
||||
var _isEnd = false;
|
||||
var _isLoading = false;
|
||||
|
||||
///滚动监听器
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: tabList.length, vsync: this);
|
||||
_tabController.addListener(_onTabChange);
|
||||
_scrollController.addListener(_onScroll);
|
||||
_onRefresh();
|
||||
}
|
||||
|
||||
///监听列表滚动
|
||||
void _onScroll() {
|
||||
final maxExtent = _scrollController.position.maxScrollExtent;
|
||||
final current = _scrollController.position.pixels;
|
||||
const threshold = 15;
|
||||
if (current >= maxExtent - threshold) {
|
||||
_fetchList();
|
||||
}
|
||||
}
|
||||
|
||||
///tab改变
|
||||
void _onTabChange() {
|
||||
if (!_tabController.indexIsChanging) {
|
||||
_onRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
///刷新
|
||||
Future<void> _onRefresh() async {
|
||||
_isEnd = false;
|
||||
await _fetchList(refresh: true);
|
||||
}
|
||||
|
||||
///获取数据
|
||||
Future<void> _fetchList({bool refresh = false}) async {
|
||||
const pageSize = 20;
|
||||
int page = refresh ? 1 : (_recordList.length / pageSize).ceil() + 1;
|
||||
if (!_isLoading && !_isEnd) {
|
||||
setState(() => _isLoading = true);
|
||||
var type = tabList[_tabController.index].value;
|
||||
var res = await skinRecordApi(
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
query: {"skin_status": type},
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_isEnd = res.list!.length < pageSize;
|
||||
if (refresh) {
|
||||
_recordList.clear();
|
||||
}
|
||||
_recordList.addAll(res.list!);
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Analysis History"),
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
dividerColor: Colors.transparent,
|
||||
tabs: tabList.map((item) {
|
||||
return Tab(text: item.name);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () => _onRefresh(),
|
||||
child: Visibility(
|
||||
visible: !_isLoading && _recordList.isEmpty,
|
||||
replacement: ListView(
|
||||
controller: _scrollController,
|
||||
padding: EdgeInsets.all(15),
|
||||
children: [
|
||||
..._recordList.map((item) {
|
||||
return ItemWidget(data: item);
|
||||
}),
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
child: Visibility(
|
||||
visible: _isLoading,
|
||||
replacement: Center(child: Text("已加载完毕", style: Theme.of(context).textTheme.labelSmall)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 12,
|
||||
height: 12,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 1,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Text("加载中...", style: Theme.of(context).textTheme.labelSmall),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Empty(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
class TabItem {
|
||||
final String name;
|
||||
final int value;
|
||||
|
||||
const TabItem({required this.name, required this.value});
|
||||
}
|
||||
113
lib/page/record/list/widget/item_widget.dart
Normal file
113
lib/page/record/list/widget/item_widget.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
import 'package:derma_flutter/api/dto/record_list_dto.dart';
|
||||
import 'package:derma_flutter/config/theme/custom_colors.dart';
|
||||
import 'package:derma_flutter/router/config/route_paths.dart';
|
||||
import 'package:derma_flutter/utils/format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class ItemWidget extends StatefulWidget {
|
||||
final RecordItemDto data;
|
||||
|
||||
const ItemWidget({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<ItemWidget> createState() => _ItemWidgetState();
|
||||
}
|
||||
|
||||
class _ItemWidgetState extends State<ItemWidget> {
|
||||
void _handToDetail() {
|
||||
context.push(RoutePaths.detail, extra: widget.data.result);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var color = Colors.black;
|
||||
|
||||
switch (widget.data.skinStatus) {
|
||||
case 1:
|
||||
color = Theme.of(context).colorScheme.success;
|
||||
break;
|
||||
case 2:
|
||||
color = Theme.of(context).colorScheme.warning;
|
||||
break;
|
||||
case 3:
|
||||
color = Theme.of(context).colorScheme.error;
|
||||
break;
|
||||
default:
|
||||
color = Colors.black;
|
||||
}
|
||||
|
||||
return InkWell(
|
||||
onTap: _handToDetail,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
margin: EdgeInsets.only(bottom: 15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffE9E9E9),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 9,
|
||||
offset: Offset(1, 2), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
child: Text("Recent Analyses"),
|
||||
),
|
||||
Row(
|
||||
spacing: 15,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Image.network(
|
||||
widget.data.imageUrl!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer),
|
||||
child: Icon(RemixIcons.error_warning_fill),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"health",
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: color),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
formatDateUS(widget.data.createdAt),
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
lib/page/system/agree/agree_page.dart
Normal file
23
lib/page/system/agree/agree_page.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class AgreePage extends StatelessWidget {
|
||||
final String title;
|
||||
final String url;
|
||||
|
||||
const AgreePage({super.key, required this.title, required this.url});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: WebViewWidget(
|
||||
controller: WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..loadRequest(Uri.parse(url)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
115
lib/page/system/login/login_code_page.dart
Normal file
115
lib/page/system/login/login_code_page.dart
Normal file
@@ -0,0 +1,115 @@
|
||||
import 'package:derma_flutter/api/endpoints/user_api.dart';
|
||||
import 'package:derma_flutter/api/network/safe.dart';
|
||||
import 'package:derma_flutter/page/system/login/widget/widget.dart';
|
||||
import 'package:derma_flutter/router/config/route_paths.dart';
|
||||
import 'package:derma_flutter/widgets/ui_kit/button/custom_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../providers/app_store.dart';
|
||||
|
||||
class LoginCodePage extends StatefulWidget {
|
||||
final String email;
|
||||
final String password;
|
||||
|
||||
const LoginCodePage({super.key, required this.email, required this.password});
|
||||
|
||||
@override
|
||||
State<LoginCodePage> createState() => _LoginCodePageState();
|
||||
}
|
||||
|
||||
class _LoginCodePageState extends State<LoginCodePage> {
|
||||
final _codeController = TextEditingController();
|
||||
var _subLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_handSendCode();
|
||||
}
|
||||
|
||||
///发送验证码
|
||||
void _handSendCode() {
|
||||
sendEmailCodeApi(widget.email);
|
||||
EasyLoading.showSuccess("Send success");
|
||||
}
|
||||
|
||||
///提交
|
||||
void _handSubmit() async {
|
||||
if (_codeController.text.isNotEmpty) {
|
||||
setState(() {
|
||||
_subLoading = true;
|
||||
});
|
||||
var res = await safeRequest(
|
||||
registerApi(
|
||||
widget.email,
|
||||
widget.password,
|
||||
_codeController.text,
|
||||
),
|
||||
onError: (error) {
|
||||
setState(() {
|
||||
_subLoading = false;
|
||||
});
|
||||
},
|
||||
);
|
||||
var appStore = context.read<AppStore>();
|
||||
await appStore.setInfo(res);
|
||||
context.go(RoutePaths.layout);
|
||||
setState(() {
|
||||
_subLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(left: 20, right: 20, top: 40),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Check your inbox",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20, bottom: 40),
|
||||
child: Text(
|
||||
"Enter the verification code we just sent to ${widget.email}.",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
InputBox(hintText: "Code", controller: _codeController),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
child: CustomButton(
|
||||
loading: _subLoading,
|
||||
onPressed: _handSubmit,
|
||||
child: Text("Continue"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
_handSendCode();
|
||||
},
|
||||
child: Text(
|
||||
"Resend code",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
236
lib/page/system/login/login_page.dart
Normal file
236
lib/page/system/login/login_page.dart
Normal file
@@ -0,0 +1,236 @@
|
||||
import 'package:derma_flutter/api/endpoints/user_api.dart';
|
||||
import 'package:derma_flutter/data/models/other_login_type.dart';
|
||||
import 'package:derma_flutter/router/config/route_paths.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
import '../../../providers/app_store.dart';
|
||||
import '../../../widgets/common/app_backend.dart';
|
||||
import '../../../widgets/ui_kit/button/custom_button.dart';
|
||||
import 'widget/agreement_box.dart';
|
||||
import 'widget/widget.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
State<LoginPage> createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
var _subLoading = false;
|
||||
///协议
|
||||
bool _agree = false;
|
||||
|
||||
///谷歌登陆
|
||||
final GoogleSignIn _googleSignIn = GoogleSignIn.instance;
|
||||
|
||||
///邮箱输入框
|
||||
final TextEditingController _emailController = TextEditingController(text: "18207394@qq.com");
|
||||
final TextEditingController _passwordController = TextEditingController(text: "111");
|
||||
|
||||
//显示密码
|
||||
var _hidePassword = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initGoogleSign();
|
||||
}
|
||||
|
||||
void _initGoogleSign() {
|
||||
_googleSignIn.initialize(
|
||||
clientId: null,
|
||||
serverClientId: "497244455669-sl271gkb1polqd8kqtnb6co82n95aerq.apps.googleusercontent.com",
|
||||
);
|
||||
_googleSignIn.authenticationEvents
|
||||
.listen((_) {
|
||||
print("登陆成功");
|
||||
})
|
||||
.onError((error) {
|
||||
print('登录错误: $error');
|
||||
});
|
||||
}
|
||||
|
||||
void _handleSignIn() async {
|
||||
if (!_agree) {
|
||||
EasyLoading.showToast('Please read and agree to the terms first.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果用户未登录,则启动标准的 Google 登录
|
||||
if (_googleSignIn.supportsAuthenticate()) {
|
||||
// 使用 authenticate() 进行认证
|
||||
GoogleSignInAccount? user = await _googleSignIn.authenticate();
|
||||
var auth = user.authentication;
|
||||
|
||||
// var res = await Dio().get("https://oauth2.googleapis.com/tokeninfo?id_token=${auth.idToken}");
|
||||
//登陆
|
||||
EasyLoading.show(status: "Logging in...");
|
||||
var res = await thirdLoginApi(auth.idToken!, OtherLoginType.google);
|
||||
EasyLoading.dismiss();
|
||||
_onLogin(res);
|
||||
}
|
||||
// } catch (e) {
|
||||
// if (e is GoogleSignInException) {
|
||||
// if (e.code == GoogleSignInExceptionCode.canceled) {
|
||||
// // 用户取消登录
|
||||
// print("User canceled login.");
|
||||
// } else {
|
||||
// // 其他错误
|
||||
// print("Google Sign-In error: $e");
|
||||
// }
|
||||
// } else {
|
||||
// print("Unknown error: $e");
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
EasyLoading.showError("Login failed");
|
||||
print("登录错误: $e");
|
||||
}
|
||||
}
|
||||
|
||||
void _handSubmit() async {
|
||||
if (!_agree) {
|
||||
EasyLoading.showToast('Please read and agree to the terms first.');
|
||||
return;
|
||||
}
|
||||
if (_emailController.text.isEmpty) {
|
||||
//请输入邮箱
|
||||
EasyLoading.showError("Please enter your email");
|
||||
return;
|
||||
} else if (_passwordController.text.isEmpty) {
|
||||
EasyLoading.showError("Please enter your Password");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setState(() {
|
||||
_subLoading = true;
|
||||
});
|
||||
var isRegister = await checkRegisterApi(_emailController.text);
|
||||
if (!isRegister) {
|
||||
context.push(
|
||||
RoutePaths.loginCode,
|
||||
extra: {
|
||||
"email": _emailController.text,
|
||||
"password": _passwordController.text,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
var res = await loginApi(_emailController.text, _passwordController.text);
|
||||
_onLogin(res);
|
||||
}
|
||||
setState(() {
|
||||
_subLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_subLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
///登陆的操作
|
||||
void _onLogin(dynamic res) {
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.setInfo(res);
|
||||
context.go(RoutePaths.layout);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: AppBackend(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(
|
||||
top: 0.1.sh,
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
LogoBox(),
|
||||
PageHeader(),
|
||||
InputBox(
|
||||
hintText: "Email",
|
||||
controller: _emailController,
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
InputBox(
|
||||
obscureText: _hidePassword,
|
||||
hintText: "Password",
|
||||
controller: _passwordController,
|
||||
suffix: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_hidePassword = !_hidePassword;
|
||||
});
|
||||
},
|
||||
child: Icon(
|
||||
_hidePassword ? RemixIcons.eye_off_fill : RemixIcons.eye_fill,
|
||||
size: 20,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
height: 45,
|
||||
child: CustomButton(
|
||||
loading: _subLoading,
|
||||
round: false,
|
||||
onPressed: _handSubmit,
|
||||
child: Text("Continue"),
|
||||
),
|
||||
),
|
||||
LoginDivider(),
|
||||
OtherButton(
|
||||
title: "Continue with Google",
|
||||
icon: "assets/image/google.png",
|
||||
onTap: () {
|
||||
_handleSignIn();
|
||||
},
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
// OtherButton(
|
||||
// title: "Continue with Apple",
|
||||
// icon: "assets/image/apple.png",
|
||||
// onTap: () {},
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 20,
|
||||
child: AgreementBox(
|
||||
checked: _agree,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_agree = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
77
lib/page/system/login/widget/agreement_box.dart
Normal file
77
lib/page/system/login/widget/agreement_box.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:derma_flutter/router/config/route_paths.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
///勾中协议
|
||||
class AgreementBox extends StatelessWidget {
|
||||
final bool checked;
|
||||
final Function(bool) onChanged;
|
||||
|
||||
const AgreementBox({
|
||||
super.key,
|
||||
this.checked = false,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 25,
|
||||
child: Transform.scale(
|
||||
scale: 0.8,
|
||||
child: Checkbox(
|
||||
value: checked,
|
||||
shape: CircleBorder(),
|
||||
onChanged: (value) {
|
||||
onChanged(value!);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "我已阅读并同意",
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
onChanged(!checked);
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text: "《用户协议》",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "用户协议", "url": "https://keyang2.tuzuu.com/ak-health/agreement/user_agreement.html"},
|
||||
);
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text: "《隐私协议》",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "隐私政策", "url": "https://keyang2.tuzuu.com/ak-health/agreement/privacy_policy.html"},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
166
lib/page/system/login/widget/widget.dart
Normal file
166
lib/page/system/login/widget/widget.dart
Normal file
@@ -0,0 +1,166 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
///登陆Box
|
||||
class LogoBox extends StatelessWidget {
|
||||
const LogoBox({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 60),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/image/logo.png",
|
||||
width: 43,
|
||||
),
|
||||
Text(
|
||||
"Demacare",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///头部文案
|
||||
class PageHeader extends StatelessWidget {
|
||||
const PageHeader({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 30),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Create an account",
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
Text(
|
||||
"Enter your email to sign up for this app",
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///输入框
|
||||
class InputBox extends StatelessWidget {
|
||||
final bool obscureText;
|
||||
final String hintText;
|
||||
final TextEditingController controller;
|
||||
final Widget? suffix;
|
||||
|
||||
const InputBox({
|
||||
super.key,
|
||||
this.obscureText = false,
|
||||
required this.hintText,
|
||||
required this.controller,
|
||||
this.suffix,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//边框
|
||||
var inputBorder = OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
),
|
||||
);
|
||||
return TextField(
|
||||
controller: controller,
|
||||
maxLength: 20,
|
||||
obscureText: obscureText,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText,
|
||||
hintStyle: Theme.of(context).textTheme.labelMedium,
|
||||
counterText: '',
|
||||
border: inputBorder,
|
||||
enabledBorder: inputBorder,
|
||||
suffix: suffix,
|
||||
suffixIconConstraints: BoxConstraints(
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///分割线
|
||||
class LoginDivider extends StatelessWidget {
|
||||
const LoginDivider({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"or",
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///其他登陆按钮
|
||||
class OtherButton extends StatelessWidget {
|
||||
final Function() onTap;
|
||||
final String title;
|
||||
final String icon;
|
||||
|
||||
const OtherButton({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(icon, width: 20),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
65
lib/page/system/splash/splash_page.dart
Normal file
65
lib/page/system/splash/splash_page.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:derma_flutter/providers/app_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/app_context.dart';
|
||||
import '../../../router/config/route_paths.dart';
|
||||
import '../../../router/routes.dart';
|
||||
|
||||
class SplashPage extends StatefulWidget {
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
State<SplashPage> createState() => _SplashPageState();
|
||||
}
|
||||
|
||||
class _SplashPageState extends State<SplashPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
init();
|
||||
}
|
||||
|
||||
void init() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
AppContext.setContent(navigatorKey.currentState!.context);
|
||||
//效验
|
||||
AppStore appStore = context.read<AppStore>();
|
||||
await appStore.init();
|
||||
if (!mounted) return;
|
||||
if (appStore.token.isEmpty) {
|
||||
context.go(RoutePaths.login);
|
||||
} else {
|
||||
context.go(RoutePaths.layout);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/image/logo.png",
|
||||
width: 68.w,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 16),
|
||||
child: Text(
|
||||
"Demacare",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user