Przeglądaj źródła

1、返回首页的问题优化

tags/0.0.2+11
PH2 4 lat temu
rodzic
commit
2f523efbb4
4 zmienionych plików z 42 dodań i 88 usunięć
  1. +2
    -1
      lib/pages/login_page/account/login_account_page.dart
  2. +31
    -86
      lib/pages/login_page/invite/login_invite_page.dart
  3. +3
    -1
      lib/util/mob_util/secverify/quick_login_util.dart
  4. +6
    -0
      lib/util/router_util.dart

+ 2
- 1
lib/pages/login_page/account/login_account_page.dart Wyświetl plik

@@ -69,7 +69,8 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
/// 登陆成功页面
void _openLoginSuccessPage() {
RouterUtil.hideKeyboard(context);
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false,);
RouterUtil.goBackHomePage(context);
// Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false,);
}

/// 返回上一页


+ 31
- 86
lib/pages/login_page/invite/login_invite_page.dart Wyświetl plik

@@ -21,8 +21,7 @@ class LoginInvitePage extends StatelessWidget {
resizeToAvoidBottomInset: false,
backgroundColor: HexColor.fromHex('#FFFFFF'),
body: BlocProvider(
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository())
..add(LoginInviteInitEvent()),
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository())..add(LoginInviteInitEvent()),
child: LoginInvitePageContainer(),
),
);
@@ -33,8 +32,7 @@ class LoginInvitePage extends StatelessWidget {
/// 邀请
class LoginInvitePageContainer extends StatefulWidget {
@override
_LoginInvitePageContainerState createState() =>
_LoginInvitePageContainerState();
_LoginInvitePageContainerState createState() => _LoginInvitePageContainerState();
}

class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
@@ -55,13 +53,8 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
/// 注册成功跳转
void _successJump() {
RouterUtil.hideKeyboard(context);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
PageFactory.create('homePage', null)),
(Route<dynamic> route) => false,
);
RouterUtil.goBackHomePage(context);
// Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false,);
}

/// 输入框输入变化
@@ -80,8 +73,7 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
if (!EmptyUtil.isEmpty(inviteNum) && inviteNum.length < 3) {
return;
}
BlocProvider.of<LoginInviteBloc>(context)
.add(LoginInviteQueryEvent(num: inviteNum));
BlocProvider.of<LoginInviteBloc>(context).add(LoginInviteQueryEvent(num: inviteNum));
}

/// 填写邀请啊吗
@@ -92,13 +84,10 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
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 ?? '';
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));
}
}

@@ -158,8 +147,7 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
/// 邀请码成功 跳转
if (current is LoginInviteSubmitSuccess) {
// 缓存数据
Provider.of<UserInfoNotifier>(context, listen: false)
.setUserInfo(current.model);
Provider.of<UserInfoNotifier>(context, listen: false).setUserInfo(current.model);
_successJump();
return false;
}
@@ -184,31 +172,20 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
Widget _getMainWidget(LoginModel model, LoginInviteUser inviteUser) {
return Column(
children: <Widget>[

/// appbar
_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(
visible: inviteUser != null && _showInviteInfo,
child: Padding(
padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 8),
child: _getInviteInfoWidget(inviteUser))),
Visibility(visible: inviteUser != null && _showInviteInfo, 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)),
],
);
}
@@ -221,9 +198,7 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
elevation: 0,
title: Text(
model?.invite?.appBarTitle ?? '登录',
style: TextStyle(
color:
HexColor.fromHex(model?.invite?.appBarTitleColor ?? '#333333')),
style: TextStyle(color: HexColor.fromHex(model?.invite?.appBarTitleColor ?? '#333333')),
),
centerTitle: true,
leading: IconButton(
@@ -243,9 +218,7 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
alignment: Alignment.centerLeft,
child: Text(
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),
));
}

@@ -266,13 +239,10 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
Widget _getInviteInfoWidget(LoginInviteUser model) {
return Container(
// 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),
child: Row(
children: <Widget>[

/// 头像
CircleAvatar(
radius: 23.5,
@@ -283,30 +253,20 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[

/// 名字
Text(
'${model?.nickname}',
style: TextStyle(
color: HexColor.fromHex(model?.nickNameColor),
fontSize: 13),
style: TextStyle(color: HexColor.fromHex(model?.nickNameColor), fontSize: 13),
),

/// 邀请
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)),
),
]),
)
],
)
@@ -327,36 +287,22 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
model?.invite?.btnSubmitText ?? '进入智莺生活',
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'),
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,
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(
height: 42,
@@ -385,8 +331,7 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 30, left: 7.5),
hintText: hint,
hintStyle:
TextStyle(fontSize: 13, color: HexColor.fromHex(hintColor)),
hintStyle: TextStyle(fontSize: 13, color: HexColor.fromHex(hintColor)),
hintMaxLines: 1,
filled: true,
fillColor: Colors.transparent,


+ 3
- 1
lib/util/mob_util/secverify/quick_login_util.dart Wyświetl plik

@@ -14,6 +14,7 @@ import 'package:zhiying_comm/util/log/let_log.dart';
import 'package:zhiying_comm/util/net_util.dart';
import 'package:provider/provider.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:zhiying_comm/util/router_util.dart';
import '../../page_factory.dart';

class QuickLoginUtil {
@@ -84,7 +85,8 @@ class QuickLoginUtil {

/// 打开首页的方法
void _openHomePage(BuildContext context) {
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false);
RouterUtil.goBackHomePage(context);
// Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false);
}

// 需要自己实现这部分


+ 6
- 0
lib/util/router_util.dart Wyświetl plik

@@ -52,6 +52,7 @@ class RouterUtil {
}));
}

// 打开网页
static Future openWebview(String url, BuildContext context) {
if (url == null || url == '') {
Logger.error('跳转链接不能为空');
@@ -63,7 +64,12 @@ class RouterUtil {
RouterUtil.route(model, model.toJson(), context);
}

// 回到首页
static Future goBackHomePage(BuildContext context){
Navigator.popUntil(context, ModalRoute.withName('/homePage'));
}

// 隐藏键盘
static void hideKeyboard(BuildContext context){
try {
FocusScopeNode currentFocus = FocusScope.of(context);


Ładowanie…
Anuluj
Zapisz