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 | 4 | static const String icVip = '${_assetImagePrefix}ic_vip.png'; |
| 5 | 5 | static const String icNext = '${_assetImagePrefix}ic_next.png'; |
| 6 | 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; |
| 7 | + static const String bgEditUserInformation = '${_assetImagePrefix}bg_edit_information.png'; | |
| 7 | 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 | 37 | } else if (type == HeaderActionType.shop) { |
| 38 | 38 | Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop); |
| 39 | 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 | 42 | } else { |
| 43 | 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 | 5 | import 'package:wow_english/common/core/user_util.dart'; |
| 6 | 6 | import 'package:wow_english/common/widgets/we_app_bar.dart'; |
| 7 | 7 | import 'package:wow_english/models/user_entity.dart'; |
| 8 | +import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | |
| 8 | 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 | 13 | class UserInformationPage extends StatelessWidget { |
| 13 | 14 | const UserInformationPage({super.key}); |
| ... | ... | @@ -15,7 +16,7 @@ class UserInformationPage extends StatelessWidget { |
| 15 | 16 | @override |
| 16 | 17 | Widget build(BuildContext context) { |
| 17 | 18 | return BlocProvider( |
| 18 | - create: (context) => UserInformationBloc(), | |
| 19 | + create: (context) => UserBloc(), | |
| 19 | 20 | child: const _UserInformationView(), |
| 20 | 21 | ); |
| 21 | 22 | } |
| ... | ... | @@ -26,9 +27,9 @@ class _UserInformationView extends StatelessWidget { |
| 26 | 27 | |
| 27 | 28 | @override |
| 28 | 29 | Widget build(BuildContext context) { |
| 29 | - return BlocListener<UserInformationBloc, UserInformationState>( | |
| 30 | + return BlocListener<UserBloc, UserState>( | |
| 30 | 31 | listener: (context, state) {}, |
| 31 | - child: BlocBuilder<UserInformationBloc, UserInformationState>(builder: (context, state) { | |
| 32 | + child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { | |
| 32 | 33 | return const _UserInformationContentView(); |
| 33 | 34 | }), |
| 34 | 35 | ); |
| ... | ... | @@ -38,31 +39,34 @@ class _UserInformationView extends StatelessWidget { |
| 38 | 39 | class _UserInformationContentView extends StatelessWidget { |
| 39 | 40 | const _UserInformationContentView({super.key}); |
| 40 | 41 | |
| 42 | + void _openModifyPage(ModifyUserInformationType type) { | |
| 43 | + print('_openModifyPage($type)'); | |
| 44 | + } | |
| 45 | + | |
| 41 | 46 | @override |
| 42 | 47 | Widget build(BuildContext context) { |
| 43 | 48 | UserEntity user = UserUtil.getUser()!; |
| 44 | 49 | return Scaffold( |
| 45 | 50 | backgroundColor: Colors.white, |
| 46 | - appBar: const WEAppBar(titleText: "个人信息",), | |
| 51 | + appBar: const WEAppBar( | |
| 52 | + titleText: "个人信息", | |
| 53 | + ), | |
| 47 | 54 | body: SingleChildScrollView( |
| 48 | 55 | padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), |
| 49 | 56 | child: Column( |
| 50 | 57 | children: [ |
| 51 | - buildContentRow( | |
| 58 | + _buildContentRow( | |
| 52 | 59 | '头像', |
| 53 | 60 | CircleAvatar( |
| 54 | 61 | radius: 22.5.r, |
| 55 | - backgroundColor: Color(0xFF140C10), | |
| 62 | + backgroundColor: const Color(0xFF140C10), | |
| 56 | 63 | child: CircleAvatar( |
| 57 | 64 | radius: 21.r, |
| 58 | 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 | 68 | 11.verticalSpace, |
| 65 | - buildContentRow( | |
| 69 | + _buildContentRow( | |
| 66 | 70 | '名字', |
| 67 | 71 | Text( |
| 68 | 72 | user.name, |
| ... | ... | @@ -71,9 +75,10 @@ class _UserInformationContentView extends StatelessWidget { |
| 71 | 75 | color: const Color(0xFF333333), |
| 72 | 76 | fontSize: 21.sp, |
| 73 | 77 | ), |
| 74 | - )), | |
| 78 | + ), | |
| 79 | + onTap: () => _openModifyPage(ModifyUserInformationType.name)), | |
| 75 | 80 | 11.verticalSpace, |
| 76 | - buildContentRow( | |
| 81 | + _buildContentRow( | |
| 77 | 82 | '年龄', |
| 78 | 83 | Text( |
| 79 | 84 | user.age.toString(), |
| ... | ... | @@ -84,7 +89,7 @@ class _UserInformationContentView extends StatelessWidget { |
| 84 | 89 | ), |
| 85 | 90 | )), |
| 86 | 91 | 11.verticalSpace, |
| 87 | - buildContentRow( | |
| 92 | + _buildContentRow( | |
| 88 | 93 | '性别', |
| 89 | 94 | Text( |
| 90 | 95 | user.getGenderString(), |
| ... | ... | @@ -95,7 +100,7 @@ class _UserInformationContentView extends StatelessWidget { |
| 95 | 100 | ), |
| 96 | 101 | )), |
| 97 | 102 | 11.verticalSpace, |
| 98 | - buildContentRow( | |
| 103 | + _buildContentRow( | |
| 99 | 104 | '账号', |
| 100 | 105 | Text( |
| 101 | 106 | user.phoneNum, |
| ... | ... | @@ -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 | 122 | return GestureDetector( |
| 118 | 123 | onTap: onTap, |
| 119 | 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 | 25 | class _UserView extends StatelessWidget { |
| 26 | 26 | const _UserView({super.key}); |
| 27 | 27 | |
| 28 | + final String bannerUrl = ''; | |
| 29 | + | |
| 28 | 30 | @override |
| 29 | 31 | Widget build(BuildContext context) { |
| 30 | 32 | return _pageWidget(); |
| ... | ... | @@ -62,7 +64,10 @@ class _UserView extends StatelessWidget { |
| 62 | 64 | mainAxisAlignment: MainAxisAlignment.center, |
| 63 | 65 | children: <Widget>[ |
| 64 | 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 | 71 | 30.verticalSpace, |
| 67 | 72 | Row( |
| 68 | 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 | +} | ... | ... |