1
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user