diff --git a/lib/common/widgets/textfield_customer_widget.dart b/lib/common/widgets/textfield_customer_widget.dart index a435971..ab4593e 100644 --- a/lib/common/widgets/textfield_customer_widget.dart +++ b/lib/common/widgets/textfield_customer_widget.dart @@ -4,6 +4,20 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/extension/string_extension.dart'; class TextFieldCustomerWidget extends StatefulWidget { + final TextEditingController? controller; + final TextStyle? hitStyle; + final TextStyle? textStyle; + final String? bgImageName; + final String? hitText; + final double? width; + final double? height; + final TextAlign? textAlign; + final TextInputType? textInputType; + final bool? obscureText; + final Function(String value)? onChangeValue; + final List? inputFormatters; + final bool? enabel; + const TextFieldCustomerWidget({ super.key, this.controller, @@ -18,21 +32,9 @@ class TextFieldCustomerWidget extends StatefulWidget { this.obscureText, this.onChangeValue, this.inputFormatters, + this.enabel = true, }); - final TextEditingController? controller; - final TextStyle? hitStyle; - final TextStyle? textStyle; - final String? bgImageName; - final String? hitText; - final double? width; - final double? height; - final TextAlign? textAlign; - final TextInputType? textInputType; - final bool? obscureText; - final Function(String value)? onChangeValue; - final List? inputFormatters; - @override State createState() { return _TextFieldCustomerWidgetState(); @@ -52,6 +54,7 @@ class _TextFieldCustomerWidgetState extends State { fit: BoxFit.fill, )), child: TextField( + enabled: widget.enabel, inputFormatters: widget.inputFormatters, controller: widget.controller, textAlign: widget.textAlign ?? TextAlign.center, @@ -61,7 +64,8 @@ class _TextFieldCustomerWidgetState extends State { decoration: InputDecoration( hintText: widget.hitText ?? '', border: InputBorder.none, - hintStyle: widget.hitStyle ?? TextStyle(fontSize: 16.sp, color: const Color(0xFF999999))), + hintStyle: widget.hitStyle ?? + TextStyle(fontSize: 16.sp, color: const Color(0xFF999999))), style: widget.textStyle ?? TextStyle( color: const Color(0xFF333333), diff --git a/lib/pages/home/bloc.dart b/lib/pages/home/bloc.dart index 7d455df..eaf337d 100644 --- a/lib/pages/home/bloc.dart +++ b/lib/pages/home/bloc.dart @@ -1,6 +1,4 @@ import 'package:bloc/bloc.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import '../../common/core/app_config_helper.dart'; import '../../common/request/dao/system_dao.dart'; @@ -12,12 +10,22 @@ import 'state.dart'; class HomeBloc extends Bloc { HomeBloc() : super(HomeState().init()) { on(_init); + on(_exchangeSuccess); } + bool exchangeResult = false; + void _init(InitEvent event, Emitter emit) async { await _checkUpdate(emit); } + void _exchangeSuccess( + ExchangeSuccessEvent event, Emitter emit) async { + if (exchangeResult) { + emit(HomeState()); + } + } + Future _checkUpdate(Emitter emit) async { if (AppConfigHelper.checkedUpdate) { return; @@ -28,10 +36,12 @@ class HomeBloc extends Bloc { if (appVersionEntity == null) { return; } - Log.d("WQF _checkUpdate appVersionEntity: $appVersionEntity localVersion=$localVersion"); + Log.d( + "WQF _checkUpdate appVersionEntity: $appVersionEntity localVersion=$localVersion"); if (localVersion < int.parse(appVersionEntity.version ?? '0')) { emit(UpdateDialogState( - appVersionEntity.volType == UpdateStrategy.FORCE.name, appVersionEntity)); + appVersionEntity.volType == UpdateStrategy.FORCE.name, + appVersionEntity)); } } } diff --git a/lib/pages/home/event.dart b/lib/pages/home/event.dart index e16af4c..24abeb8 100644 --- a/lib/pages/home/event.dart +++ b/lib/pages/home/event.dart @@ -1,3 +1,5 @@ abstract class HomeEvent {} -class InitEvent extends HomeEvent {} \ No newline at end of file +class InitEvent extends HomeEvent {} + +class ExchangeSuccessEvent extends HomeEvent {} diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 12632b3..09c344c 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_app_update/azhon_app_update.dart'; import 'package:flutter_app_update/update_model.dart'; @@ -9,6 +8,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/models/app_version_entity.dart'; import 'package:wow_english/pages/home/state.dart'; import 'package:wow_english/pages/home/widgets/BaseHomeHeaderWidget.dart'; +import 'package:wow_english/pages/shop/exchane/bloc/exchange_lesson_bloc.dart'; import 'package:wow_english/pages/user/bloc/user_bloc.dart'; import '../../common/core/user_util.dart'; @@ -24,9 +24,9 @@ class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => - HomeBloc() - ..add(InitEvent()), + create: (BuildContext context) => HomeBloc() + ..add(InitEvent()) + ..add(ExchangeSuccessEvent()), child: Builder(builder: (context) => _HomePageView()), ); } @@ -36,12 +36,12 @@ class _HomePageView extends StatelessWidget { @override Widget build(BuildContext context) { return MultiBlocListener(listeners: [ - BlocListener(listener: (context, state) { - }), + BlocListener(listener: (context, state) {}), BlocListener( listener: (context, state) { if (state is UpdateDialogState) { - _showUpdateDialog(context, state.forceUpdate, state.appVersionEntity); + _showUpdateDialog( + context, state.forceUpdate, state.appVersionEntity); } }, ), @@ -49,24 +49,67 @@ class _HomePageView extends StatelessWidget { } Widget _homeView() => - BlocBuilder( - builder: (context, state) { - return Scaffold( - body: Container( - color: Colors.white, - child: Column( - children: [ - const BaseHomeHeaderWidget(), - Expanded( - child: Center( - child: Row( - children: [ - Expanded( - child: GestureDetector( + BlocBuilder(builder: (context, state) { + final bloc = BlocProvider.of(context); + return Scaffold( + body: Container( + color: Colors.white, + child: Column( + children: [ + BaseHomeHeaderWidget( + callBack: (value) => { + bloc.exchangeResult = value['exchange'], + bloc.add(ExchangeSuccessEvent()) + }), + Expanded( + child: Center( + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () { + _checkPermission(() { + pushNamed(AppRouteName.courseUnit) + .then((value) => { + if (value != null) + { + bloc.exchangeResult = + value['exchange'], + bloc.add(ExchangeSuccessEvent()) + } + }); + }, bloc); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + alignment: AlignmentDirectional.center, + children: [ + Image.asset('bg_frame_module'.assetPng, + width: 162.5.w, height: 203.5.h), + Center( + child: Image.asset( + 'pic_module_study'.assetPng, + width: 140.5.w, + height: 172.h), + ) + ]), + 10.verticalSpace, + Image.asset('label_module_study'.assetPng, + width: 124.w, height: 34.h), + ], + ), + ), + ), + Expanded( + child: BlocBuilder( + builder: (context, userState) { + return GestureDetector( onTap: () { _checkPermission(() { - pushNamed(AppRouteName.courseUnit); - }); + pushNamed(AppRouteName.games); + }, bloc); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -76,69 +119,31 @@ class _HomePageView extends StatelessWidget { children: [ Image.asset( 'bg_frame_module'.assetPng, - width: 162.5.w, height: 203.5.h), - Center( - child: Image.asset( - 'pic_module_study'.assetPng, - width: 140.5.w, - height: 172.h), - ) + width: 162.5.w, + height: 203.5.h), + Image.asset( + 'pic_module_game'.assetPng, + width: 140.5.w, + height: 172.h) ]), 10.verticalSpace, - Image.asset('label_module_study'.assetPng, + Image.asset('label_module_game'.assetPng, width: 124.w, height: 34.h), ], - ), - ), - ), - Expanded( - child: BlocBuilder( - builder: (context, userState) { - return GestureDetector( - onTap: () { - _checkPermission(() { - pushNamed(AppRouteName.games); - }); - }, - child: Column( - mainAxisAlignment: MainAxisAlignment - .center, - children: [ - Stack( - alignment: AlignmentDirectional - .center, - children: [ - Image.asset( - 'bg_frame_module' - .assetPng, - width: 162.5.w, - height: 203.5.h), - Image.asset( - 'pic_module_game' - .assetPng, - width: 140.5.w, - height: 172.h) - ]), - 10.verticalSpace, - Image.asset( - 'label_module_game'.assetPng, - width: 124.w, height: 34.h), - ], - )); - }), - ), - ], + )); + }), ), - ), - ) - ], - ), - ), - ); - }); - + ], + ), + ), + ) + ], + ), + ), + ); + }); - _checkPermission(VoidCallback onAllowed) { + _checkPermission(VoidCallback onAllowed, HomeBloc bloc) { if (UserUtil.isLogined()) { if (AppConfigHelper.shouldHidePay()) { onAllowed(); @@ -146,13 +151,18 @@ class _HomePageView extends StatelessWidget { if (UserUtil.hasPermission()) { onAllowed(); } else { - showTwoActionDialog('提示', '忽略', '去续费', - '您的课程已到期,请快快续费继续学习吧!', leftTap: () { - popPage(); - }, rightTap: () { - popPage(); - pushNamed(AppRouteName.shop); - }); + showTwoActionDialog('提示', '忽略', '去续费', '您的课程已到期,请快快续费继续学习吧!', + leftTap: () { + popPage(); + }, rightTap: () { + popPage(); + pushNamed(AppRouteName.shop).then((value) { + if (value != null) { + bloc.exchangeResult = value['exchange']; + bloc.add(ExchangeSuccessEvent()); + } + }); + }); } } } else { @@ -161,7 +171,6 @@ class _HomePageView extends StatelessWidget { } } - ///Flutter侧处理升级对话框 ///[forcedUpgrade] 是否强制升级 _showUpdateDialog(BuildContext context, bool forcedUpgrade, @@ -175,20 +184,15 @@ class _HomePageView extends StatelessWidget { onWillPop: () => Future.value(!forcedUpgrade), child: AlertDialog( title: const Text('发现新版本'), - content: Text( - appVersionEntity.remark ?? - '修复了一些已知问题'), + content: Text(appVersionEntity.remark ?? '修复了一些已知问题'), actions: [ TextButton( child: Text(forcedUpgrade ? '退出' : '取消'), - onPressed: () => - { - if (forcedUpgrade) { - AppConfigHelper.exitApp() - } else - { - Navigator.of(context).pop() - } + onPressed: () => { + if (forcedUpgrade) + {AppConfigHelper.exitApp()} + else + {Navigator.of(context).pop()} }, ), TextButton( @@ -208,8 +212,8 @@ class _HomePageView extends StatelessWidget { "ic_launcher", '', ); - AzhonAppUpdate.update(model).then((value) => - debugPrint('$value')); + AzhonAppUpdate.update(model) + .then((value) => debugPrint('$value')); if (!forcedUpgrade) { Navigator.of(context).pop(); } diff --git a/lib/pages/home/widgets/BaseHomeHeaderWidget.dart b/lib/pages/home/widgets/BaseHomeHeaderWidget.dart index 8d4795b..c1ecf71 100644 --- a/lib/pages/home/widgets/BaseHomeHeaderWidget.dart +++ b/lib/pages/home/widgets/BaseHomeHeaderWidget.dart @@ -10,10 +10,13 @@ import '../../../route/route.dart'; import '../../../utils/image_util.dart'; import '../../user/bloc/user_bloc.dart'; +typedef HeaderCallback = void Function(dynamic); + class BaseHomeHeaderWidget extends StatelessWidget { - const BaseHomeHeaderWidget({super.key, this.entity}); + const BaseHomeHeaderWidget({super.key, this.entity, this.callBack}); final CourseEntity? entity; + final HeaderCallback? callBack; @override Widget build(BuildContext context) { @@ -50,9 +53,7 @@ class BaseHomeHeaderWidget extends StatelessWidget { ), ), GestureDetector( - onTap: () { - onUserClick(); - }, + onTap: () => {onUserClick()}, child: Container( margin: const EdgeInsets.only(left: 7), padding: const EdgeInsets.all(4.0), @@ -83,10 +84,16 @@ class BaseHomeHeaderWidget extends StatelessWidget { !UserUtil.isLogined(), child: GestureDetector( onTap: () => { - pushNamed(AppRouteName.shop), + pushNamed(AppRouteName.shop).then((value) { + if (value != null) { + if (callBack == null) { + } else { + callBack!(value); + } + } + }) }, - child: Row( - children: [ + child: Row(children: [ Image( width: 20.0.w, height: 20.0.h, @@ -94,7 +101,9 @@ class BaseHomeHeaderWidget extends StatelessWidget { // 替换为你的图片资源路径 const SizedBox(width: 6.0), // 图片和文本之间的间隔 - Text('还剩${UserUtil.getRemainingValidity()}天'), + UserUtil.hasPermission() + ? Text('还剩${UserUtil.getRemainingValidity()}天') + : const Text('已过期'), ]), )), ScreenUtil().bottomBarHeight.horizontalSpace, @@ -103,12 +112,19 @@ class BaseHomeHeaderWidget extends StatelessWidget { }, ); } -} -void onUserClick() { - if (UserUtil.isLogined()) { - pushNamed(AppRouteName.user); - } else { - pushNamed(AppRouteName.login); + void onUserClick() { + if (UserUtil.isLogined()) { + pushNamed(AppRouteName.user).then((value) { + if (value != null) { + if (callBack == null) { + } else { + callBack!(value); + } + } + }); + } else { + pushNamed(AppRouteName.login); + } } } diff --git a/lib/pages/login/forgetpwd/bloc/forget_pwd_home_bloc.dart b/lib/pages/login/forgetpwd/bloc/forget_pwd_home_bloc.dart index 1d34c74..0d68da6 100644 --- a/lib/pages/login/forgetpwd/bloc/forget_pwd_home_bloc.dart +++ b/lib/pages/login/forgetpwd/bloc/forget_pwd_home_bloc.dart @@ -1,50 +1,33 @@ import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:wow_english/common/request/dao/user_dao.dart'; import 'package:wow_english/common/request/exception.dart'; import 'package:wow_english/utils/loading.dart'; import 'package:wow_english/utils/toast_util.dart'; +import 'package:wow_english/common/core/user_util.dart'; + part 'forget_pwd_home_event.dart'; part 'forget_pwd_home_state.dart'; class ForgetPwdHomeBloc extends Bloc { - ///是否可以发送验证码 - bool _canSendSms = false; bool _canSetPwd = false; - bool get canSendSms => _canSendSms; - bool get canSetPwd => _canSetPwd; - final TextEditingController phoneNumController = TextEditingController(); + final TextEditingController phoneNumController = + TextEditingController(text: UserUtil.getUser()?.phoneNum); final TextEditingController checkNumController = TextEditingController(); - ForgetPwdHomeBloc() : super(ForgetPwdHomeInitial()) { - on(_changePhoneNumber); on(_changeCodeNumber); on(_setPassWord); on(_sendSmsCode); } - void _changePhoneNumber(PhoneNumChangeEvent event, Emitter emitter) async { - if (phoneNumController.text.isNotEmpty) { - if (!_canSendSms) { - _canSendSms = true; - emitter(SendSmsCodeTypeChangeState()); - emitter(SetPwdTypeChangeState()); - } - } else { - if (_canSendSms) { - _canSendSms = false; - emitter(SendSmsCodeTypeChangeState()); - emitter(SetPwdTypeChangeState()); - } - } - } - - void _changeCodeNumber(CheckCodeChangeEvent event, Emitter emitter) async { + void _changeCodeNumber( + CheckCodeChangeEvent event, Emitter emitter) async { if (checkNumController.text.isNotEmpty) { if (!_canSetPwd) { _canSetPwd = true; @@ -60,7 +43,8 @@ class ForgetPwdHomeBloc extends Bloc { } } - void _setPassWord(SetPassWordEvent event, Emitter emitter) async { + void _setPassWord( + SetPassWordEvent event, Emitter emitter) async { if (!RegexUtil.isMobileExact(phoneNumController.text)) { showToast('手机号不正确!'); return; @@ -68,7 +52,8 @@ class ForgetPwdHomeBloc extends Bloc { emitter(SetPwdCheckCodeState()); } - void _sendSmsCode(SendSmsCodeEvent event, Emitter emitter) async { + void _sendSmsCode( + SendSmsCodeEvent event, Emitter emitter) async { final phoneNumber = phoneNumController.text; if (!RegexUtil.isMobileExact(phoneNumber)) { showToast('请检查手机号'); @@ -76,12 +61,12 @@ class ForgetPwdHomeBloc extends Bloc { } try { await loading(() async { - await UserDao.sendCode(phoneNumber,smsType:'change_passWord'); + await UserDao.sendCode(phoneNumber, smsType: 'change_passWord'); }); emitter(SendSmsCodeState()); } catch (e) { - if(e is ApiException) { - showToast(e.message??'网络请求失败'); + if (e is ApiException) { + showToast(e.message ?? '网络请求失败'); } } } diff --git a/lib/pages/login/forgetpwd/bloc/forget_pwd_home_event.dart b/lib/pages/login/forgetpwd/bloc/forget_pwd_home_event.dart index 0be0181..eb85784 100644 --- a/lib/pages/login/forgetpwd/bloc/forget_pwd_home_event.dart +++ b/lib/pages/login/forgetpwd/bloc/forget_pwd_home_event.dart @@ -3,8 +3,6 @@ part of 'forget_pwd_home_bloc.dart'; @immutable abstract class ForgetPwdHomeEvent {} -class PhoneNumChangeEvent extends ForgetPwdHomeEvent {} - class CheckCodeChangeEvent extends ForgetPwdHomeEvent {} class SetPassWordEvent extends ForgetPwdHomeEvent {} diff --git a/lib/pages/login/forgetpwd/forget_password_home_page.dart b/lib/pages/login/forgetpwd/forget_password_home_page.dart index fc6d0f4..d75a2fe 100644 --- a/lib/pages/login/forgetpwd/forget_password_home_page.dart +++ b/lib/pages/login/forgetpwd/forget_password_home_page.dart @@ -31,54 +31,55 @@ class _ForgetPasswordHomePageView extends StatelessWidget { var bloc = context.read(); var phoneNum = bloc.phoneNumController.text; var smsCode = bloc.checkNumController.text; - if (phoneNum.isEmpty) { - '请输入手机号'.toast(); - return; - } if (smsCode.isEmpty) { '请输入验证码'.toast(); return; } // todo 后续需要改成在当前页面,验证过验证码后,再跳转到设置密码页面 // change_passWord - SetPassWordPage.push(context, SetPwdPageType.resetPwd, phoneNum: phoneNum, smsCode: smsCode); + SetPassWordPage.push(context, SetPwdPageType.resetPwd, + phoneNum: phoneNum, smsCode: smsCode); } }, child: _buildForgetPwdView(), ); } - Widget _buildForgetPwdView() => BlocBuilder(builder: (context, state) { - final bloc = BlocProvider.of(context); - return Scaffold( - appBar: const WEAppBar(), - body: Container( - color: Colors.white, - child: SafeArea( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(left: 49.w, right: 10.w), - child: Column( - children: [ - Row( + Widget _buildForgetPwdView() => + BlocBuilder( + builder: (context, state) { + final bloc = BlocProvider.of(context); + return Scaffold( + appBar: const WEAppBar(), + body: Container( + color: Colors.white, + child: SafeArea( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.only(left: 49.w, right: 10.w), + child: Column( children: [ - Image.asset( - 'wow_logo'.assetPng, - height: 49.w, - width: 83.5.h, + Row( + children: [ + Image.asset( + 'wow_logo'.assetPng, + height: 49.w, + width: 83.5.h, + ), + 12.5.horizontalSpace, + Text( + '修改密码\n请输入您的手机号和验证码吧', + style: TextStyle( + fontSize: 16.sp, + color: const Color(0xFF666666)), + ) + ], ), - 12.5.horizontalSpace, - Text( - '修改密码\n请输入您的手机号和验证码吧', - style: TextStyle(fontSize: 16.sp, color: const Color(0xFF666666)), - ) - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( children: [ 44.5.verticalSpace, Row( @@ -91,20 +92,23 @@ class _ForgetPasswordHomePageView extends StatelessWidget { 15.horizontalSpace, Expanded( child: TextFieldCustomerWidget( - height: 50.h, - hitText: '请输入当前手机号', - textInputType: TextInputType.phone, - bgImageName: 'Input_layer_up', - onChangeValue: (String value) { - bloc.add(PhoneNumChangeEvent()); - }, - controller: bloc.phoneNumController, - )) + height: 50.h, + textStyle: TextStyle( + fontWeight: FontWeight.w500, + color: const Color(0xFF999999), + fontSize: 21.sp, + ), + textInputType: TextInputType.phone, + bgImageName: 'Input_layer_up', + enabel: false, + controller: bloc.phoneNumController, + )) ], ), 11.5.verticalSpace, Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Image.asset( 'lock'.assetPng, @@ -114,57 +118,62 @@ class _ForgetPasswordHomePageView extends StatelessWidget { 18.5.horizontalSpace, Expanded( child: TextFieldCustomerWidget( - hitText: '请输入验证码', - bgImageName: 'Input_layer_down', - onChangeValue: (String value) { - bloc.add(CheckCodeChangeEvent()); - }, - textInputType: TextInputType.emailAddress, - controller: bloc.checkNumController, - )), + hitText: '请输入验证码', + bgImageName: 'Input_layer_down', + onChangeValue: (String value) { + bloc.add(CheckCodeChangeEvent()); + }, + textInputType: TextInputType.emailAddress, + controller: bloc.checkNumController, + )), 16.5.horizontalSpace, TimerWidget( pageType: 1, - canSendSms: bloc.canSendSms, - sendSmsEvent: () => bloc.add(SendSmsCodeEvent()), + canSendSms: true, + sendSmsEvent: () => + bloc.add(SendSmsCodeEvent()), ) ], ) ], )), - 2.verticalSpace, - Image.asset( - 'steven_bride'.assetPng, - height: 173.h, - width: 157.w, + 2.verticalSpace, + Image.asset( + 'steven_bride'.assetPng, + height: 173.h, + width: 157.w, + ) + ], + ), + GestureDetector( + onTap: () { + if (bloc.canSetPwd) { + bloc.add(SetPassWordEvent()); + } + }, + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(bloc.canSetPwd + ? 'login_enter'.assetPng + : 'login_enter_dis'.assetPng), + fit: BoxFit.fill), + ), + padding: EdgeInsets.symmetric( + horizontal: 28.w, vertical: 14.h), + child: Text( + '确定', + style: + TextStyle(fontSize: 16.sp, color: Colors.white), + ), + ), ) ], ), - GestureDetector( - onTap: () { - if (bloc.canSetPwd) { - bloc.add(SetPassWordEvent()); - } - }, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage(bloc.canSetPwd ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng), - fit: BoxFit.fill), - ), - padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h), - child: Text( - '确定', - style: TextStyle(fontSize: 16.sp, color: Colors.white), - ), - ), - ) - ], + ), ), ), ), - ), - ), - ); - }); + ); + }); } diff --git a/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart b/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart index c1f1b17..10c7ff9 100644 --- a/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart +++ b/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart @@ -1,17 +1,22 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:wow_english/common/request/dao/user_dao.dart'; import 'package:wow_english/utils/loading.dart'; +import 'package:wow_english/common/core/user_util.dart'; +import 'package:wow_english/models/user_entity.dart'; + import '../../../../common/request/dao/request_dao.dart'; part 'exchange_lesson_event.dart'; part 'exchange_lesson_state.dart'; -class ExchangeLessonBloc extends Bloc { - +class ExchangeLessonBloc + extends Bloc { final TextEditingController codeNumberController = TextEditingController(); bool _checkCode = false; + bool exchangeSuccess = false; bool get checkCode => _checkCode; @@ -20,8 +25,9 @@ class ExchangeLessonBloc extends Bloc on(_requestCheckCode); } - _codeNumberChange(CodeNumberChangeEvent event,Emitter emitter) async { - if(codeNumberController.text.isNotEmpty) { + _codeNumberChange( + CodeNumberChangeEvent event, Emitter emitter) async { + if (codeNumberController.text.isNotEmpty) { if (!_checkCode) { _checkCode = true; emitter(CheckCodeTypeChangeState()); @@ -34,13 +40,23 @@ class ExchangeLessonBloc extends Bloc } } - _requestCheckCode(CheckCodeEvent event, Emitter emitter) async { + _requestCheckCode( + CheckCodeEvent event, Emitter emitter) async { try { await loading(() async { await RequestDao.exchange(codeNumberController.text); + // 更新本地数据 + UserEntity? userEntity = await UserDao.getUserInfo(); + final token = UserUtil.getUser()?.token; + if (userEntity != null) { + userEntity.token = token; + UserUtil.saveUser(userEntity); + } + exchangeSuccess = true; emitter(CheckCodeResultState(true)); }); } catch (e) { + exchangeSuccess = false; emitter(CheckCodeResultState(false)); } } diff --git a/lib/pages/shop/exchane/exchange_lesson_page.dart b/lib/pages/shop/exchane/exchange_lesson_page.dart index 531c99f..ea60068 100644 --- a/lib/pages/shop/exchane/exchange_lesson_page.dart +++ b/lib/pages/shop/exchane/exchange_lesson_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; +import 'package:wow_english/pages/home/event.dart'; import 'package:wow_english/pages/shop/exchane/widegts/exchange_result_dialog.dart'; import 'package:wow_english/route/route.dart'; @@ -27,6 +28,8 @@ class _ExchangeLessonPage extends StatelessWidget { return BlocListener( listener: (context, state) { if (state is CheckCodeResultState) { + final bloc = BlocProvider.of(context); + bloc.exchangeSuccess = state.result; showDialog( context: context, barrierDismissible: !state.result, @@ -34,7 +37,7 @@ class _ExchangeLessonPage extends StatelessWidget { return ExChangeResultDialog( resultType: state.result, onTap: () { - popPage(); + popPage(data: {'exchange': bloc.exchangeSuccess}); }); }); } @@ -117,12 +120,15 @@ class _ExchangeLessonPage extends StatelessWidget { ], ), ), - const Positioned( + Positioned( top: 0, left: 0, right: 0, child: WEAppBar( backgroundColor: Colors.transparent, + onBack: () { + popPage(data: {'exchange': bloc.exchangeSuccess}); + }, ), ), ], diff --git a/lib/pages/shop/home/bloc/shop_home_bloc.dart b/lib/pages/shop/home/bloc/shop_home_bloc.dart index 6a97c42..dd04b6e 100644 --- a/lib/pages/shop/home/bloc/shop_home_bloc.dart +++ b/lib/pages/shop/home/bloc/shop_home_bloc.dart @@ -1,3 +1,4 @@ +import 'dart:ffi'; import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; @@ -12,11 +13,12 @@ part 'shop_home_event.dart'; part 'shop_home_state.dart'; class ShopHomeBloc extends Bloc { - List _productDatas = []; List get productDatas => _productDatas; + bool exchangeResult = false; + ShopHomeBloc() : super(ShopHomeInitial()) { on((event, emit) { // TODO: implement event handler @@ -24,7 +26,8 @@ class ShopHomeBloc extends Bloc { on(_requestData); } - void _requestData(RequestDataEvent event, Emitter emitter) async { + void _requestData( + RequestDataEvent event, Emitter emitter) async { try { await loading(() async { _productDatas = await ShopDao.productList() ?? []; diff --git a/lib/pages/shop/home/shop_home_page.dart b/lib/pages/shop/home/shop_home_page.dart index 638b19e..481e22e 100644 --- a/lib/pages/shop/home/shop_home_page.dart +++ b/lib/pages/shop/home/shop_home_page.dart @@ -44,7 +44,10 @@ class _ShopHomeView extends StatelessWidget { ), color: Colors.white, onPressed: () { - Navigator.of(context).pushNamed(AppRouteName.exLesson); + pushNamed(AppRouteName.exLesson).then((value) => { + if (value != null) + {bloc.exchangeResult = value['exchange']} + }); }, ), IconButton( @@ -59,6 +62,9 @@ class _ShopHomeView extends StatelessWidget { }, ) ], + onBack: () { + popPage(data: {'exchange': bloc.exchangeResult}); + }, ), body: Center( child: Padding( @@ -73,9 +79,11 @@ class _ShopHomeView extends StatelessWidget { ), itemBuilder: (BuildContext context, int index) { final productEntity = bloc.productDatas[index]; - return ProductItem(onTap: () { - pushNamed(AppRouteName.pay, arguments: productEntity); - }, entity: productEntity); + return ProductItem( + onTap: () { + pushNamed(AppRouteName.pay, arguments: productEntity); + }, + entity: productEntity); }), ), ), diff --git a/lib/pages/unit/bloc.dart b/lib/pages/unit/bloc.dart index b791c82..7609fdc 100644 --- a/lib/pages/unit/bloc.dart +++ b/lib/pages/unit/bloc.dart @@ -12,7 +12,6 @@ import 'event.dart'; import 'state.dart'; class UnitBloc extends Bloc { - CourseModuleEntity? _moduleEntity; CourseModuleEntity? get moduleEntity => _moduleEntity; @@ -21,12 +20,14 @@ class UnitBloc extends Bloc { CourseUnitEntity? get unitData => _unitData; + bool exchangeResult = false; UnitBloc(CourseModuleEntity? courseEntity) : super(UnitState().init()) { on(_requestUnitDatas); } - void _requestUnitDatas(RequestUnitDataEvent event, Emitter emitter) async { + void _requestUnitDatas( + RequestUnitDataEvent event, Emitter emitter) async { try { await loading(() async { _unitData = await LessonDao.courseUnit(event.moduleId); @@ -51,7 +52,8 @@ class UnitBloc extends Bloc { } else if (type == HeaderActionType.listen) { pushNamed(AppRouteName.listen); } else if (type == HeaderActionType.shop) { - pushNamed(AppRouteName.shop); + pushNamed(AppRouteName.shop) + .then((value) => {exchangeResult = value['exchange']}); } else if (type == HeaderActionType.user) { pushNamed(AppRouteName.user); } diff --git a/lib/pages/unit/view.dart b/lib/pages/unit/view.dart index ed7f07c..bb3d3f6 100644 --- a/lib/pages/unit/view.dart +++ b/lib/pages/unit/view.dart @@ -40,6 +40,9 @@ class UnitPage extends StatelessWidget { children: [ HomeTabHeaderWidget( courseModuleCode: bloc.getCourseModuleCode(), + onBack: () { + popPage(data: {'exchange': bloc.exchangeResult}); + }, actionTap: (HeaderActionType type) { bloc.headerActionEvent(type); }, @@ -67,10 +70,12 @@ class UnitPage extends StatelessWidget { 'courseUnitId': data.id }).then((value) { if (value != null) { - Map dataMap = value as Map; + Map dataMap = + value as Map; bool needRefresh = dataMap['needRefresh']; if (needRefresh) { - bloc.add(RequestUnitDataEvent(courseModuleEntity?.id)); + bloc.add(RequestUnitDataEvent( + courseModuleEntity?.id)); } } }); diff --git a/lib/pages/unit/widget/home_tab_header_widget.dart b/lib/pages/unit/widget/home_tab_header_widget.dart index 3dc6223..4436510 100644 --- a/lib/pages/unit/widget/home_tab_header_widget.dart +++ b/lib/pages/unit/widget/home_tab_header_widget.dart @@ -21,12 +21,13 @@ enum HeaderActionType { } class HomeTabHeaderWidget extends StatelessWidget { - const HomeTabHeaderWidget({super.key, this.courseModuleCode, this.actionTap}); + const HomeTabHeaderWidget( + {super.key, this.courseModuleCode, this.actionTap, this.onBack}); final String? courseModuleCode; final Function(HeaderActionType type)? actionTap; - + final VoidCallback? onBack; @override Widget build(BuildContext context) { return BlocBuilder( @@ -34,15 +35,18 @@ class HomeTabHeaderWidget extends StatelessWidget { return Container( height: 45, width: double.infinity, - color: - CourseModuleModel(courseModuleCode ?? 'Phase-1').color, + color: CourseModuleModel(courseModuleCode ?? 'Phase-1').color, padding: EdgeInsets.symmetric(horizontal: 9.5.w), child: Row( children: [ ScreenUtil().bottomBarHeight.horizontalSpace, GestureDetector( onTap: () { - Navigator.pop(context); + if (onBack == null) { + Navigator.pop(context); + } else { + onBack!(); + } }, child: Container( alignment: Alignment.center, @@ -65,21 +69,25 @@ class HomeTabHeaderWidget extends StatelessWidget { onTap: () { if (actionTap != null) { actionTap!(HeaderActionType.phase); - }; + } }, - child: Image(image: AssetImage('home'.assetPng), - width: 36.0.w, height: 36.0.h, fit: BoxFit.contain) - ), + child: Image( + image: AssetImage('home'.assetPng), + width: 36.0.w, + height: 36.0.h, + fit: BoxFit.contain)), 8.horizontalSpace, GestureDetector( - onTap: () { - if (actionTap != null) { - actionTap!(HeaderActionType.listen); - }; - }, - child: Image(image: AssetImage('listen'.assetPng), - width: 36.0.w, height: 36.0.h, fit: BoxFit.contain) - ), + onTap: () { + if (actionTap != null) { + actionTap!(HeaderActionType.listen); + } + }, + child: Image( + image: AssetImage('listen'.assetPng), + width: 36.0.w, + height: 36.0.h, + fit: BoxFit.contain)), 8.horizontalSpace, Offstage( offstage: AppConfigHelper.shouldHidePay(), @@ -87,11 +95,13 @@ class HomeTabHeaderWidget extends StatelessWidget { onTap: () { if (actionTap != null) { actionTap!(HeaderActionType.shop); - }; + } }, - child: Image(image: AssetImage('shop'.assetPng), - width: 36.0.w, height: 36.0.h, fit: BoxFit.contain) - ), + child: Image( + image: AssetImage('shop'.assetPng), + width: 36.0.w, + height: 36.0.h, + fit: BoxFit.contain)), ), ScreenUtil().bottomBarHeight.horizontalSpace, ], diff --git a/lib/pages/user/bloc/user_bloc.dart b/lib/pages/user/bloc/user_bloc.dart index 5059e9d..9aeefdc 100644 --- a/lib/pages/user/bloc/user_bloc.dart +++ b/lib/pages/user/bloc/user_bloc.dart @@ -16,6 +16,7 @@ class UserBloc extends Bloc { UserEntity? get userEntityForPay => _userEntityForPay; + bool exchangeResult = false; UserBloc() : super(UserInitial()) { on(_logout); on(_deleteAccount); @@ -37,7 +38,8 @@ class UserBloc extends Bloc { } void _updateUser(UserUpdate event, Emitter emitter) async { - Log.d('_updateUser, event: ${event.type}, emitter.isDone: ${emitter.isDone}, text=${event.content}'); + Log.d( + '_updateUser, event: ${event.type}, emitter.isDone: ${emitter.isDone}, text=${event.content}'); UserEntity user = UserUtil.getUser()!; try { switch (event.type) { @@ -84,7 +86,8 @@ class UserBloc extends Bloc { } //支付状态变化 - void _patStateChanged(PayStateChangeEvent event, Emitter emitter) async { + void _patStateChanged( + PayStateChangeEvent event, Emitter emitter) async { // 由于userInfo接口不会返回token,所以这里需要再次保存一下token final token = UserUtil.getUser()?.token; _userEntityForPay = await UserDao.getUserInfo(); diff --git a/lib/pages/user/user_page.dart b/lib/pages/user/user_page.dart index 4387097..dbec0fd 100644 --- a/lib/pages/user/user_page.dart +++ b/lib/pages/user/user_page.dart @@ -29,7 +29,8 @@ class _UserView extends StatelessWidget { final String bannerUrl = ''; /// 方法 - final MethodChannel methodChannel = const MethodChannel('wow_english/game_method_channel'); + final MethodChannel methodChannel = + const MethodChannel('wow_english/game_method_channel'); @override Widget build(BuildContext context) { @@ -37,34 +38,41 @@ class _UserView extends StatelessWidget { } Widget _pageWidget() => BlocBuilder( - builder: (context, state) { - UserEntity user = UserUtil.getUser()!; - final userBloc = BlocProvider.of(context); + builder: (context, state) { + UserEntity user = UserUtil.getUser()!; + final userBloc = BlocProvider.of(context); - // 常规按钮的字体样式 - final textStyle21sp = TextStyle( - //fontWeight: FontWeight.w600, - color: const Color(0xFF333333), - fontSize: 21.sp, - ); + // 常规按钮的字体样式 + final textStyle21sp = TextStyle( + //fontWeight: FontWeight.w600, + color: const Color(0xFF333333), + fontSize: 21.sp, + ); - // 常规按钮的样式 - var normalButtonStyle = ButtonStyle( - side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5.w)), - shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.r))), - minimumSize: MaterialStateProperty.all(Size(double.infinity, 58.h)), - backgroundColor: MaterialStateProperty.all(Colors.white), - ); + // 常规按钮的样式 + var normalButtonStyle = ButtonStyle( + side: MaterialStateProperty.all( + BorderSide(color: const Color(0xFF140C10), width: 1.5.w)), + shape: MaterialStateProperty.all(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15.r))), + minimumSize: MaterialStateProperty.all(Size(double.infinity, 58.h)), + backgroundColor: MaterialStateProperty.all(Colors.white), + ); - return Scaffold( - appBar: const WEAppBar(), - body: SingleChildScrollView( - padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // todo banner,暂时没有接口获取banner URL - /*Offstage( + return Scaffold( + appBar: WEAppBar( + onBack: () { + popPage(data: {'exchange': userBloc.exchangeResult}); + }, + ), + body: SingleChildScrollView( + padding: EdgeInsets.only( + left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // todo banner,暂时没有接口获取banner URL + /*Offstage( child: Column( children: [ Container(child: Image.asset(bannerUrl), constraints: BoxConstraints(maxHeight: 196.h)), @@ -72,23 +80,25 @@ class _UserView extends StatelessWidget { ], ), ),*/ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CircleAvatar( - radius: 40.r, - backgroundColor: const Color(0xFF140C10), - child: CircleAvatar( - radius: 38.5.r, - backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl), - ), - /*child: ClipOval( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CircleAvatar( + radius: 40.r, + backgroundColor: const Color(0xFF140C10), + child: CircleAvatar( + radius: 38.5.r, + backgroundImage: + ImageUtil.getImageProviderOnDefault( + user.avatarUrl), + ), + /*child: ClipOval( child: OwImageWidget(name: user.avatarUrl ?? AssetsConst.wowLogo, fit: BoxFit.contain,), )*/ - ), - 32.horizontalSpace, - Expanded( - child: Column( + ), + 32.horizontalSpace, + Expanded( + child: Column( children: [ Row( children: [ @@ -108,7 +118,8 @@ class _UserView extends StatelessWidget { ), 14.horizontalSpace, Offstage( - offstage: user.effectiveDate == null || AppConfigHelper.shouldHidePay(), + offstage: user.effectiveDate == null || + AppConfigHelper.shouldHidePay(), child: Image.asset( AssetsConst.icVip, height: 18.h, @@ -117,7 +128,8 @@ class _UserView extends StatelessWidget { ], ), Offstage( - offstage: user.effectiveDate == null || AppConfigHelper.shouldHidePay(), + offstage: user.effectiveDate == null || + AppConfigHelper.shouldHidePay(), child: Row( children: [ Text( @@ -132,132 +144,158 @@ class _UserView extends StatelessWidget { ) ], )), - TextButton( + TextButton( + child: Text( + "修改个人信息>", + style: textStyle21sp, + ), + onPressed: () { + pushNamed(AppRouteName.userInformation); + }, + ) + ], + ), + 30.verticalSpace, + // 打开游戏界面 供审核用 + ((UserUtil.getUser()?.phoneNum == '17730280759' || + UserUtil.getUser()?.phoneNum == '17718485544') + ? OutlinedButton( + onPressed: () { + methodChannel + .invokeMethod('openGamePage', {"gameId": 1}); + }, + style: normalButtonStyle, + child: Text( + "进入游戏", + style: textStyle21sp, + ), + ) + : 1.verticalSpace), + ((UserUtil.getUser()?.phoneNum == '17730280759' || + UserUtil.getUser()?.phoneNum == '17718485544') + ? 12.verticalSpace + : 1.verticalSpace), + OutlinedButton( + onPressed: () => pushNamed(AppRouteName.fogPwd), + style: normalButtonStyle, child: Text( - "修改个人信息>", + "修改密码", style: textStyle21sp, ), - onPressed: () { - pushNamed(AppRouteName.userInformation); - }, - ) + ), + 12.verticalSpace, + Offstage( + offstage: AppConfigHelper.shouldHidePay(), + child: OutlinedButton( + onPressed: () => + pushNamed(AppRouteName.exLesson).then((value) => { + if (value != null) + { + userBloc.exchangeResult = + value['exchange'] + } + }), + style: normalButtonStyle, + child: Text( + "兑换课程", + style: textStyle21sp, + )), + ), + Offstage( + offstage: AppConfigHelper.shouldHidePay(), + child: 12.verticalSpace, + ), + OutlinedButton( + onPressed: () { + pushNamed(AppRouteName.webView, arguments: { + 'urlStr': AppConsts.userPrivacyPolicyUrl, + 'webViewTitle': '隐私协议' + }); + }, + style: normalButtonStyle, + child: Text( + "隐私协议", + style: textStyle21sp, + )), + 12.verticalSpace, + OutlinedButton( + onPressed: () { + String phone = 'tel:+8618856084180'; + _launchPhone(phone); + }, + style: normalButtonStyle, + child: Text( + "联系客服", + style: textStyle21sp, + )), + 12.verticalSpace, + OutlinedButton( + onPressed: () { + pushNamed(AppRouteName.setting); + }, + style: normalButtonStyle, + child: Text( + "设置", + style: textStyle21sp, + )), + 30.verticalSpace, + OutlinedButton( + onPressed: () { + showTwoActionDialog( + barrierDismissible: false, + '提示', + '取消', + '确认', + '您确认要退出Wow English吗?', leftTap: () { + popPage(); + }, rightTap: () { + popPage(); + userBloc.add(UserLogout()); + }); + }, + style: ButtonStyle( + side: MaterialStateProperty.all(const BorderSide( + color: Color(0xFF140C10), width: 1.5)), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15.r))), + minimumSize: + MaterialStateProperty.all(Size(295.w, 40.h)), + backgroundColor: MaterialStateProperty.all( + const Color(0xFFFBB621)), + ), + child: Text( + "退出登录", + style: TextStyle( + //fontWeight: FontWeight.w600, + color: Colors.white, + fontSize: 17.sp, + ), + )), + // 30.verticalSpace, + // TextButton( + // onPressed: () { + // //userBloc.add(UserDelete()) + // showTwoActionDialog('注销账号', '取消', '注销', '请谨慎操作!\n注销后不可恢复哦!', () { + // popPage(); + // }, () { + // userBloc.add(UserDelete()); + // popPage(); + // }); + // }, + // child: Text( + // "注销账号", + // style: TextStyle( + // //fontWeight: FontWeight.w600, + // color: Colors.red, + // fontSize: 15.sp, + // ), + // )), ], ), - 30.verticalSpace, - // 打开游戏界面 供审核用 - ((UserUtil.getUser()?.phoneNum == '17730280759' || UserUtil.getUser()?.phoneNum == '17718485544') ? OutlinedButton( - onPressed: () { - methodChannel.invokeMethod('openGamePage', { "gameId": 1 }); - }, - style: normalButtonStyle, - child: Text( - "进入游戏", - style: textStyle21sp, - ), - ) : 1.verticalSpace), - ((UserUtil.getUser()?.phoneNum == '17730280759' || UserUtil.getUser()?.phoneNum == '17718485544') ? 12.verticalSpace : 1.verticalSpace), - OutlinedButton( - onPressed: () => pushNamed(AppRouteName.fogPwd), - style: normalButtonStyle, - child: Text( - "修改密码", - style: textStyle21sp, - ), - ), - 12.verticalSpace, - Offstage( - offstage: AppConfigHelper.shouldHidePay(), - child: OutlinedButton( - onPressed: () => pushNamed(AppRouteName.exLesson), - style: normalButtonStyle, - child: Text( - "兑换课程", - style: textStyle21sp, - )), - ), - Offstage( - offstage: AppConfigHelper.shouldHidePay(), - child: 12.verticalSpace, - ), - OutlinedButton( - onPressed: () { - pushNamed(AppRouteName.webView,arguments: {'urlStr': AppConsts.userPrivacyPolicyUrl, 'webViewTitle': '隐私协议'}); - }, - style: normalButtonStyle, - child: Text( - "隐私协议", - style: textStyle21sp, - )), - 12.verticalSpace, - OutlinedButton( - onPressed: () { - String phone ='tel:+8618856084180'; - _launchPhone(phone); - }, - style: normalButtonStyle, - child: Text( - "联系客服", - style: textStyle21sp, - )), - 12.verticalSpace, - OutlinedButton( - onPressed: () { - pushNamed(AppRouteName.setting); - }, - style: normalButtonStyle, - child: Text( - "设置", - style: textStyle21sp, - )), - 30.verticalSpace, - OutlinedButton( - onPressed: () { - showTwoActionDialog(barrierDismissible:false,'提示', '取消', '确认', '您确认要退出Wow English吗?',leftTap: (){ - popPage(); - },rightTap: (){ - popPage(); - userBloc.add(UserLogout()); - }); - }, - style: ButtonStyle( - side: MaterialStateProperty.all(const BorderSide(color: Color(0xFF140C10), width: 1.5)), - shape: MaterialStateProperty.all( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.r))), - minimumSize: MaterialStateProperty.all(Size(295.w, 40.h)), - backgroundColor: MaterialStateProperty.all(const Color(0xFFFBB621)), - ), - child: Text( - "退出登录", - style: TextStyle( - //fontWeight: FontWeight.w600, - color: Colors.white, - fontSize: 17.sp, - ), - )), - // 30.verticalSpace, - // TextButton( - // onPressed: () { - // //userBloc.add(UserDelete()) - // showTwoActionDialog('注销账号', '取消', '注销', '请谨慎操作!\n注销后不可恢复哦!', () { - // popPage(); - // }, () { - // userBloc.add(UserDelete()); - // popPage(); - // }); - // }, - // child: Text( - // "注销账号", - // style: TextStyle( - // //fontWeight: FontWeight.w600, - // color: Colors.red, - // fontSize: 15.sp, - // ), - // )), - ], - ), - )); - }, - ); + )); + }, + ); void _launchPhone(String phone) async { if (await canLaunchUrl(Uri.parse(phone))) {