Commit e12dbc82499e691d5b76251f67cc117c6cc18a33

Authored by Key
1 parent 6529e5f7

user module

assets/images/ic_vip.png 0 → 100644

3.35 KB

lib/common/core/assets_const.dart 0 → 100644
  1 +class AssetsConst {
  2 + static const String _assetImagePrefix = "assets/images/";
  3 + static const String wowLogo = "wow_logo.png";
  4 + static const String icVip = "ic_vip.png";
  5 +}
... ...
lib/common/core/const.dart renamed to lib/common/core/sp_const.dart
lib/common/core/user_util.dart
1 1 import 'dart:convert';
2 2  
3 3 import 'package:flutter/material.dart';
4   -import 'package:wow_english/common/core/const.dart';
  4 +import 'package:wow_english/common/core/sp_const.dart';
5 5 import 'package:wow_english/models/user_entity.dart';
6 6 import 'package:wow_english/route/route.dart';
7 7 import 'package:wow_english/utils/sp_util.dart';
... ...
lib/common/request/request_client.dart
... ... @@ -17,7 +17,7 @@ class RequestClient {
17 17 RequestClient() {
18 18 _dio = Dio(BaseOptions(baseUrl: RequestConfig.baseUrl, connectTimeout: RequestConfig.connectTimeout));
19 19 _dio.interceptors.add(TokenInterceptor());
20   - _dio.interceptors.add(PrettyDioLogger(requestHeader: true, requestBody: true, responseHeader: true));
  20 + _dio.interceptors.add(PrettyDioLogger(requestHeader: true, requestBody: true));
21 21 }
22 22  
23 23 Future<T?> request<T>(
... ...
lib/models/user_entity.dart
... ... @@ -7,9 +7,10 @@ import &#39;package:wow_english/generated/json/user_entity.g.dart&#39;;
7 7 class UserEntity {
8 8 late int id;
9 9 late String name;
10   - late int age;
11   - late int gender;
12   - late String avatarUrl;
  10 + late int? age;
  11 + /// 性别:0, 1
  12 + late int? gender;
  13 + late String? avatarUrl;
13 14 late String phoneNum;
14 15 late String token;
15 16 late int expireTime;
... ...
lib/pages/user/user_page.dart
1 1 import 'package:flutter/material.dart';
2 2 import 'package:flutter_bloc/flutter_bloc.dart';
  3 +import 'package:flutter_screenutil/flutter_screenutil.dart';
3 4 import 'package:wow_english/common/blocs/cachebloc/cache_bloc.dart';
  5 +import 'package:wow_english/common/core/assets_const.dart';
  6 +import 'package:wow_english/common/extension/string_extension.dart';
4 7 import 'package:wow_english/common/widgets/we_app_bar.dart';
5 8 import 'package:wow_english/models/user_entity.dart';
  9 +import 'package:wow_english/pages/user/bloc/user_bloc.dart';
6 10  
7 11 class UserPage extends StatelessWidget {
8 12 const UserPage({super.key});
9 13  
10 14 @override
11 15 Widget build(BuildContext context) {
  16 + return BlocProvider(
  17 + create: (context) => UserBloc(),
  18 + child: _UserView(),
  19 + );
  20 + }
  21 +}
  22 +
  23 +class _UserView extends StatelessWidget {
  24 + const _UserView({super.key});
  25 +
  26 + @override
  27 + Widget build(BuildContext context) {
12 28 UserEntity? user = context.read<CacheBloc>().userEntity;
13 29 return Scaffold(
14   - backgroundColor: Colors.white,
15   - appBar: WEAppBar(
16   - titleText: user?.name ?? '????',
17   - ),
18   - body: Row(),
  30 + backgroundColor: Colors.white,
  31 + appBar: WEAppBar(
  32 + // 测试用的
  33 + titleText: user?.name ?? '个人中心',
  34 + ),
  35 + body: SingleChildScrollView(
  36 + child: Column(
  37 + mainAxisAlignment: MainAxisAlignment.center,
  38 + children: <Widget>[
  39 + Container(
  40 + child: Image.asset(AssetsConst.wowLogo.assetImg), constraints: BoxConstraints(maxHeight: 196.h)),
  41 + _userInfo(context),
  42 + ],
  43 + ),
  44 + ));
  45 + }
  46 +
  47 + Widget _userInfo(BuildContext context) {
  48 + return Row(
  49 + children: [
  50 + Image.asset(
  51 + AssetsConst.wowLogo.assetImg,
  52 + width: 80,
  53 + height: 80,
  54 + ),
  55 + Column(
  56 + children: [
  57 + Row(
  58 + children: [
  59 + Text(
  60 + context.read<CacheBloc>().userEntity?.name ?? '----',
  61 + style: TextStyle(
  62 + color: const Color(0xFF333333),
  63 + fontSize: 21.sp,
  64 + ),
  65 + ),
  66 + //Text(context.read<CacheBloc>().userEntity?.gender ?? '--'),
  67 + Image.asset(
  68 + AssetsConst.wowLogo.assetImg,
  69 + height: 18.h,
  70 + ),
  71 + ],
  72 + ),
  73 + Row(
  74 + children: [
  75 + Text(
  76 + "什么时候到期",
  77 + style: TextStyle(
  78 + color: const Color(0xFFE11212),
  79 + fontSize: 17.sp,
  80 + ),
  81 + )
  82 + ],
  83 + )
  84 + ],
  85 + ),
  86 + ],
19 87 );
20 88 }
21 89 }
... ...