Commit 49e626e95a46c09f0655e675011b909e11804a2e
1 parent
da82bd70
feat: log_util.dart
Showing
10 changed files
with
116 additions
and
42 deletions
assets/images/bg_edit_information.png
0 → 100644
504 KB
lib/common/core/assets_const.dart
| @@ -4,5 +4,6 @@ class AssetsConst { | @@ -4,5 +4,6 @@ class AssetsConst { | ||
| 4 | static const String icVip = '${_assetImagePrefix}ic_vip.png'; | 4 | static const String icVip = '${_assetImagePrefix}ic_vip.png'; |
| 5 | static const String icNext = '${_assetImagePrefix}ic_next.png'; | 5 | static const String icNext = '${_assetImagePrefix}ic_next.png'; |
| 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; | 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; |
| 7 | + static const String bgEditUserInformation = '${_assetImagePrefix}bg_edit_information.png'; | ||
| 7 | //static String get icVip2 =>'ic_vip.png'.assetImg; | 8 | //static String get icVip2 =>'ic_vip.png'.assetImg; |
| 8 | } | 9 | } |
lib/pages/home/home_page.dart
| @@ -37,8 +37,8 @@ class _HomePageView extends StatelessWidget { | @@ -37,8 +37,8 @@ class _HomePageView extends StatelessWidget { | ||
| 37 | } else if (type == HeaderActionType.shop) { | 37 | } else if (type == HeaderActionType.shop) { |
| 38 | Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop); | 38 | Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop); |
| 39 | } else if (type == HeaderActionType.user) { | 39 | } else if (type == HeaderActionType.user) { |
| 40 | - // Navigator.of(AppRouter.context).pushNamed(AppRouteName.user); | ||
| 41 | - Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic); | 40 | + Navigator.of(AppRouter.context).pushNamed(AppRouteName.user); |
| 41 | + // Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic); | ||
| 42 | } else { | 42 | } else { |
| 43 | // Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic); | 43 | // Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic); |
| 44 | } | 44 | } |
lib/pages/user/information/user_information_bloc.dart deleted
| 1 | -import 'package:bloc/bloc.dart'; | ||
| 2 | -import 'package:meta/meta.dart'; | ||
| 3 | - | ||
| 4 | -part 'user_information_event.dart'; | ||
| 5 | -part 'user_information_state.dart'; | ||
| 6 | - | ||
| 7 | -class UserInformationBloc extends Bloc<UserInformationEvent, UserInformationState> { | ||
| 8 | - UserInformationBloc() : super(UserInformationInitial()) { | ||
| 9 | - on<UserInformationEvent>((event, emit) { | ||
| 10 | - // TODO: implement event handler | ||
| 11 | - }); | ||
| 12 | - } | ||
| 13 | -} |
lib/pages/user/information/user_information_event.dart deleted
lib/pages/user/information/user_information_page.dart
| @@ -5,9 +5,10 @@ import 'package:wow_english/common/core/assets_const.dart'; | @@ -5,9 +5,10 @@ import 'package:wow_english/common/core/assets_const.dart'; | ||
| 5 | import 'package:wow_english/common/core/user_util.dart'; | 5 | import 'package:wow_english/common/core/user_util.dart'; |
| 6 | import 'package:wow_english/common/widgets/we_app_bar.dart'; | 6 | import 'package:wow_english/common/widgets/we_app_bar.dart'; |
| 7 | import 'package:wow_english/models/user_entity.dart'; | 7 | import 'package:wow_english/models/user_entity.dart'; |
| 8 | +import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | ||
| 8 | import 'package:wow_english/utils/image_util.dart'; | 9 | import 'package:wow_english/utils/image_util.dart'; |
| 9 | 10 | ||
| 10 | -import 'user_information_bloc.dart'; | 11 | +import '../modify/modify_user_information_page.dart'; |
| 11 | 12 | ||
| 12 | class UserInformationPage extends StatelessWidget { | 13 | class UserInformationPage extends StatelessWidget { |
| 13 | const UserInformationPage({super.key}); | 14 | const UserInformationPage({super.key}); |
| @@ -15,7 +16,7 @@ class UserInformationPage extends StatelessWidget { | @@ -15,7 +16,7 @@ class UserInformationPage extends StatelessWidget { | ||
| 15 | @override | 16 | @override |
| 16 | Widget build(BuildContext context) { | 17 | Widget build(BuildContext context) { |
| 17 | return BlocProvider( | 18 | return BlocProvider( |
| 18 | - create: (context) => UserInformationBloc(), | 19 | + create: (context) => UserBloc(), |
| 19 | child: const _UserInformationView(), | 20 | child: const _UserInformationView(), |
| 20 | ); | 21 | ); |
| 21 | } | 22 | } |
| @@ -26,9 +27,9 @@ class _UserInformationView extends StatelessWidget { | @@ -26,9 +27,9 @@ class _UserInformationView extends StatelessWidget { | ||
| 26 | 27 | ||
| 27 | @override | 28 | @override |
| 28 | Widget build(BuildContext context) { | 29 | Widget build(BuildContext context) { |
| 29 | - return BlocListener<UserInformationBloc, UserInformationState>( | 30 | + return BlocListener<UserBloc, UserState>( |
| 30 | listener: (context, state) {}, | 31 | listener: (context, state) {}, |
| 31 | - child: BlocBuilder<UserInformationBloc, UserInformationState>(builder: (context, state) { | 32 | + child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { |
| 32 | return const _UserInformationContentView(); | 33 | return const _UserInformationContentView(); |
| 33 | }), | 34 | }), |
| 34 | ); | 35 | ); |
| @@ -38,31 +39,34 @@ class _UserInformationView extends StatelessWidget { | @@ -38,31 +39,34 @@ class _UserInformationView extends StatelessWidget { | ||
| 38 | class _UserInformationContentView extends StatelessWidget { | 39 | class _UserInformationContentView extends StatelessWidget { |
| 39 | const _UserInformationContentView({super.key}); | 40 | const _UserInformationContentView({super.key}); |
| 40 | 41 | ||
| 42 | + void _openModifyPage(ModifyUserInformationType type) { | ||
| 43 | + print('_openModifyPage($type)'); | ||
| 44 | + } | ||
| 45 | + | ||
| 41 | @override | 46 | @override |
| 42 | Widget build(BuildContext context) { | 47 | Widget build(BuildContext context) { |
| 43 | UserEntity user = UserUtil.getUser()!; | 48 | UserEntity user = UserUtil.getUser()!; |
| 44 | return Scaffold( | 49 | return Scaffold( |
| 45 | backgroundColor: Colors.white, | 50 | backgroundColor: Colors.white, |
| 46 | - appBar: const WEAppBar(titleText: "个人信息",), | 51 | + appBar: const WEAppBar( |
| 52 | + titleText: "个人信息", | ||
| 53 | + ), | ||
| 47 | body: SingleChildScrollView( | 54 | body: SingleChildScrollView( |
| 48 | padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), | 55 | padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), |
| 49 | child: Column( | 56 | child: Column( |
| 50 | children: [ | 57 | children: [ |
| 51 | - buildContentRow( | 58 | + _buildContentRow( |
| 52 | '头像', | 59 | '头像', |
| 53 | CircleAvatar( | 60 | CircleAvatar( |
| 54 | radius: 22.5.r, | 61 | radius: 22.5.r, |
| 55 | - backgroundColor: Color(0xFF140C10), | 62 | + backgroundColor: const Color(0xFF140C10), |
| 56 | child: CircleAvatar( | 63 | child: CircleAvatar( |
| 57 | radius: 21.r, | 64 | radius: 21.r, |
| 58 | backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl), | 65 | backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl), |
| 59 | ), | 66 | ), |
| 60 | - /*child: ClipOval( | ||
| 61 | - child: OwImageWidget(name: user.avatarUrl ?? AssetsConst.wowLogo, fit: BoxFit.contain,), | ||
| 62 | - )*/ | ||
| 63 | )), | 67 | )), |
| 64 | 11.verticalSpace, | 68 | 11.verticalSpace, |
| 65 | - buildContentRow( | 69 | + _buildContentRow( |
| 66 | '名字', | 70 | '名字', |
| 67 | Text( | 71 | Text( |
| 68 | user.name, | 72 | user.name, |
| @@ -71,9 +75,10 @@ class _UserInformationContentView extends StatelessWidget { | @@ -71,9 +75,10 @@ class _UserInformationContentView extends StatelessWidget { | ||
| 71 | color: const Color(0xFF333333), | 75 | color: const Color(0xFF333333), |
| 72 | fontSize: 21.sp, | 76 | fontSize: 21.sp, |
| 73 | ), | 77 | ), |
| 74 | - )), | 78 | + ), |
| 79 | + onTap: () => _openModifyPage(ModifyUserInformationType.name)), | ||
| 75 | 11.verticalSpace, | 80 | 11.verticalSpace, |
| 76 | - buildContentRow( | 81 | + _buildContentRow( |
| 77 | '年龄', | 82 | '年龄', |
| 78 | Text( | 83 | Text( |
| 79 | user.age.toString(), | 84 | user.age.toString(), |
| @@ -84,7 +89,7 @@ class _UserInformationContentView extends StatelessWidget { | @@ -84,7 +89,7 @@ class _UserInformationContentView extends StatelessWidget { | ||
| 84 | ), | 89 | ), |
| 85 | )), | 90 | )), |
| 86 | 11.verticalSpace, | 91 | 11.verticalSpace, |
| 87 | - buildContentRow( | 92 | + _buildContentRow( |
| 88 | '性别', | 93 | '性别', |
| 89 | Text( | 94 | Text( |
| 90 | user.getGenderString(), | 95 | user.getGenderString(), |
| @@ -95,7 +100,7 @@ class _UserInformationContentView extends StatelessWidget { | @@ -95,7 +100,7 @@ class _UserInformationContentView extends StatelessWidget { | ||
| 95 | ), | 100 | ), |
| 96 | )), | 101 | )), |
| 97 | 11.verticalSpace, | 102 | 11.verticalSpace, |
| 98 | - buildContentRow( | 103 | + _buildContentRow( |
| 99 | '账号', | 104 | '账号', |
| 100 | Text( | 105 | Text( |
| 101 | user.phoneNum, | 106 | user.phoneNum, |
| @@ -113,7 +118,7 @@ class _UserInformationContentView extends StatelessWidget { | @@ -113,7 +118,7 @@ class _UserInformationContentView extends StatelessWidget { | ||
| 113 | ); | 118 | ); |
| 114 | } | 119 | } |
| 115 | 120 | ||
| 116 | - Widget buildContentRow(String filedName, Widget contentWidget, {bool isHideEndIcon = false, Function()? onTap}) { | 121 | + Widget _buildContentRow(String filedName, Widget contentWidget, {bool isHideEndIcon = false, Function()? onTap}) { |
| 117 | return GestureDetector( | 122 | return GestureDetector( |
| 118 | onTap: onTap, | 123 | onTap: onTap, |
| 119 | child: Container( | 124 | child: Container( |
lib/pages/user/information/user_information_state.dart deleted
lib/pages/user/modify/modify_user_information_page.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_bloc/flutter_bloc.dart'; | ||
| 3 | +import 'package:wow_english/common/widgets/we_app_bar.dart'; | ||
| 4 | +import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | ||
| 5 | + | ||
| 6 | +enum ModifyUserInformationType { | ||
| 7 | + avatar('修改头像'), name('修改名字'), age('修改年龄'), gender('修改性别'); | ||
| 8 | + | ||
| 9 | + const ModifyUserInformationType(this.title); | ||
| 10 | + | ||
| 11 | + final String title; | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +class ModifyUserInformationPage extends StatelessWidget { | ||
| 15 | + final ModifyUserInformationType type; | ||
| 16 | + | ||
| 17 | + const ModifyUserInformationPage({super.key, required this.type}); | ||
| 18 | + | ||
| 19 | + @override | ||
| 20 | + Widget build(BuildContext context) { | ||
| 21 | + return BlocProvider( | ||
| 22 | + create: (context) => UserBloc(), | ||
| 23 | + child: Scaffold( | ||
| 24 | + backgroundColor: Colors.white, | ||
| 25 | + appBar: WEAppBar( | ||
| 26 | + titleText: type.title, | ||
| 27 | + ), | ||
| 28 | + ), | ||
| 29 | + ); | ||
| 30 | + } | ||
| 31 | +} |
lib/pages/user/user_page.dart
| @@ -25,6 +25,8 @@ class UserPage extends StatelessWidget { | @@ -25,6 +25,8 @@ class UserPage extends StatelessWidget { | ||
| 25 | class _UserView extends StatelessWidget { | 25 | class _UserView extends StatelessWidget { |
| 26 | const _UserView({super.key}); | 26 | const _UserView({super.key}); |
| 27 | 27 | ||
| 28 | + final String bannerUrl = ''; | ||
| 29 | + | ||
| 28 | @override | 30 | @override |
| 29 | Widget build(BuildContext context) { | 31 | Widget build(BuildContext context) { |
| 30 | return _pageWidget(); | 32 | return _pageWidget(); |
| @@ -62,7 +64,10 @@ class _UserView extends StatelessWidget { | @@ -62,7 +64,10 @@ class _UserView extends StatelessWidget { | ||
| 62 | mainAxisAlignment: MainAxisAlignment.center, | 64 | mainAxisAlignment: MainAxisAlignment.center, |
| 63 | children: <Widget>[ | 65 | children: <Widget>[ |
| 64 | // banner | 66 | // banner |
| 65 | - Container(child: Image.asset(AssetsConst.wowLogo), constraints: BoxConstraints(maxHeight: 196.h)), | 67 | + Offstage( |
| 68 | + child: Container( | ||
| 69 | + child: Image.asset(bannerUrl), constraints: BoxConstraints(maxHeight: 196.h)), | ||
| 70 | + ), | ||
| 66 | 30.verticalSpace, | 71 | 30.verticalSpace, |
| 67 | Row( | 72 | Row( |
| 68 | mainAxisAlignment: MainAxisAlignment.spaceBetween, | 73 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
lib/utils/log_util.dart
0 → 100644
| 1 | +enum LogLevel { debug, info, warning, error } | ||
| 2 | + | ||
| 3 | +class Log { | ||
| 4 | + static LogLevel level = LogLevel.debug; | ||
| 5 | + | ||
| 6 | + /// debug | ||
| 7 | + static void d(String message) { | ||
| 8 | + if (level.index <= LogLevel.debug.index) { | ||
| 9 | + print(message); | ||
| 10 | + } | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + /// info | ||
| 14 | + static void i(String message) { | ||
| 15 | + if (level.index <= LogLevel.info.index) { | ||
| 16 | + print(message); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /// warning | ||
| 21 | + static void w(String message) { | ||
| 22 | + if (level.index <= LogLevel.warning.index) { | ||
| 23 | + print(message); | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /// error | ||
| 28 | + static void e(String message) { | ||
| 29 | + if (level.index <= LogLevel.error.index) { | ||
| 30 | + print(message); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +extension LogExtension on String { | ||
| 36 | + String logD() { | ||
| 37 | + Log.d(this); | ||
| 38 | + return this; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + String logI() { | ||
| 42 | + Log.i(this); | ||
| 43 | + return this; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + String logW() { | ||
| 47 | + Log.w(this); | ||
| 48 | + return this; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + String logE() { | ||
| 52 | + Log.e(this); | ||
| 53 | + return this; | ||
| 54 | + } | ||
| 55 | +} |