1
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:plan/theme/decorations/app_shadows.dart';
|
||||
|
||||
import '../../../router/config/route_paths.dart';
|
||||
|
||||
class PlanFormCard extends StatefulWidget {
|
||||
const PlanFormCard({super.key});
|
||||
@@ -10,6 +14,19 @@ class PlanFormCard extends StatefulWidget {
|
||||
class _PlanFormCardState extends State<PlanFormCard> {
|
||||
final TextEditingController _inputController = TextEditingController();
|
||||
|
||||
void _handSubmit() {
|
||||
if (_inputController.text.isEmpty) {
|
||||
return;
|
||||
}
|
||||
context.push(
|
||||
RoutePaths.planDetail(),
|
||||
extra: {
|
||||
"name": _inputController.text,
|
||||
},
|
||||
);
|
||||
_inputController.clear();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
@@ -26,20 +43,7 @@ class _PlanFormCardState extends State<PlanFormCard> {
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 40),
|
||||
margin: EdgeInsets.only(top: 120),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black, width: 2),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffb5b5b5),
|
||||
blurRadius: 2,
|
||||
offset: Offset(6, 6),
|
||||
spreadRadius: 0,
|
||||
blurStyle: BlurStyle.normal,
|
||||
),
|
||||
],
|
||||
),
|
||||
decoration: shadowDecoration,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
@@ -49,6 +53,7 @@ class _PlanFormCardState extends State<PlanFormCard> {
|
||||
TextField(
|
||||
controller: _inputController,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
maxLength: 40,
|
||||
decoration: InputDecoration(
|
||||
hintText: "我躺在床上听歌",
|
||||
fillColor: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
@@ -68,19 +73,22 @@ class _PlanFormCardState extends State<PlanFormCard> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: Colors.black, width: 1.5),
|
||||
),
|
||||
child: Text(
|
||||
"创建计划",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
InkWell(
|
||||
onTap: _handSubmit,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: Colors.black, width: 1.5),
|
||||
),
|
||||
child: Text(
|
||||
"创建计划",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:plan/api/dto/login_dto.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../../api/endpoints/user_api.dart';
|
||||
import '../../providers/app_store.dart';
|
||||
import '../../router/config/route_paths.dart';
|
||||
import 'widget/avatar_name.dart';
|
||||
import 'widget/profile_section.dart';
|
||||
|
||||
@@ -15,6 +22,72 @@ class MyPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyPageState extends State<MyPage> {
|
||||
|
||||
///退出登陆
|
||||
void _handLogout() async {
|
||||
await showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text("Log Out?"),
|
||||
content: Text("Are you sure you want to log out? You’ll need to sign in again to access your account."),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text("Cancel"),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text("Log Out"),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.logout();
|
||||
context.go(RoutePaths.login);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///注销账号
|
||||
void _handDelete() async {
|
||||
await showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text("Delete Account?"),
|
||||
content: Text("Are you sure you want to delete your account? You won’t be able to recover your account."),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
child: Text("Cancel"),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text("Delete"),
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
EasyLoading.show();
|
||||
await deleteAccountApi();
|
||||
EasyLoading.dismiss();
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.logout();
|
||||
context.go(RoutePaths.login);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///编辑资料
|
||||
void _updateUserInfo(UserInfo value) {
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.updateUserInfo(value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
@@ -32,8 +105,31 @@ class _MyPageState extends State<MyPage> {
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
|
||||
children: [
|
||||
AvatarName(),
|
||||
ProfileSection(),
|
||||
AvatarName(
|
||||
onUpdate: _updateUserInfo,
|
||||
),
|
||||
ProfileSection(
|
||||
onUpdate: _updateUserInfo,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 50),
|
||||
child: CupertinoButton(
|
||||
color: CupertinoColors.systemRed,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
onPressed: _handLogout,
|
||||
child: Text(
|
||||
"退出登录",
|
||||
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
onPressed: _handDelete,
|
||||
child: const Text(
|
||||
"删除账号",
|
||||
style: TextStyle(color: CupertinoColors.systemRed, fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:plan/api/dto/login_dto.dart';
|
||||
import 'package:plan/api/endpoints/user_api.dart';
|
||||
import 'package:plan/providers/app_store.dart';
|
||||
import 'package:plan/utils/common.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
||||
class AvatarName extends StatefulWidget {
|
||||
const AvatarName({super.key});
|
||||
final Function(UserInfo) onUpdate;
|
||||
|
||||
const AvatarName({super.key, required this.onUpdate});
|
||||
|
||||
@override
|
||||
State<AvatarName> createState() => _AvatarNameState();
|
||||
@@ -19,94 +29,150 @@ class _AvatarNameState extends State<AvatarName> {
|
||||
setState(() {
|
||||
_isEdit = true;
|
||||
});
|
||||
AppStore appStore = context.read<AppStore>();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_inputController.text = appStore.userInfo?.name ?? "";
|
||||
_focusNode.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
///确定编辑内容
|
||||
void _confirmEdit(String value) {
|
||||
///确定编辑名字
|
||||
void _confirmEdit(String value) async {
|
||||
setState(() {
|
||||
_isEdit = false;
|
||||
});
|
||||
var res = await updateUserInfoApi(name: value);
|
||||
widget.onUpdate(res);
|
||||
}
|
||||
|
||||
///选择图片
|
||||
void _handPickImage() async {
|
||||
var result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.image,
|
||||
allowMultiple: false,
|
||||
);
|
||||
if (result != null) {
|
||||
//压缩文件
|
||||
final compress = await FlutterImageCompress.compressWithFile(
|
||||
result.files[0].path!,
|
||||
minWidth: 500,
|
||||
minHeight: 500,
|
||||
quality: 85,
|
||||
rotate: 0,
|
||||
);
|
||||
|
||||
var res = await updateUserInfoApi(avatar: compress);
|
||||
widget.onUpdate(res);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
spacing: 15,
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xffcae2fd),
|
||||
border: Border.all(
|
||||
color: Color(0xff797e80),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
width: 50,
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff8e8d93),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Icon(
|
||||
RemixIcons.user_fill,
|
||||
color: Color(0xffcae2fd),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Visibility(
|
||||
visible: _isEdit,
|
||||
replacement: InkWell(
|
||||
onTap: _handleEdit,
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text(
|
||||
"教练如何称呼你?",
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
Icon(
|
||||
RemixIcons.pencil_fill,
|
||||
size: 18,
|
||||
color: Theme.of(context).textTheme.labelMedium?.color,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
focusNode: _focusNode,
|
||||
controller: _inputController,
|
||||
style: TextStyle(fontSize: 14),
|
||||
decoration: InputDecoration(
|
||||
hintText: "输入你的姓名",
|
||||
isCollapsed: true,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
return Consumer<AppStore>(
|
||||
builder: (context, store, __) {
|
||||
return Row(
|
||||
spacing: 15,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: _handPickImage,
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xffcae2fd),
|
||||
border: Border.all(
|
||||
color: Color(0xff797e80),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
alignment: Alignment.center,
|
||||
child: Visibility(
|
||||
visible: getNotEmpty(store.userInfo?.avatar) == null,
|
||||
replacement: CachedNetworkImage(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
imageUrl: store.userInfo?.avatar ?? "",
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
placeholder: (context, url) => Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
alignment: Alignment.center,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
width: 50,
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xff8e8d93),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Icon(
|
||||
RemixIcons.user_fill,
|
||||
color: Color(0xffcae2fd),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onSubmitted: _confirmEdit,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: Visibility(
|
||||
visible: _isEdit,
|
||||
replacement: InkWell(
|
||||
onTap: _handleEdit,
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: getNotEmpty(store.userInfo?.name) == null,
|
||||
replacement: Text(
|
||||
store.userInfo?.name ?? "",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
child: Text(
|
||||
"教练如何称呼你?",
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
RemixIcons.pencil_fill,
|
||||
size: 18,
|
||||
color: Theme.of(context).textTheme.labelMedium?.color,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
focusNode: _focusNode,
|
||||
controller: _inputController,
|
||||
style: TextStyle(fontSize: 14),
|
||||
maxLength: 20,
|
||||
decoration: InputDecoration(
|
||||
hintText: "输入你的姓名",
|
||||
isCollapsed: true,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
),
|
||||
),
|
||||
onSubmitted: _confirmEdit,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:plan/api/dto/login_dto.dart';
|
||||
import 'package:plan/api/endpoints/user_api.dart';
|
||||
import 'package:plan/providers/app_store.dart';
|
||||
import 'package:plan/utils/debouncer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class ProfileSection extends StatefulWidget {
|
||||
const ProfileSection({super.key});
|
||||
final Function(UserInfo) onUpdate;
|
||||
|
||||
const ProfileSection({super.key, required this.onUpdate});
|
||||
|
||||
@override
|
||||
State<ProfileSection> createState() => _ProfileSectionState();
|
||||
@@ -12,7 +19,35 @@ class _ProfileSectionState extends State<ProfileSection> {
|
||||
//输入框
|
||||
final TextEditingController _inputController = TextEditingController();
|
||||
|
||||
final List<String> _tips = ["教练每次为你制定计划时,都会首先参考这里的信息", "你分享的背景信息越详细,教练就越能为你量身定制,符合你独特情况的行动步骤", "你可以在这里为教练提需求,比如“我不吃香菜”"];
|
||||
final List<String> _tips = [
|
||||
"教练每次为你制定计划时,都会首先参考这里的信息",
|
||||
"你分享的背景信息越详细,教练就越能为你量身定制,符合你独特情况的行动步骤",
|
||||
"你可以在这里为教练提需求,比如“我不吃香菜”",
|
||||
];
|
||||
|
||||
//防抖
|
||||
Debouncer debouncer = Debouncer(milliseconds: 2000);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
AppStore appStore = context.read<AppStore>();
|
||||
_inputController.text = appStore.userInfo?.description ?? "";
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
debouncer.dispose();
|
||||
}
|
||||
|
||||
///确定编辑画像
|
||||
void _onTextChanged(String value) {
|
||||
debouncer.run(() async {
|
||||
var res = await updateUserInfoApi(description: value);
|
||||
widget.onUpdate(res);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -38,9 +73,10 @@ class _ProfileSectionState extends State<ProfileSection> {
|
||||
margin: EdgeInsets.only(bottom: 20),
|
||||
child: TextField(
|
||||
maxLines: 5,
|
||||
maxLength: 200,
|
||||
maxLength: 500,
|
||||
controller: _inputController,
|
||||
style: TextStyle(fontSize: 14, letterSpacing: 1),
|
||||
onChanged: _onTextChanged,
|
||||
decoration: InputDecoration(
|
||||
hintText: "我是19岁女生,刷碗时用洗碗机,请不要按手洗拆解步骤..",
|
||||
enabledBorder: OutlineInputBorder(
|
||||
|
||||
@@ -1,29 +1,148 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:plan/page/plan/detail/viewmodel/plan_detail_store.dart';
|
||||
import 'package:plan/theme/decorations/app_shadows.dart';
|
||||
import 'package:plan/widgets/ui_kit/popup/popup_action.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../widgets/edit_desc_dialog.dart';
|
||||
import 'widgets/avatar_card.dart';
|
||||
import 'widgets/plan_item.dart';
|
||||
import 'widgets/scroll_box.dart';
|
||||
import 'widgets/suggested.dart';
|
||||
|
||||
class PlanDetailPage extends StatefulWidget {
|
||||
const PlanDetailPage({super.key});
|
||||
final String? id;
|
||||
final String? planName;
|
||||
|
||||
const PlanDetailPage({
|
||||
super.key,
|
||||
this.id,
|
||||
this.planName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PlanDetailPage> createState() => _PlanDetailPageState();
|
||||
}
|
||||
|
||||
class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||
bool _isEdit = false;
|
||||
|
||||
///popup菜单
|
||||
void _onPopupActionSelected(String value) {
|
||||
if (value == 'edit_step') {
|
||||
setState(() {
|
||||
_isEdit = true;
|
||||
});
|
||||
} else if (value == 'edit_desc') {
|
||||
showEditDescDialog(
|
||||
context,
|
||||
value: "你好",
|
||||
onConfirm: (value) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///取消编辑
|
||||
void _cancelEdit() {
|
||||
setState(() {
|
||||
_isEdit = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: Colors.white,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('计划详情'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min, // 关键:Row 只占实际内容宽度
|
||||
children: [
|
||||
Icon(RemixIcons.more_fill),
|
||||
],
|
||||
return ChangeNotifierProvider<PlanDetailStore>(
|
||||
create: (_) {
|
||||
return PlanDetailStore();
|
||||
},
|
||||
child: CupertinoPageScaffold(
|
||||
backgroundColor: Colors.white,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('计划详情'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min, // 关键:Row 只占实际内容宽度
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder: (child, animation) {
|
||||
// 仅使用渐变动画
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _isEdit
|
||||
? InkWell(
|
||||
onTap: _cancelEdit,
|
||||
child: Icon(RemixIcons.check_fill),
|
||||
)
|
||||
: PopupAction(
|
||||
onSelected: _onPopupActionSelected,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
value: 'edit_step',
|
||||
child: Text("编辑步骤"),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'edit_desc',
|
||||
child: Text("编辑摘要"),
|
||||
),
|
||||
],
|
||||
child: Icon(RemixIcons.more_fill),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
AvatarCard(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: ScrollBox(
|
||||
child: Container(
|
||||
decoration: shadowDecoration,
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(height: 20),
|
||||
),
|
||||
SliverList.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return PlanItem(
|
||||
showEdit: _isEdit,
|
||||
title: "测试 ${index + 1}",
|
||||
desc: "测测 ${index + 1}",
|
||||
onDelete: (id) {},
|
||||
);
|
||||
},
|
||||
itemCount: 10,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: SuggestedTitle(),
|
||||
),
|
||||
SliverList.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return SuggestedItem(
|
||||
title: "测试",
|
||||
);
|
||||
},
|
||||
itemCount: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
13
lib/page/plan/detail/viewmodel/plan_detail_store.dart
Normal file
13
lib/page/plan/detail/viewmodel/plan_detail_store.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class PlanDetailStore extends ChangeNotifier {
|
||||
///角色话语是否显示
|
||||
bool _showRoleTalk = true;
|
||||
|
||||
bool get showRoleTalk => _showRoleTalk;
|
||||
|
||||
set showRoleTalk(bool value) {
|
||||
_showRoleTalk = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
137
lib/page/plan/detail/widgets/avatar_card.dart
Normal file
137
lib/page/plan/detail/widgets/avatar_card.dart
Normal file
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class AvatarCard extends StatefulWidget {
|
||||
const AvatarCard({super.key});
|
||||
|
||||
@override
|
||||
State<AvatarCard> createState() => _AvatarCardState();
|
||||
}
|
||||
|
||||
class _AvatarCardState extends State<AvatarCard> with SingleTickerProviderStateMixin {
|
||||
bool _isShow = false;
|
||||
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 400),
|
||||
);
|
||||
}
|
||||
|
||||
void _toggleShow() {
|
||||
setState(() {
|
||||
_isShow = !_isShow;
|
||||
if (_isShow) {
|
||||
_controller.forward();
|
||||
} else {
|
||||
_controller.reverse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, 50),
|
||||
child: Column(
|
||||
children: [
|
||||
Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.identity()..translate(40.0, 40.0)..scale(0.2),
|
||||
child: Container(
|
||||
color: Colors.red,
|
||||
padding: EdgeInsets.only(bottom: 10),
|
||||
child: InkWell(
|
||||
onTap: _toggleShow,
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
border: Border.all(color: Colors.black, width: 1),
|
||||
),
|
||||
child: Text(
|
||||
"好的,让我们把学习软件开发这个目标分解成最简单的小步骤,这样你明天就能轻松开始行动",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: CustomPaint(
|
||||
painter: BubblePainter(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
Image.asset("assets/image/xiaozhi.png", height: 100),
|
||||
Positioned(
|
||||
top: 20,
|
||||
child: Transform.translate(
|
||||
offset: Offset(50, -10),
|
||||
child: GestureDetector(
|
||||
onTap: _toggleShow,
|
||||
child: Icon(RemixIcons.message_2_line, size: 26),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BubblePainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
var bottomWidth = 10;
|
||||
//点坐标
|
||||
var start = Offset((size.width - bottomWidth) / 2, 0);
|
||||
//底线
|
||||
final bottomLinePaint = Paint()
|
||||
..color = Colors.white
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
final bottomLinePath = Path()
|
||||
..moveTo(start.dx, 0)
|
||||
..lineTo(start.dx + bottomWidth, 0);
|
||||
canvas.drawPath(bottomLinePath, bottomLinePaint);
|
||||
|
||||
//边线
|
||||
final sideLinePaint = Paint()
|
||||
..color = Colors.black
|
||||
..strokeWidth = 1
|
||||
..style = bottomLinePaint.style;
|
||||
|
||||
final sideLinePath = Path()
|
||||
..moveTo(start.dx, 0)
|
||||
..lineTo(start.dx + bottomWidth / 2, 5)
|
||||
..lineTo(start.dx + bottomWidth, 0);
|
||||
canvas.drawPath(sideLinePath, sideLinePaint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
71
lib/page/plan/detail/widgets/plan_item.dart
Normal file
71
lib/page/plan/detail/widgets/plan_item.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:plan/widgets/business/delete_row_item.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class PlanItem extends StatefulWidget {
|
||||
final String title;
|
||||
final String desc;
|
||||
final bool showEdit;
|
||||
final Function(int) onDelete;
|
||||
|
||||
const PlanItem({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.desc,
|
||||
this.showEdit = false,
|
||||
required this.onDelete,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PlanItem> createState() => _PlanItemState();
|
||||
}
|
||||
|
||||
class _PlanItemState extends State<PlanItem> with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
child: DeleteRowItem(
|
||||
showDelete: widget.showEdit,
|
||||
onDelete: () {},
|
||||
builder: (_, animate) {
|
||||
return [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 3),
|
||||
child: Text(
|
||||
"完成以上步骤后,给自己倒杯水休息一下。",
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"就从这里开始,写下基本信息只需要2分钟,这是最简单的一部",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizeTransition(
|
||||
axis: Axis.horizontal,
|
||||
sizeFactor: animate,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
child: Opacity(
|
||||
opacity: 0.4,
|
||||
child: Icon(RemixIcons.menu_line),
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
23
lib/page/plan/detail/widgets/scroll_box.dart
Normal file
23
lib/page/plan/detail/widgets/scroll_box.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScrollBox extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const ScrollBox({super.key, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScrollbarTheme(
|
||||
data: ScrollbarThemeData(
|
||||
thumbColor: WidgetStateProperty.all(Theme.of(context).colorScheme.surfaceContainerHigh),
|
||||
thickness: WidgetStateProperty.all(3),
|
||||
crossAxisMargin: 3,
|
||||
mainAxisMargin: 2,
|
||||
radius: const Radius.circular(5),
|
||||
),
|
||||
child: Scrollbar(
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
73
lib/page/plan/detail/widgets/suggested.dart
Normal file
73
lib/page/plan/detail/widgets/suggested.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
///模块标题
|
||||
class SuggestedTitle extends StatelessWidget {
|
||||
const SuggestedTitle({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 20, bottom: 5),
|
||||
child: Opacity(
|
||||
opacity: 0.6,
|
||||
child: Row(
|
||||
spacing: 20,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
Text(
|
||||
"额外建议",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SuggestedItem extends StatelessWidget {
|
||||
final String title;
|
||||
|
||||
const SuggestedItem({super.key, required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(0, 5),
|
||||
child: Icon(
|
||||
RemixIcons.lightbulb_flash_fill,
|
||||
color: Color(0xfff2a529),
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: 0.5,
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import 'widgets/history_item.dart';
|
||||
import 'widgets/popup_action.dart';
|
||||
import '../../../widgets/ui_kit/popup/popup_action.dart';
|
||||
|
||||
class PlanHistoryPage extends StatefulWidget {
|
||||
const PlanHistoryPage({super.key});
|
||||
@@ -42,22 +43,19 @@ class _PlanHistoryPageState extends State<PlanHistoryPage> {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text("计划历史"),
|
||||
trailing: CupertinoNavigationBar(
|
||||
transitionBetweenRoutes: false,
|
||||
middle: const Text("计划历史"),
|
||||
trailing: PopupAction(
|
||||
onSelected: _onPopupActionSelected,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
value: 'edit',
|
||||
child: Text(
|
||||
_isDelete ? "完成" : "编辑",
|
||||
style: TextStyle(color: Colors.black),
|
||||
),
|
||||
middle: const Text("计划历史"),
|
||||
trailing: PopupAction(
|
||||
onSelected: _onPopupActionSelected,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
value: 'edit',
|
||||
child: Text(
|
||||
_isDelete ? "完成" : "编辑",
|
||||
style: TextStyle(color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Icon(RemixIcons.more_fill),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:plan/router/config/route_paths.dart';
|
||||
import 'package:plan/widgets/business/delete_row_item.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class HistoryItem extends StatefulWidget {
|
||||
@@ -18,76 +18,15 @@ class HistoryItem extends StatefulWidget {
|
||||
State<HistoryItem> createState() => _HistoryItemState();
|
||||
}
|
||||
|
||||
class _HistoryItemState extends State<HistoryItem> with TickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
|
||||
class _HistoryItemState extends State<HistoryItem> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 300),
|
||||
);
|
||||
_animation = CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
|
||||
if (widget.showDelete) {
|
||||
_controller.forward();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant HistoryItem oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.showDelete != widget.showDelete) {
|
||||
if (widget.showDelete) {
|
||||
_controller.forward();
|
||||
} else {
|
||||
_controller.reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
///点击删除
|
||||
void _handleDelete() {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text("删除计划"),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text("取消"),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
widget.onDelete(0);
|
||||
},
|
||||
child: Text("确定"),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
///跳转详情
|
||||
void _goDetail() {
|
||||
context.push(RoutePaths.planDetail);
|
||||
context.push(RoutePaths.planDetail(1));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -98,62 +37,53 @@ class _HistoryItemState extends State<HistoryItem> with TickerProviderStateMixin
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.symmetric(vertical: 15),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
SizeTransition(
|
||||
axis: Axis.horizontal,
|
||||
sizeFactor: _animation,
|
||||
axisAlignment: -1, // 从左向右展开
|
||||
child: InkWell(
|
||||
onTap: _handleDelete,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: Icon(
|
||||
RemixIcons.indeterminate_circle_fill,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: Text("开始学习软件开发"),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: Text(
|
||||
"创建于 2025/9/3 9:40:51 教练:W教练",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
child: DeleteRowItem(
|
||||
showDelete: widget.showDelete,
|
||||
onDelete: () {
|
||||
widget.onDelete(0);
|
||||
},
|
||||
builder: (_, __) {
|
||||
return [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: Text("开始学习软件开发"),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Expanded(
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.5,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"0/7",
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 5),
|
||||
child: Text(
|
||||
"创建于 2025/9/3 9:40:51 教练:W教练",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Expanded(
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.5,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"0/7",
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
RemixIcons.arrow_right_s_line,
|
||||
size: 30,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
],
|
||||
Icon(
|
||||
RemixIcons.arrow_right_s_line,
|
||||
size: 30,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
class PopupAction extends StatelessWidget {
|
||||
final List<PopupMenuEntry<String>> items;
|
||||
final Function(String) onSelected;
|
||||
|
||||
const PopupAction({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton<String>(
|
||||
color: Colors.white,
|
||||
offset: Offset(0, 30),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12), // 圆角
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 200,
|
||||
),
|
||||
elevation: 6,
|
||||
shadowColor: Colors.black87,
|
||||
onSelected:onSelected,
|
||||
itemBuilder: (context) => items,
|
||||
child: const Icon(RemixIcons.more_fill),
|
||||
);
|
||||
}
|
||||
}
|
||||
48
lib/page/plan/widgets/edit_desc_dialog.dart
Normal file
48
lib/page/plan/widgets/edit_desc_dialog.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
void showEditDescDialog(
|
||||
BuildContext context, {
|
||||
String value = "",
|
||||
required void Function(String) onConfirm,
|
||||
}) {
|
||||
final controller = TextEditingController(text: value);
|
||||
final focusNode = FocusNode();
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
// 确保弹窗显示后再获取焦点
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
focusNode.requestFocus();
|
||||
});
|
||||
|
||||
return CupertinoAlertDialog(
|
||||
title: Text("编辑摘要"),
|
||||
content: Padding(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
placeholder: "edit...",
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
child: Text('取消'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
onConfirm(controller.text);
|
||||
},
|
||||
child: Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -26,9 +26,6 @@ class LoginPage extends StatefulWidget {
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
var _subLoading = false;
|
||||
|
||||
///协议
|
||||
bool _agree = false;
|
||||
|
||||
///谷歌登陆
|
||||
final GoogleSignIn _googleSignIn = GoogleSignIn.instance;
|
||||
|
||||
@@ -80,11 +77,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||
|
||||
///谷歌登录
|
||||
void _handleGoogleSignIn() async {
|
||||
if (!_agree) {
|
||||
EasyLoading.showToast('Please read and agree to the terms first.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果用户未登录,则启动标准的 Google 登录
|
||||
if (_googleSignIn.supportsAuthenticate()) {
|
||||
@@ -120,11 +112,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||
|
||||
///apple登录
|
||||
void _handAppleSignIn() async {
|
||||
if (!_agree) {
|
||||
EasyLoading.showToast('Please read and agree to the terms first.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final credential = await SignInWithApple.getAppleIDCredential(scopes: [AppleIDAuthorizationScopes.email, AppleIDAuthorizationScopes.fullName]);
|
||||
EasyLoading.show(status: "Logging in...");
|
||||
@@ -139,10 +126,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
|
||||
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");
|
||||
@@ -238,14 +221,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.only(top: 40),
|
||||
alignment: Alignment.center,
|
||||
child: AgreementBox(
|
||||
checked: _agree,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_agree = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
child: AgreementBox(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -6,68 +6,40 @@ import '../../../../router/config/route_paths.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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 25,
|
||||
child: Transform.scale(
|
||||
scale: 0.8,
|
||||
child: Checkbox(
|
||||
value: checked,
|
||||
shape: CircleBorder(),
|
||||
onChanged: (value) {
|
||||
onChanged(value!);
|
||||
},
|
||||
),
|
||||
return Text.rich(
|
||||
textAlign: TextAlign.center,
|
||||
TextSpan(
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
children: [
|
||||
const TextSpan(text: "By logging in, you agree to our "),
|
||||
TextSpan(
|
||||
text: "Terms",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () => context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "Terms of Service", "url": "https://support.curain.ai/privacy/foodcura/terms_service.html"},
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
onChanged(!checked);
|
||||
},
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "I agree to the ",
|
||||
),
|
||||
TextSpan(
|
||||
text: "Terms",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () => context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "Terms of Service", "url": "https://support.curain.ai/privacy/foodcura/terms_service.html"},
|
||||
),
|
||||
),
|
||||
TextSpan(text: " & "),
|
||||
TextSpan(
|
||||
text: "Privacy Policy",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () => context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "Privacy", "url": "https://support.curain.ai/privacy/foodcura/privacy_policy.html"},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const TextSpan(text: " and "),
|
||||
TextSpan(
|
||||
text: "Privacy Policy",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () => context.push(
|
||||
RoutePaths.agreement,
|
||||
extra: {"title": "Privacy", "url": "https://support.curain.ai/privacy/foodcura/privacy_policy.html"},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const TextSpan(text: "."),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ class LogoBox extends StatelessWidget {
|
||||
margin: EdgeInsets.only(bottom: 40),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/image/logo.png",
|
||||
width: 43,
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Image.asset(
|
||||
"assets/image/logo.png",
|
||||
width: 43,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"FoodCura",
|
||||
"PlanCura",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user