diff --git a/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt index 4a5cd2d..1cee7ba 100644 --- a/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt +++ b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt @@ -1,11 +1,47 @@ package com.kouyuxingqiu.wow_english +import android.graphics.Color +import android.os.Build +import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat import io.flutter.embedding.android.FlutterActivity class MainActivity : FlutterActivity() { - // 测试有效 - /*override fun onCreate(savedInstanceState: Bundle?) { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - Toast.makeText(this, "onCreate", Toast.LENGTH_SHORT).show() - }*/ + Log.i("WowEnglish", "MainActivity onCreate") + } + + override fun onResume() { + super.onResume() + //setFullScreen() + } + + private fun setFullScreen() { + WindowInsetsControllerCompat(window, window.decorView).let { + it.hide(WindowInsetsCompat.Type.statusBars()) + it.hide(WindowInsetsCompat.Type.navigationBars()) + it.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + // 导航栏横线的颜色 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + window.navigationBarDividerColor = Color.TRANSPARENT + } + + /*window.statusBarColor = Color.TRANSPARENT + val controller = WindowInsetsControllerCompat(window, window.decorView) + // 黑色状态栏字体 + controller.isAppearanceLightStatusBars = false + // 状态栏隐藏 + controller.hide(WindowInsetsCompat.Type.statusBars()) + // 导航栏隐藏 + controller.hide(WindowInsetsCompat.Type.navigationBars()) + //window.navigationBarColor = Color.TRANSPARENT + // 打开沉浸式 + WindowCompat.setDecorFitsSystemWindows(window, false)*/ + } } diff --git a/lib/common/core/assets_const.dart b/lib/common/core/assets_const.dart index bdaa341..622a1c9 100644 --- a/lib/common/core/assets_const.dart +++ b/lib/common/core/assets_const.dart @@ -1,5 +1,6 @@ class AssetsConst { - static const String _assetImagePrefix = "assets/images/"; - static const String wowLogo = "wow_logo.png"; - static const String icVip = "ic_vip.png"; + static const String _assetImagePrefix = 'assets/images/'; + static const String wowLogo = '${_assetImagePrefix}wow_logo.png'; + static const String icVip = '${_assetImagePrefix}ic_vip.png'; +//static String get icVip2 =>'ic_vip.png'.assetImg; } diff --git a/lib/common/pages/wow_web_page.dart b/lib/common/pages/wow_web_page.dart index 2f8859e..55743df 100644 --- a/lib/common/pages/wow_web_page.dart +++ b/lib/common/pages/wow_web_page.dart @@ -1,9 +1,5 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:limiting_direction_csx/limiting_direction_csx.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:wow_english/common/widgets/we_app_bar.dart'; @@ -26,12 +22,11 @@ class _WowWebViewPageState extends State { @override void initState() { super.initState(); - - if (Platform.isIOS) { + /*if (Platform.isIOS) { LimitingDirectionCsx.setScreenDirection(DeviceDirectionMask.PortraitUpsideDown); } else { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - } + }*/ final WebViewController controller =WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) @@ -69,14 +64,4 @@ class _WowWebViewPageState extends State { body: WebViewWidget(controller: _controller,), ); } - - @override - void deactivate() { - super.deactivate(); - if (Platform.isIOS) { - LimitingDirectionCsx.setScreenDirection(DeviceDirectionMask.Landscape); - } else { - SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight]); - } - } -} \ No newline at end of file +} diff --git a/lib/common/request/apis.dart b/lib/common/request/apis.dart index c57c30b..4429056 100644 --- a/lib/common/request/apis.dart +++ b/lib/common/request/apis.dart @@ -10,6 +10,12 @@ class Apis { /// 登出 static const String logout = 'logout'; + /// 获取用户信息 + static const String getUserInfo = 'student/info'; + + /// 更新用户信息 + static const String setUserInfo = 'student/update/info'; + /// 发送验证码 static const String sendSmsCode = 'system/send/code'; diff --git a/lib/common/request/dao/user_dao.dart b/lib/common/request/dao/user_dao.dart index e164544..88e7625 100644 --- a/lib/common/request/dao/user_dao.dart +++ b/lib/common/request/dao/user_dao.dart @@ -5,6 +5,7 @@ import '../apis.dart'; import '../request_client.dart'; class UserDao { + /// 登录 static Future login(phoneNumber, type, checkKey, checkNumber) async { var params = {'phoneNum': phoneNumber, 'type': type, checkKey: checkNumber}; var data = await requestClient.post( @@ -17,10 +18,27 @@ class UserDao { return data; } - static Future sendCode(phoneNumber,{smsType ='login'}) async { - final params = {'phoneNum':phoneNumber,'smsType':smsType}; - await requestClient.post( - Apis.sendSmsCode,data: params - ); + /// 登出 + static Future logout() async { + var result = await requestClient.post(Apis.logout); + print('logout result=$result'); + UserUtil.logout(); + return result; + } + + /// 发送验证码 + static Future sendCode(phoneNumber, {smsType = 'login'}) async { + final params = {'phoneNum': phoneNumber, 'smsType': smsType}; + await requestClient.post(Apis.sendSmsCode, data: params); + } + + /// 获取用户信息 + static Future getUserInfo() async { + return await requestClient.post(Apis.getUserInfo); + } + + /// 更新用户信息,返回即成功,无body + static Future updateUserInfo(UserEntity userEntity) async { + return await requestClient.put(Apis.setUserInfo, data: userEntity.toUpdateJson()); } } diff --git a/lib/common/widgets/ow_image_widget.dart b/lib/common/widgets/ow_image_widget.dart index 7b1bc74..b9cdc01 100644 --- a/lib/common/widgets/ow_image_widget.dart +++ b/lib/common/widgets/ow_image_widget.dart @@ -16,7 +16,7 @@ class OwImageWidget extends StatelessWidget { width: width, ); } - return name.contains('http')? + return name.startsWith('http')? CachedNetworkImage( imageUrl: name, height: height, @@ -29,4 +29,4 @@ class OwImageWidget extends StatelessWidget { fit: fit, ); } -} \ No newline at end of file +} diff --git a/lib/generated/json/user_entity.g.dart b/lib/generated/json/user_entity.g.dart index 2217112..456b6d9 100644 --- a/lib/generated/json/user_entity.g.dart +++ b/lib/generated/json/user_entity.g.dart @@ -11,6 +11,10 @@ UserEntity $UserEntityFromJson(Map json) { if (name != null) { userEntity.name = name; } + final String? token = jsonConvert.convert(json['token']); + if (token != null) { + userEntity.token = token; + } final int? age = jsonConvert.convert(json['age']); if (age != null) { userEntity.age = age; @@ -27,13 +31,17 @@ UserEntity $UserEntityFromJson(Map json) { if (phoneNum != null) { userEntity.phoneNum = phoneNum; } - final String? token = jsonConvert.convert(json['token']); - if (token != null) { - userEntity.token = token; + final int? fillUserInfo = jsonConvert.convert(json['fillUserInfo']); + if (fillUserInfo != null) { + userEntity.fillUserInfo = fillUserInfo; + } + final int? nowCourseModuleId = jsonConvert.convert(json['nowCourseModuleId']); + if (nowCourseModuleId != null) { + userEntity.nowCourseModuleId = nowCourseModuleId; } - final int? expireTime = jsonConvert.convert(json['expireTime']); - if (expireTime != null) { - userEntity.expireTime = expireTime; + final String? effectiveDate = jsonConvert.convert(json['effectiveDate']); + if (effectiveDate != null) { + userEntity.effectiveDate = effectiveDate; } return userEntity; } @@ -42,11 +50,13 @@ Map $UserEntityToJson(UserEntity entity) { final Map data = {}; data['id'] = entity.id; data['name'] = entity.name; + data['token'] = entity.token; data['age'] = entity.age; data['gender'] = entity.gender; data['avatarUrl'] = entity.avatarUrl; data['phoneNum'] = entity.phoneNum; - data['token'] = entity.token; - data['expireTime'] = entity.expireTime; + data['fillUserInfo'] = entity.fillUserInfo; + data['nowCourseModuleId'] = entity.nowCourseModuleId; + data['effectiveDate'] = entity.effectiveDate; return data; -} \ No newline at end of file +} diff --git a/lib/models/response_model.dart.txt b/lib/models/response_model.dart.txt deleted file mode 100644 index 3f891db..0000000 --- a/lib/models/response_model.dart.txt +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'response_model.g.dart'; - -@JsonSerializable() -class ResponseModel { - int? code; - dynamic data; - String? msg; - - ResponseModel(this.code,this.data,this.msg); - - factory ResponseModel.fromJson(Map json) => _$ResponseModelFromJson(json); - - Map toJson() => _$ResponseModelToJson(this); -} diff --git a/lib/models/response_model.g.dart.txt b/lib/models/response_model.g.dart.txt deleted file mode 100644 index f7e30ec..0000000 --- a/lib/models/response_model.g.dart.txt +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'response_model.dart.txt'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -ResponseModel _$ResponseModelFromJson(Map json) => - ResponseModel( - json['code'] as int?, - json['data'], - json['msg'] as String?, - ); - -Map _$ResponseModelToJson(ResponseModel instance) => - { - 'code': instance.code, - 'data': instance.data, - 'msg': instance.msg, - }; diff --git a/lib/models/user_entity.dart b/lib/models/user_entity.dart index 5560c49..09cf1fd 100644 --- a/lib/models/user_entity.dart +++ b/lib/models/user_entity.dart @@ -7,14 +7,27 @@ import 'package:wow_english/generated/json/user_entity.g.dart'; class UserEntity { late int id; late String name; + + /// 一定有也必须要有 + late String token; + + //late int expireTime; + int? age; /// 性别:0, 1 int? gender; String? avatarUrl; - late String phoneNum; - late String token; - late int expireTime; + String? phoneNum; + + /// 用户信息是否填写 0.未填写 1.已经填写 + int? fillUserInfo; + + /// 当前模块Id + int? nowCourseModuleId; + + /// 有效时间,VIP,为null没有 + String? effectiveDate; UserEntity(); @@ -26,4 +39,21 @@ class UserEntity { String toString() { return jsonEncode(this); } + + Map toUpdateJson() { + final Map data = {}; + data['name'] = name; + data['age'] = age; + data['gender'] = gender; + data['avatarUrl'] = avatarUrl; + return data; + } + + String getGenderString() { + return gender == null + ? '' + : gender == 0 + ? '男' + : '女'; + } } diff --git a/lib/network/api.dart.txt b/lib/network/api.dart.txt deleted file mode 100644 index 65f2840..0000000 --- a/lib/network/api.dart.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Api { - /// app初始化配置信息 - // GET /system/app/config - // 接口地址:https://app.apifox.com/link/project/2684751/apis/api-89897678 - static const String appConfig = '/system/app/config'; - - /// 登陆 - static const String login = 'login'; - - /// 登出 - static const String logout = 'logout'; - - /// 发送验证码 - static const String sendSmsCode = '/system/send/code'; - - /// 课程模块 - // GET /home/courseModule - // 接口地址:https://app.apifox.com/link/project/2684751/apis/api-89897663 - static const String courseModule = '/home/courseModule'; - - /// 课程列表 - // GET /home/courseLesson - // 接口地址:https://app.apifox.com/link/project/2684751/apis/api-89897662 - static const String courseLesson = '/home/courseLesson'; -} diff --git a/lib/network/basic_configuration.dart.txt b/lib/network/basic_configuration.dart.txt deleted file mode 100644 index c4c60cb..0000000 --- a/lib/network/basic_configuration.dart.txt +++ /dev/null @@ -1,34 +0,0 @@ -enum DevelopEvent { - ///开发环境 - dev, - - ///正式环境 - formal -} - -class BasicConfigurationManager { - factory BasicConfigurationManager() => _getInstance(); - - static BasicConfigurationManager? _instance; - - //服务器地址 - String? baseUrl; - - //SessionId - String? sessionId; - - BasicConfigurationManager._internal() { - DevelopEvent developType = DevelopEvent.dev; - if (developType == DevelopEvent.dev) { - baseUrl = 'http://wow-app.dev.kouyuxingqiu.com/'; - } else { - baseUrl = 'http://wow-app.dev.kouyuxingqiu.com/'; - } - sessionId = ''; - } - - static BasicConfigurationManager _getInstance() { - _instance ??= BasicConfigurationManager._internal(); - return _instance!; - } -} diff --git a/lib/network/network_manager.dart.txt b/lib/network/network_manager.dart.txt deleted file mode 100644 index 9522223..0000000 --- a/lib/network/network_manager.dart.txt +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; -import 'package:wow_english/models/response_model.dart'; -import 'package:wow_english/network/basic_configuration.dart.txt'; - -enum HttpMethod { - get, - put, - post, - head, - patch, - delete, -} - -class DioUtil { - static final Dio _dio = getDefDio(); - - static Dio getDefDio() { - Dio dio = Dio(); - dio.options = getDefOptions(); - return dio; - } - - static BaseOptions getDefOptions() { - final BaseOptions options = BaseOptions(); - options.baseUrl = BasicConfigurationManager().baseUrl ?? ''; - options.connectTimeout = const Duration(milliseconds: 1000); - options.receiveTimeout = const Duration(milliseconds: 1000); - return options; - } - - Future requestData( - HttpMethod method, - String path, { - data, - Function? successCallBack, - Function? errorCallBack, - Map? queryParameters, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - try { - Map headers = {}; - - if (method == HttpMethod.post) { - headers['content-type'] = 'application/json'; - } - Response response; - response = await _dio.request(path, - data: data ?? {}, - queryParameters: queryParameters, - options: Options(method: method.name, headers: headers), - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress); - int statusCode = response.statusCode ?? 0; - if (statusCode >= 200 && statusCode < 300) { - if (kDebugMode) { - print(response.data); - } - final ResponseModel model = ResponseModel.fromJson(response.data); - if (model.code == 200) { - successCallBack?.call(response.data); - } else { - errorCallBack?.call(model.msg); - } - } else { - errorCallBack?.call('请求失败'); - } - } on DioException catch (error) { - if (kDebugMode) { - print(error); - } - errorCallBack?.call("网络错误: ${error.message}"); - } - } -} diff --git a/lib/pages/login/loginpage/login_page.dart b/lib/pages/login/loginpage/login_page.dart index c504c84..bb05564 100644 --- a/lib/pages/login/loginpage/login_page.dart +++ b/lib/pages/login/loginpage/login_page.dart @@ -104,7 +104,7 @@ class _LoginPageView extends StatelessWidget { recognizer: TapGestureRecognizer() ..onTap = () { Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { - 'urlStr': 'https://www.zhihu.com', + 'urlStr': 'http://page.kouyuxingqiu.com/%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8F%8A%E4%BD%BF%E7%94%A8APP%E9%9A%90%E7%A7%81%E5%8D%8F%E8%AE%AE.html', 'webViewTitle': '用户隐私协议' }); }), @@ -116,7 +116,7 @@ class _LoginPageView extends StatelessWidget { recognizer: TapGestureRecognizer() ..onTap = () { Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { - 'urlStr': 'https://www.zhihu.com', + 'urlStr': 'https://ishowedu-public-images.ishowedu.com/%E5%8F%A3%E8%AF%AD%E6%98%9F%E7%90%83%E5%84%BF%E7%AB%A5%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4%E6%94%BF%E7%AD%96_iShowLD%E4%BF%AE%E8%AE%A2_20210913%281%29.html', 'webViewTitle': '儿童隐私协议' }); }) diff --git a/lib/pages/user/bloc/user_bloc.dart b/lib/pages/user/bloc/user_bloc.dart index 377b2aa..2db7551 100644 --- a/lib/pages/user/bloc/user_bloc.dart +++ b/lib/pages/user/bloc/user_bloc.dart @@ -1,13 +1,20 @@ import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; +import 'package:wow_english/common/request/dao/user_dao.dart'; part 'user_event.dart'; part 'user_state.dart'; class UserBloc extends Bloc { UserBloc() : super(UserInitial()) { + on(_test); on((event, emit) { // TODO: implement event handler }); } + + void _test(UserLogout event, Emitter emitter) async { + print('UserBloc._test, event: $event, emitter: $emitter'); + await UserDao.logout(); + } } diff --git a/lib/pages/user/bloc/user_event.dart b/lib/pages/user/bloc/user_event.dart index 3dd7c37..60941d5 100644 --- a/lib/pages/user/bloc/user_event.dart +++ b/lib/pages/user/bloc/user_event.dart @@ -2,3 +2,7 @@ part of 'user_bloc.dart'; @immutable abstract class UserEvent {} + +class UserStarted extends UserEvent {} + +class UserLogout extends UserEvent {} diff --git a/lib/pages/user/user_page.dart b/lib/pages/user/user_page.dart index d6c2374..b28454a 100644 --- a/lib/pages/user/user_page.dart +++ b/lib/pages/user/user_page.dart @@ -3,10 +3,11 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/blocs/cachebloc/cache_bloc.dart'; import 'package:wow_english/common/core/assets_const.dart'; -import 'package:wow_english/common/extension/string_extension.dart'; +import 'package:wow_english/common/widgets/ow_image_widget.dart'; import 'package:wow_english/common/widgets/we_app_bar.dart'; import 'package:wow_english/models/user_entity.dart'; import 'package:wow_english/pages/user/bloc/user_bloc.dart'; +import 'package:wow_english/route/route.dart'; class UserPage extends StatelessWidget { const UserPage({super.key}); @@ -15,7 +16,7 @@ class UserPage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => UserBloc(), - child: _UserView(), + child: const _UserView(), ); } } @@ -25,65 +26,152 @@ class _UserView extends StatelessWidget { @override Widget build(BuildContext context) { - UserEntity? user = context.read().userEntity; + final cacheBloc = BlocProvider.of(context); + final userBloc = BlocProvider.of(context); + UserEntity user = cacheBloc.userEntity!; + + // 常规按钮的字体样式 + final textStyle21sp = TextStyle( + //fontWeight: FontWeight.w600, + color: const Color(0xFF333333), + fontSize: 21.sp, + ); + + // 常规按钮的样式 + var normalButtonStyle = ButtonStyle( + side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5)), + shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.r))), + minimumSize: MaterialStateProperty.all(Size(double.infinity, 58.h)), + backgroundColor: MaterialStateProperty.all(Colors.white), + ); return Scaffold( backgroundColor: Colors.white, - appBar: WEAppBar( - // 测试用的 - titleText: user?.name ?? '个人中心', - ), + appBar: const WEAppBar(), body: SingleChildScrollView( + //padding: EdgeInsets.symmetric(horizontal: 17.w), + padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - child: Image.asset(AssetsConst.wowLogo.assetImg), constraints: BoxConstraints(maxHeight: 196.h)), - _userInfo(context), + Container(child: Image.asset(AssetsConst.wowLogo), constraints: BoxConstraints(maxHeight: 196.h)), + 30.verticalSpace, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CircleAvatar( + radius: 40.r, + backgroundColor: Color(0xFF140C10), + /*child: CircleAvatar( + radius: 38.5.r, + backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl), + ),*/ + child: ClipOval( + child: OwImageWidget(name: user.avatarUrl ?? AssetsConst.wowLogo), + )), + 32.horizontalSpace, + Expanded( + child: Column( + children: [ + Row( + children: [ + LimitedBox( + maxWidth: 220.w, + child: Text( + user.name, + //'1231231231312312312312312312312312312312312312312', + style: textStyle21sp, + overflow: TextOverflow.ellipsis, + ), + ), + 14.horizontalSpace, + Text( + user.getGenderString(), + style: textStyle21sp, + ), + 14.horizontalSpace, + Offstage( + offstage: user.effectiveDate == null, + child: Image.asset( + AssetsConst.icVip, + height: 18.h, + ), + ) + ], + ), + Offstage( + offstage: user.effectiveDate == null, + child: Row( + children: [ + Text( + "${user.effectiveDate} 到期", + style: TextStyle( + color: const Color(0xFFE11212), + fontSize: 17.sp, + ), + ) + ], + ), + ) + ], + )), + TextButton( + child: Text( + "修改个人信息>", + style: textStyle21sp, + ), + onPressed: () {}, + ) + ], + ), + 30.verticalSpace, + OutlinedButton( + onPressed: () => {}, + style: normalButtonStyle, + child: Text( + "修改密码", + style: textStyle21sp, + ), + ), + 12.verticalSpace, + OutlinedButton( + onPressed: () => {}, + style: normalButtonStyle, + child: Text( + "兑换课程", + style: textStyle21sp, + )), + 12.verticalSpace, + OutlinedButton( + onPressed: () => { + Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { + 'urlStr': 'http://page.kouyuxingqiu.com/%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8F%8A%E4%BD%BF%E7%94%A8APP%E9%9A%90%E7%A7%81%E5%8D%8F%E8%AE%AE.html', + 'webViewTitle': '隐私协议' + }) + }, + style: normalButtonStyle, + child: Text( + "隐私协议", + style: textStyle21sp, + )), + 30.verticalSpace, + OutlinedButton( + onPressed: () => {userBloc.add(UserLogout())}, + style: ButtonStyle( + side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5)), + shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.r))), + minimumSize: MaterialStateProperty.all(Size(295.w, 40.h)), + backgroundColor: MaterialStateProperty.all(Color(0xFFFBB621)), + ), + child: Text( + "退出登陆", + style: TextStyle( + //fontWeight: FontWeight.w600, + color: Colors.white, + fontSize: 17.sp, + ), + )), ], ), )); } - - Widget _userInfo(BuildContext context) { - return Row( - children: [ - Image.asset( - AssetsConst.wowLogo.assetImg, - width: 80, - height: 80, - ), - Column( - children: [ - Row( - children: [ - Text( - context.read().userEntity?.name ?? '----', - style: TextStyle( - color: const Color(0xFF333333), - fontSize: 21.sp, - ), - ), - //Text(context.read().userEntity?.gender ?? '--'), - Image.asset( - AssetsConst.wowLogo.assetImg, - height: 18.h, - ), - ], - ), - Row( - children: [ - Text( - "什么时候到期", - style: TextStyle( - color: const Color(0xFFE11212), - fontSize: 17.sp, - ), - ) - ], - ) - ], - ), - ], - ); - } } diff --git a/lib/utils/image_util.dart b/lib/utils/image_util.dart new file mode 100644 index 0000000..fe427e9 --- /dev/null +++ b/lib/utils/image_util.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; +import 'package:wow_english/common/core/assets_const.dart'; + +class ImageUtil { + static ImageProvider getImageProviderOnDefault(String? uri, {scale = 1.0}) { + if (uri == null || uri.isEmpty) { + return ExactAssetImage(AssetsConst.wowLogo, scale: scale); + } + if (uri.startsWith('http')) { + return NetworkImage(uri); + } else { + return ExactAssetImage(uri, scale: scale); + } + //return uri.startsWith('http') ? NetworkImage(uri) : ExactAssetImage(uri, scale: 0.5) as ImageProvider?; + } +}