Commit 0786a373 authored by 张宏's avatar 张宏

remark

parent bd3c7628
1.http及response 移动至 http ## 任务分解及实现明细
## 其他
### 路由生产
dart run build_runner build
dart run build_runner watch
---
### gitlab
git config --global user.name "xxx"
git config --global user.email "xxx"
Create a new repository
git clone http://git.ruanyiit.com/zhanghong/smart_hotel_app.git
cd smart_hotel_app
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://git.ruanyiit.com/zhanghong/smart_hotel_app.git
git add .
git commit -m "Initial commit"
git push -u origin master
### 版本处理 ### 版本处理
版本对齐后,必须清除旧缓存,否则 Gradle 会继续读取损坏的元数据 版本对齐后,必须清除旧缓存,否则 Gradle 会继续读取损坏的元数据
......
...@@ -28,11 +28,13 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> { ...@@ -28,11 +28,13 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
try { try {
// todo 这里暂定返回bool // todo 这里暂定返回bool
final success = await _authService.login(event.username, event.password); // final success = await _authService.login(event.username, event.password);
final success = true;
if (success) { if (success) {
final userInfo = UserInfoBO(); final userInfo = const UserInfoBO(
userInfo.username = event.username; // todo 这里应对从login接口获取到 username: "张三丰",
);
emit(AuthSuccess(userInfo)); emit(AuthSuccess(userInfo));
} else { } else {
emit(const AuthFailure('登录失败,请检查用户名和密码')); emit(const AuthFailure('登录失败,请检查用户名和密码'));
......
...@@ -92,7 +92,7 @@ class _MyAppState extends State<MyApp> { ...@@ -92,7 +92,7 @@ class _MyAppState extends State<MyApp> {
BlocListener<AuthBloc, AuthState>( BlocListener<AuthBloc, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is AuthSuccess) { if (state is AuthSuccess) {
_appRouter.navigate(const DefaultLayoutRoute()); _appRouter.replaceAll([const DefaultLayoutRoute()]);
} }
if (state is AuthTokenExpired) { if (state is AuthTokenExpired) {
_scaffoldMessengerKey.currentState?.showSnackBar( _scaffoldMessengerKey.currentState?.showSnackBar(
......
import 'package:equatable/equatable.dart';
/** /**
* 业务对象 * 业务对象
*/ */
class UserInfoBO { class UserInfoBO extends Equatable {
String? username; final String? username;
String? rolename; final String? rolename;
String? rolecode; final String? rolecode;
// 用户相关其他信息
const UserInfoBO({
this.username,
this.rolename,
this.rolecode,
});
@override
List<Object?> get props => [username, rolename, rolecode];
} }
\ No newline at end of file
...@@ -85,7 +85,7 @@ class _HomeViewState extends State<HomeView> { ...@@ -85,7 +85,7 @@ class _HomeViewState extends State<HomeView> {
width: 2.w, width: 2.w,
), ),
Text( Text(
"香蜜湖店", "xxxx",
style: TextStyle( style: TextStyle(
color: Color(0xFFFFFFFF), color: Color(0xFFFFFFFF),
fontSize: 32.sp), fontSize: 32.sp),
......
...@@ -15,6 +15,7 @@ class _DefaultLayoutViewState extends State<DefaultLayoutView> { ...@@ -15,6 +15,7 @@ class _DefaultLayoutViewState extends State<DefaultLayoutView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AutoTabsScaffold( return AutoTabsScaffold(
routes: const [HomeRoute(), NewsRoute(), MessageRoute(), ProfileRoute()], routes: const [HomeRoute(), NewsRoute(), MessageRoute(), ProfileRoute()],
transitionBuilder: (context, child, animation) => child,
bottomNavigationBuilder: (context, tabsRouter) { bottomNavigationBuilder: (context, tabsRouter) {
return Container( return Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -34,9 +35,9 @@ class _DefaultLayoutViewState extends State<DefaultLayoutView> { ...@@ -34,9 +35,9 @@ class _DefaultLayoutViewState extends State<DefaultLayoutView> {
selectedFontSize: 12, selectedFontSize: 12,
unselectedFontSize: 12, unselectedFontSize: 12,
items: const [ items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"), BottomNavigationBarItem(icon: Icon(Icons.home), label: "告警"),
BottomNavigationBarItem(icon: Icon(Icons.new_label), label: "新闻"), BottomNavigationBarItem(icon: Icon(Icons.new_label), label: "服务"),
BottomNavigationBarItem(icon: Icon(Icons.message), label: "消息"), BottomNavigationBarItem(icon: Icon(Icons.message), label: "看板"),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.my_location), label: "我的") icon: Icon(Icons.my_location), label: "我的")
], ],
......
...@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; ...@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:smart_hotel_app/blocs/auth/auth_bloc.dart'; import 'package:smart_hotel_app/blocs/auth/auth_bloc.dart';
import 'package:smart_hotel_app/blocs/auth/auth_state.dart'; import 'package:smart_hotel_app/blocs/auth/auth_state.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';
import 'package:smart_hotel_app/utils/storage/storage_service.dart'; import 'package:smart_hotel_app/utils/storage/storage_service.dart';
import 'package:smart_hotel_app/views/login/child/btn_login.dart'; import 'package:smart_hotel_app/views/login/child/btn_login.dart';
import 'package:smart_hotel_app/views/login/child/btn_reset.dart'; import 'package:smart_hotel_app/views/login/child/btn_reset.dart';
...@@ -55,81 +56,87 @@ class _LoginViewState extends State<LoginView> { ...@@ -55,81 +56,87 @@ class _LoginViewState extends State<LoginView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: true,
body: Container( body: Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.only(left: 50.w, right: 50.w), padding: EdgeInsets.only(left: 50.w, right: 50.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFF1A2B3C), color: Color(0xFF1A2B3C),
), ),
child: Column( child: SingleChildScrollView(
children: [ child: Column(
Container( children: [
margin: EdgeInsets.only(top: 150.h, bottom: 150.h), Container(
margin: EdgeInsets.only(top: 150.h, bottom: 150.h),
child: Column(
children: [
Image.asset(
'lib/assets/znjd_logo.png',
width: 100,
height: 100,
),
const SizedBox(height: 10),
Text("智能酒店管理系统", style: TextStyle(color: Colors.white, fontSize: 20.sp),),
Text("Intelligent Hotel Management System", style: TextStyle(color: Colors.white, fontSize: 20.sp),),
],
),
),
Container(
child: Form(
key: _frmGlobalKey,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Image.asset( UsernameField(
'lib/assets/znjd_logo.png', controller: _txtUserNameController,
width: 100,
height: 100,
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Text("智能酒店管理系统", style: TextStyle(color: Colors.white, fontSize: 20.sp),), PasswordField(
Text("Intelligent Hotel Management System", style: TextStyle(color: Colors.white, fontSize: 20.sp),), controller: _txtPwdController,
),
// const SizedBox(height: 5),
RememberPasswordRow(
value: _rememberPassword,
onChanged: (val) {
setState(() {
_rememberPassword = val ?? false;
});
},
onForgotPassword: _loginController.forgotPwd,
),
const SizedBox(height: 20),
BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthFailure) {
Fluttertoast.showToast(
msg: state.error,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
}
},
builder: (context, state) {
return BtnLogin(
isLoading: state is AuthLoading,
onPressed: () => _loginController.login(
_frmGlobalKey,
rememberPassword: _rememberPassword,
),
);
},
),
], ],
), ),
), ),
Container(
child: Form(
key: _frmGlobalKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
UsernameField(
controller: _txtUserNameController,
),
const SizedBox(height: 10),
PasswordField(
controller: _txtPwdController,
),
// const SizedBox(height: 5),
RememberPasswordRow(
value: _rememberPassword,
onChanged: (val) {
setState(() {
_rememberPassword = val ?? false;
});
},
onForgotPassword: _loginController.forgotPwd,
),
const SizedBox(height: 20),
BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthFailure) {
Fluttertoast.showToast(
msg: state.error,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
}
},
builder: (context, state) {
return BtnLogin(
isLoading: state is AuthLoading,
onPressed: () => _loginController.login(
_frmGlobalKey,
rememberPassword: _rememberPassword,
),
);
},
),
],
),
), ),
])
), ),
])
), ),
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment