import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/core/assets_const.dart'; import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; import 'package:wow_english/common/widgets/we_app_bar.dart'; import 'package:wow_english/pages/user/bloc/user_bloc.dart'; enum ModifyUserInformationType { avatar('头像'), name('名字'), age('年龄'), gender('性别'); const ModifyUserInformationType(this.title); final String title; } class ModifyUserInformationPage extends StatelessWidget { final ModifyUserInformationType type; const ModifyUserInformationPage({super.key, required this.type}); static push(BuildContext context, ModifyUserInformationType type) { Navigator.of(context).push(CupertinoPageRoute(builder: (context) { return ModifyUserInformationPage(type: type); })); } @override Widget build(BuildContext context) { return BlocProvider( create: (context) => UserBloc(), child: Scaffold( backgroundColor: Colors.white, appBar: WEAppBar( titleText: '修改${type.title}', ), body: BlocListener( listener: (context, state) { }, child: BlocBuilder(builder: (context, state) { //final bloc = context.read(); // 区别是什么? //BlocProvider.of(context); return SingleChildScrollView( child: Column( children: [ Padding( padding: EdgeInsets.only(left: 65.w, right: 55.w, top: 38.h), child: Row( children: [ Text( type.title, style: TextStyle( fontWeight: FontWeight.w700, color: const Color(0xFF333333), fontSize: 21.sp, ), ), 20.horizontalSpace, TextFieldCustomerWidget( height: 65.h, width: 222.w, bgImageName: 'Input_layer_up', textInputType: TextInputType.name, inputFormatters: [ LengthLimitingTextInputFormatter(12), FilteringTextInputFormatter.deny(RegExp('[ ]')), ], //controller: bloc.modifyTextController, /*onChangeValue: (String value) { bloc.add(CodeNumberChangeEvent()); },*/ ), Expanded( child: Container(), ), // 按钮 GestureDetector( onTap: () { // 更新type类型的字段 //bloc.add(UserUpdate(type)); }, child: Container( alignment: Alignment.center, width: 90.w, height: 44.h, decoration: BoxDecoration( image: DecorationImage(image: AssetImage(AssetsConst.bgButtonBlue), fit: BoxFit.fill), ), child: Text( '确定', style: TextStyle(fontSize: 17.sp, color: Colors.white), ), ), ) ], )), ], )); }), ), ), ); } }