|
@@ -1,10 +1,11 @@ |
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter_bloc/flutter_bloc.dart'; |
|
|
import 'package:flutter_bloc/flutter_bloc.dart'; |
|
|
import 'package:provider/provider.dart'; |
|
|
import 'package:provider/provider.dart'; |
|
|
import 'package:zhiying_comm/pages/login_page/model/login_model.dart'; |
|
|
import 'package:zhiying_comm/pages/login_page/model/login_model.dart'; |
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart'; |
|
|
|
|
|
import 'package:zhiying_comm/util/empty_util.dart'; |
|
|
import 'package:zhiying_comm/util/empty_util.dart'; |
|
|
|
|
|
import 'package:zhiying_comm/util/mob_util/mob_util.dart'; |
|
|
|
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
|
|
|
import 'bloc/bloc.dart'; |
|
|
import 'bloc/bloc.dart'; |
|
|
import 'bloc/login_invite_repository.dart'; |
|
|
import 'bloc/login_invite_repository.dart'; |
|
@@ -20,7 +21,8 @@ class LoginInvitePage extends StatelessWidget { |
|
|
resizeToAvoidBottomInset: false, |
|
|
resizeToAvoidBottomInset: false, |
|
|
backgroundColor: HexColor.fromHex('#FFFFFF'), |
|
|
backgroundColor: HexColor.fromHex('#FFFFFF'), |
|
|
body: BlocProvider( |
|
|
body: BlocProvider( |
|
|
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository())..add(LoginInviteInitEvent()), |
|
|
|
|
|
|
|
|
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository()) |
|
|
|
|
|
..add(LoginInviteInitEvent()), |
|
|
child: LoginInvitePageContainer(), |
|
|
child: LoginInvitePageContainer(), |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
@@ -31,7 +33,8 @@ class LoginInvitePage extends StatelessWidget { |
|
|
/// 邀请 |
|
|
/// 邀请 |
|
|
class LoginInvitePageContainer extends StatefulWidget { |
|
|
class LoginInvitePageContainer extends StatefulWidget { |
|
|
@override |
|
|
@override |
|
|
_LoginInvitePageContainerState createState() => _LoginInvitePageContainerState(); |
|
|
|
|
|
|
|
|
_LoginInvitePageContainerState createState() => |
|
|
|
|
|
_LoginInvitePageContainerState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
@@ -50,11 +53,13 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 注册成功跳转 |
|
|
/// 注册成功跳转 |
|
|
void _successJump(){ |
|
|
|
|
|
|
|
|
void _successJump() { |
|
|
RouterUtil.hideKeyboard(context); |
|
|
RouterUtil.hideKeyboard(context); |
|
|
Navigator.pushAndRemoveUntil( |
|
|
Navigator.pushAndRemoveUntil( |
|
|
context, |
|
|
context, |
|
|
MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), |
|
|
|
|
|
|
|
|
MaterialPageRoute( |
|
|
|
|
|
builder: (BuildContext context) => |
|
|
|
|
|
PageFactory.create('homePage', null)), |
|
|
(Route<dynamic> route) => false, |
|
|
(Route<dynamic> route) => false, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@@ -75,7 +80,8 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
if (!EmptyUtil.isEmpty(inviteNum) && inviteNum.length < 3) { |
|
|
if (!EmptyUtil.isEmpty(inviteNum) && inviteNum.length < 3) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
BlocProvider.of<LoginInviteBloc>(context).add(LoginInviteQueryEvent(num: inviteNum)); |
|
|
|
|
|
|
|
|
BlocProvider.of<LoginInviteBloc>(context) |
|
|
|
|
|
.add(LoginInviteQueryEvent(num: inviteNum)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 填写邀请啊吗 |
|
|
/// 填写邀请啊吗 |
|
@@ -86,23 +92,32 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
String inviteNum = inviteUser?.userId ?? ''; |
|
|
String inviteNum = inviteUser?.userId ?? ''; |
|
|
|
|
|
|
|
|
/// 手机号 |
|
|
/// 手机号 |
|
|
UserInfoModel model = await Provider.of<UserInfoNotifier>(context, listen: false)?.getUserInfoModel(); |
|
|
|
|
|
|
|
|
UserInfoModel model = |
|
|
|
|
|
await Provider.of<UserInfoNotifier>(context, listen: false) |
|
|
|
|
|
?.getUserInfoModel(); |
|
|
String mobile = model?.mobile ?? ''; |
|
|
String mobile = model?.mobile ?? ''; |
|
|
if (!EmptyUtil.isEmpty(inviteNum) && !EmptyUtil.isEmpty(mobile)) { |
|
|
if (!EmptyUtil.isEmpty(inviteNum) && !EmptyUtil.isEmpty(mobile)) { |
|
|
BlocProvider.of<LoginInviteBloc>(context).add(LoginInviteSubmitEvent(mobile: mobile, num: inviteNum)); |
|
|
|
|
|
|
|
|
BlocProvider.of<LoginInviteBloc>(context) |
|
|
|
|
|
.add(LoginInviteSubmitEvent(mobile: mobile, num: inviteNum)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
void initState() { |
|
|
void initState() { |
|
|
_editingController = TextEditingController(); |
|
|
_editingController = TextEditingController(); |
|
|
|
|
|
// SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid); |
|
|
|
|
|
|
|
|
|
|
|
MobUtil.getInvitedCode().then((value) { |
|
|
|
|
|
_editingController.text = value; |
|
|
|
|
|
_onChange(value); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
_focusNode = FocusNode(); |
|
|
_focusNode = FocusNode(); |
|
|
super.initState(); |
|
|
super.initState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
void didChangeDependencies() { |
|
|
void didChangeDependencies() { |
|
|
|
|
|
|
|
|
super.didChangeDependencies(); |
|
|
super.didChangeDependencies(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -128,19 +143,23 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
if (current is LoginInviteErrorState) { |
|
|
if (current is LoginInviteErrorState) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 查询邀请人失败 |
|
|
/// 查询邀请人失败 |
|
|
if(current is LoginInviteQueryErrorState){ |
|
|
|
|
|
|
|
|
if (current is LoginInviteQueryErrorState) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 邀请人查询成功 |
|
|
/// 邀请人查询成功 |
|
|
if(current is LoginInviteQuerySuccessState){ |
|
|
|
|
|
|
|
|
if (current is LoginInviteQuerySuccessState) { |
|
|
_showInviteInfo = true; |
|
|
_showInviteInfo = true; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 邀请码成功 跳转 |
|
|
/// 邀请码成功 跳转 |
|
|
if (current is LoginInviteSubmitSuccess) { |
|
|
if (current is LoginInviteSubmitSuccess) { |
|
|
// 缓存数据 |
|
|
// 缓存数据 |
|
|
Provider.of<UserInfoNotifier>(context, listen: false).setUserInfo(current.model); |
|
|
|
|
|
|
|
|
Provider.of<UserInfoNotifier>(context, listen: false) |
|
|
|
|
|
.setUserInfo(current.model); |
|
|
_successJump(); |
|
|
_successJump(); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@@ -165,22 +184,31 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
Widget _getMainWidget(LoginModel model, LoginInviteUser inviteUser) { |
|
|
Widget _getMainWidget(LoginModel model, LoginInviteUser inviteUser) { |
|
|
return Column( |
|
|
return Column( |
|
|
children: <Widget>[ |
|
|
children: <Widget>[ |
|
|
|
|
|
|
|
|
/// appbar |
|
|
/// appbar |
|
|
_getAppBar(model), |
|
|
_getAppBar(model), |
|
|
|
|
|
|
|
|
/// 标题 |
|
|
/// 标题 |
|
|
Padding(padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 40), child: _getTitleWidget(model)), |
|
|
|
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 40), |
|
|
|
|
|
child: _getTitleWidget(model)), |
|
|
|
|
|
|
|
|
/// 输入框 |
|
|
/// 输入框 |
|
|
Padding(padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 30), child: _getInviteInputWidget(model)), |
|
|
|
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 30), |
|
|
|
|
|
child: _getInviteInputWidget(model)), |
|
|
|
|
|
|
|
|
/// 邀请人信息 |
|
|
/// 邀请人信息 |
|
|
Visibility( |
|
|
Visibility( |
|
|
visible: inviteUser != null && _showInviteInfo, |
|
|
visible: inviteUser != null && _showInviteInfo, |
|
|
child: Padding(padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 8), child: _getInviteInfoWidget(inviteUser))), |
|
|
|
|
|
|
|
|
child: Padding( |
|
|
|
|
|
padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 8), |
|
|
|
|
|
child: _getInviteInfoWidget(inviteUser))), |
|
|
|
|
|
|
|
|
/// 按钮 |
|
|
/// 按钮 |
|
|
Padding(padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 30), child: _getSubmiBtnWidget(model, inviteUser)), |
|
|
|
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 30), |
|
|
|
|
|
child: _getSubmiBtnWidget(model, inviteUser)), |
|
|
], |
|
|
], |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@@ -193,7 +221,9 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
elevation: 0, |
|
|
elevation: 0, |
|
|
title: Text( |
|
|
title: Text( |
|
|
model?.invite?.appBarTitle ?? '登录', |
|
|
model?.invite?.appBarTitle ?? '登录', |
|
|
style: TextStyle(color: HexColor.fromHex(model?.invite?.appBarTitleColor ?? '#333333')), |
|
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: |
|
|
|
|
|
HexColor.fromHex(model?.invite?.appBarTitleColor ?? '#333333')), |
|
|
), |
|
|
), |
|
|
centerTitle: true, |
|
|
centerTitle: true, |
|
|
leading: IconButton( |
|
|
leading: IconButton( |
|
@@ -213,7 +243,9 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
alignment: Alignment.centerLeft, |
|
|
alignment: Alignment.centerLeft, |
|
|
child: Text( |
|
|
child: Text( |
|
|
model?.invite?.title ?? '输入邀请码', |
|
|
model?.invite?.title ?? '输入邀请码', |
|
|
style: TextStyle(color: HexColor.fromHex(model?.invite?.titleColor ?? '#333333'), fontSize: 25), |
|
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: HexColor.fromHex(model?.invite?.titleColor ?? '#333333'), |
|
|
|
|
|
fontSize: 25), |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -234,10 +266,13 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
Widget _getInviteInfoWidget(LoginInviteUser model) { |
|
|
Widget _getInviteInfoWidget(LoginInviteUser model) { |
|
|
return Container( |
|
|
return Container( |
|
|
// height: 77.5, |
|
|
// height: 77.5, |
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8), border: Border.all(color: HexColor.fromHex('#E8E8E8'), width: 0.5)), |
|
|
|
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
|
border: Border.all(color: HexColor.fromHex('#E8E8E8'), width: 0.5)), |
|
|
padding: const EdgeInsets.all(15), |
|
|
padding: const EdgeInsets.all(15), |
|
|
child: Row( |
|
|
child: Row( |
|
|
children: <Widget>[ |
|
|
children: <Widget>[ |
|
|
|
|
|
|
|
|
/// 头像 |
|
|
/// 头像 |
|
|
CircleAvatar( |
|
|
CircleAvatar( |
|
|
radius: 23.5, |
|
|
radius: 23.5, |
|
@@ -248,20 +283,30 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
children: <Widget>[ |
|
|
children: <Widget>[ |
|
|
|
|
|
|
|
|
/// 名字 |
|
|
/// 名字 |
|
|
Text( |
|
|
Text( |
|
|
'${model?.nickname}', |
|
|
'${model?.nickname}', |
|
|
style: TextStyle(color: HexColor.fromHex(model?.nickNameColor), fontSize: 13), |
|
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: HexColor.fromHex(model?.nickNameColor), |
|
|
|
|
|
fontSize: 13), |
|
|
), |
|
|
), |
|
|
|
|
|
|
|
|
/// 邀请 |
|
|
/// 邀请 |
|
|
RichText( |
|
|
RichText( |
|
|
text: TextSpan(text: '邀请您进入', style: TextStyle(fontSize: 11, color: HexColor.fromHex(model?.nickNameColor)), children: [ |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
text: '${model?.appName}', |
|
|
|
|
|
style: TextStyle(fontSize: 11, color: HexColor.fromHex(model?.appNameColor)), |
|
|
|
|
|
), |
|
|
|
|
|
]), |
|
|
|
|
|
|
|
|
text: TextSpan( |
|
|
|
|
|
text: '邀请您进入', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 11, |
|
|
|
|
|
color: HexColor.fromHex(model?.nickNameColor)), |
|
|
|
|
|
children: [ |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
text: '${model?.appName}', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 11, |
|
|
|
|
|
color: HexColor.fromHex(model?.appNameColor)), |
|
|
|
|
|
), |
|
|
|
|
|
]), |
|
|
) |
|
|
) |
|
|
], |
|
|
], |
|
|
) |
|
|
) |
|
@@ -282,22 +327,36 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
model?.invite?.btnSubmitText ?? '进入智莺生活', |
|
|
model?.invite?.btnSubmitText ?? '进入智莺生活', |
|
|
style: TextStyle(fontSize: 15), |
|
|
style: TextStyle(fontSize: 15), |
|
|
), |
|
|
), |
|
|
textColor: HexColor.fromHex(model?.invite?.btnSubmitTextColor ?? '#FFFFFF'), |
|
|
|
|
|
|
|
|
textColor: |
|
|
|
|
|
HexColor.fromHex(model?.invite?.btnSubmitTextColor ?? '#FFFFFF'), |
|
|
color: HexColor.fromHex(model?.invite?.btnSubmitBgColor ?? '#FF3939'), |
|
|
color: HexColor.fromHex(model?.invite?.btnSubmitBgColor ?? '#FF3939'), |
|
|
disabledColor: HexColor.fromHex(model?.invite?.btnBanBgColor ?? '#F5F5F5'), |
|
|
|
|
|
disabledTextColor: HexColor.fromHex(model?.invite?.btnBanTextColor ?? '#999999'), |
|
|
|
|
|
|
|
|
disabledColor: |
|
|
|
|
|
HexColor.fromHex(model?.invite?.btnBanBgColor ?? '#F5F5F5'), |
|
|
|
|
|
disabledTextColor: |
|
|
|
|
|
HexColor.fromHex(model?.invite?.btnBanTextColor ?? '#999999'), |
|
|
elevation: 5, |
|
|
elevation: 5, |
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(52 / 2)), |
|
|
|
|
|
onPressed: _showInviteInfo && inviteUser != null ? ()=> _submitOnClick(inviteUser) : null, |
|
|
|
|
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
|
borderRadius: BorderRadius.circular(52 / 2)), |
|
|
|
|
|
onPressed: _showInviteInfo && inviteUser != null |
|
|
|
|
|
? () => _submitOnClick(inviteUser) |
|
|
|
|
|
: null, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 自定义输入框 |
|
|
/// 自定义输入框 |
|
|
Widget _getCustomInputWidget( |
|
|
|
|
|
{String hint, String hintColor, String bgColor, String textColor, String iconUrl, TextEditingController controller, ValueChanged<String> onChanged, FocusNode focusNode}) { |
|
|
|
|
|
var border = OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: HexColor.fromHex(bgColor), width: 0)); |
|
|
|
|
|
|
|
|
Widget _getCustomInputWidget({String hint, |
|
|
|
|
|
String hintColor, |
|
|
|
|
|
String bgColor, |
|
|
|
|
|
String textColor, |
|
|
|
|
|
String iconUrl, |
|
|
|
|
|
TextEditingController controller, |
|
|
|
|
|
ValueChanged<String> onChanged, |
|
|
|
|
|
FocusNode focusNode}) { |
|
|
|
|
|
var border = OutlineInputBorder( |
|
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
|
borderSide: BorderSide(color: HexColor.fromHex(bgColor), width: 0)); |
|
|
|
|
|
|
|
|
return Container( |
|
|
return Container( |
|
|
height: 42, |
|
|
height: 42, |
|
@@ -326,7 +385,8 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { |
|
|
decoration: InputDecoration( |
|
|
decoration: InputDecoration( |
|
|
contentPadding: EdgeInsets.only(top: 30, left: 7.5), |
|
|
contentPadding: EdgeInsets.only(top: 30, left: 7.5), |
|
|
hintText: hint, |
|
|
hintText: hint, |
|
|
hintStyle: TextStyle(fontSize: 13, color: HexColor.fromHex(hintColor)), |
|
|
|
|
|
|
|
|
hintStyle: |
|
|
|
|
|
TextStyle(fontSize: 13, color: HexColor.fromHex(hintColor)), |
|
|
hintMaxLines: 1, |
|
|
hintMaxLines: 1, |
|
|
filled: true, |
|
|
filled: true, |
|
|
fillColor: Colors.transparent, |
|
|
fillColor: Colors.transparent, |
|
|