From 4224b3f8899ff5a32b51162f1112cba607b76a44 Mon Sep 17 00:00:00 2001 From: wuqifeng <540416539@qq.com> Date: Sun, 21 Apr 2024 22:08:35 +0800 Subject: [PATCH] feat:支付详情页ui --- assets/images/apple_pay.png | Bin 0 -> 1821 bytes assets/images/btn_pay.png | Bin 0 -> 46946 bytes assets/images/checked.png | Bin 0 -> 3280 bytes assets/images/unchecked.png | Bin 0 -> 3192 bytes assets/images/weixin.png | Bin 0 -> 3880 bytes assets/images/zhifubao.png | Bin 0 -> 4748 bytes lib/app/app.dart | 3 +-- lib/generated/json/aliyun_oss_upload_sts_entity.g.dart | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------- lib/generated/json/base/json_convert_content.dart | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------ lib/generated/json/base/json_field.dart | 13 ++++++++++--- lib/generated/json/course_entity.g.dart | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------- lib/generated/json/course_module_entity.g.dart | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------- lib/generated/json/course_process_entity.g.dart | 667 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- lib/generated/json/follow_read_entity.g.dart | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------- lib/generated/json/listen_entity.g.dart | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------- lib/generated/json/product_entity.g.dart | 33 +++++++++++++++++++++++++++++++++ lib/generated/json/read_content_entity.g.dart | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------- lib/generated/json/user_entity.g.dart | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------ lib/models/product_entity.dart | 22 ++++++++++++++++++++++ lib/pages/shop/home/shop_home_page.dart | 1 + lib/pages/shopping/bloc.dart | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/pages/shopping/event.dart | 11 +++++++++++ lib/pages/shopping/state.dart | 11 +++++++++++ lib/pages/shopping/view.dart | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/route/route.dart | 4 ++++ pubspec.yaml | 4 ++-- 26 files changed, 1643 insertions(+), 824 deletions(-) create mode 100644 assets/images/apple_pay.png create mode 100644 assets/images/btn_pay.png create mode 100644 assets/images/checked.png create mode 100644 assets/images/unchecked.png create mode 100644 assets/images/weixin.png create mode 100644 assets/images/zhifubao.png create mode 100644 lib/generated/json/product_entity.g.dart create mode 100644 lib/models/product_entity.dart create mode 100644 lib/pages/shopping/bloc.dart create mode 100644 lib/pages/shopping/event.dart create mode 100644 lib/pages/shopping/state.dart create mode 100644 lib/pages/shopping/view.dart diff --git a/assets/images/apple_pay.png b/assets/images/apple_pay.png new file mode 100644 index 0000000..2850364 Binary files /dev/null and b/assets/images/apple_pay.png differ diff --git a/assets/images/btn_pay.png b/assets/images/btn_pay.png new file mode 100644 index 0000000..8480685 Binary files /dev/null and b/assets/images/btn_pay.png differ diff --git a/assets/images/checked.png b/assets/images/checked.png new file mode 100644 index 0000000..7c56172 Binary files /dev/null and b/assets/images/checked.png differ diff --git a/assets/images/unchecked.png b/assets/images/unchecked.png new file mode 100644 index 0000000..d6676b5 Binary files /dev/null and b/assets/images/unchecked.png differ diff --git a/assets/images/weixin.png b/assets/images/weixin.png new file mode 100644 index 0000000..931bf9e Binary files /dev/null and b/assets/images/weixin.png differ diff --git a/assets/images/zhifubao.png b/assets/images/zhifubao.png new file mode 100644 index 0000000..a8b77a8 Binary files /dev/null and b/assets/images/zhifubao.png differ diff --git a/lib/app/app.dart b/lib/app/app.dart index 7315ad0..80b5808 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -2,8 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:responsive_framework/breakpoint.dart'; -import 'package:responsive_framework/responsive_breakpoints.dart'; +import 'package:responsive_framework/responsive_framework.dart'; import 'package:wow_english/common/blocs/cachebloc/cache_bloc.dart'; import 'package:wow_english/common/widgets/hide_keyboard_widget.dart'; import 'package:wow_english/pages/tab/blocs/tab_bloc.dart'; diff --git a/lib/generated/json/aliyun_oss_upload_sts_entity.g.dart b/lib/generated/json/aliyun_oss_upload_sts_entity.g.dart index 2dfdcca..8d02452 100644 --- a/lib/generated/json/aliyun_oss_upload_sts_entity.g.dart +++ b/lib/generated/json/aliyun_oss_upload_sts_entity.g.dart @@ -1,87 +1,136 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/aliyun_oss_upload_sts_entity.dart'; -AliyunOssUploadStsEntity $AliyunOssUploadStsEntityFromJson(Map json) { - final AliyunOssUploadStsEntity aliyunOssUploadStsEntity = AliyunOssUploadStsEntity(); - final String? securityToken = jsonConvert.convert(json['securityToken']); - if (securityToken != null) { - aliyunOssUploadStsEntity.securityToken = securityToken; - } - final String? expiration = jsonConvert.convert(json['expiration']); - if (expiration != null) { - aliyunOssUploadStsEntity.expiration = expiration; - } - final String? endpoint = jsonConvert.convert(json['endpoint']); - if (endpoint != null) { - aliyunOssUploadStsEntity.endpoint = endpoint; - } - final String? fileKey = jsonConvert.convert(json['fileKey']); - if (fileKey != null) { - aliyunOssUploadStsEntity.fileKey = fileKey; - } - final String? accessKeyId = jsonConvert.convert(json['accessKeyId']); - if (accessKeyId != null) { - aliyunOssUploadStsEntity.accessKeyId = accessKeyId; - } - final String? accessKeySecret = jsonConvert.convert(json['accessKeySecret']); - if (accessKeySecret != null) { - aliyunOssUploadStsEntity.accessKeySecret = accessKeySecret; - } - final String? bucket = jsonConvert.convert(json['bucket']); - if (bucket != null) { - aliyunOssUploadStsEntity.bucket = bucket; - } - final String? ossDomain = jsonConvert.convert(json['ossDomain']); - if (ossDomain != null) { - aliyunOssUploadStsEntity.ossDomain = ossDomain; - } - final String? host = jsonConvert.convert(json['host']); - if (host != null) { - aliyunOssUploadStsEntity.host = host; - } - final AliyunOssUploadStsCallbackParam? callbackParam = jsonConvert.convert(json['callbackParam']); - if (callbackParam != null) { - aliyunOssUploadStsEntity.callbackParam = callbackParam; - } - return aliyunOssUploadStsEntity; +AliyunOssUploadStsEntity $AliyunOssUploadStsEntityFromJson( + Map json) { + final AliyunOssUploadStsEntity aliyunOssUploadStsEntity = AliyunOssUploadStsEntity(); + final String? securityToken = jsonConvert.convert( + json['securityToken']); + if (securityToken != null) { + aliyunOssUploadStsEntity.securityToken = securityToken; + } + final String? expiration = jsonConvert.convert(json['expiration']); + if (expiration != null) { + aliyunOssUploadStsEntity.expiration = expiration; + } + final String? endpoint = jsonConvert.convert(json['endpoint']); + if (endpoint != null) { + aliyunOssUploadStsEntity.endpoint = endpoint; + } + final String? fileKey = jsonConvert.convert(json['fileKey']); + if (fileKey != null) { + aliyunOssUploadStsEntity.fileKey = fileKey; + } + final String? accessKeyId = jsonConvert.convert(json['accessKeyId']); + if (accessKeyId != null) { + aliyunOssUploadStsEntity.accessKeyId = accessKeyId; + } + final String? accessKeySecret = jsonConvert.convert( + json['accessKeySecret']); + if (accessKeySecret != null) { + aliyunOssUploadStsEntity.accessKeySecret = accessKeySecret; + } + final String? bucket = jsonConvert.convert(json['bucket']); + if (bucket != null) { + aliyunOssUploadStsEntity.bucket = bucket; + } + final String? ossDomain = jsonConvert.convert(json['ossDomain']); + if (ossDomain != null) { + aliyunOssUploadStsEntity.ossDomain = ossDomain; + } + final String? host = jsonConvert.convert(json['host']); + if (host != null) { + aliyunOssUploadStsEntity.host = host; + } + final AliyunOssUploadStsCallbackParam? callbackParam = jsonConvert.convert< + AliyunOssUploadStsCallbackParam>(json['callbackParam']); + if (callbackParam != null) { + aliyunOssUploadStsEntity.callbackParam = callbackParam; + } + return aliyunOssUploadStsEntity; } -Map $AliyunOssUploadStsEntityToJson(AliyunOssUploadStsEntity entity) { - final Map data = {}; - data['securityToken'] = entity.securityToken; - data['expiration'] = entity.expiration; - data['endpoint'] = entity.endpoint; - data['fileKey'] = entity.fileKey; - data['accessKeyId'] = entity.accessKeyId; - data['accessKeySecret'] = entity.accessKeySecret; - data['bucket'] = entity.bucket; - data['ossDomain'] = entity.ossDomain; - data['host'] = entity.host; - data['callbackParam'] = entity.callbackParam.toJson(); - return data; +Map $AliyunOssUploadStsEntityToJson( + AliyunOssUploadStsEntity entity) { + final Map data = {}; + data['securityToken'] = entity.securityToken; + data['expiration'] = entity.expiration; + data['endpoint'] = entity.endpoint; + data['fileKey'] = entity.fileKey; + data['accessKeyId'] = entity.accessKeyId; + data['accessKeySecret'] = entity.accessKeySecret; + data['bucket'] = entity.bucket; + data['ossDomain'] = entity.ossDomain; + data['host'] = entity.host; + data['callbackParam'] = entity.callbackParam.toJson(); + return data; } -AliyunOssUploadStsCallbackParam $AliyunOssUploadStsCallbackParamFromJson(Map json) { - final AliyunOssUploadStsCallbackParam aliyunOssUploadStsCallbackParam = AliyunOssUploadStsCallbackParam(); - final String? callbackBody = jsonConvert.convert(json['callbackBody']); - if (callbackBody != null) { - aliyunOssUploadStsCallbackParam.callbackBody = callbackBody; - } - final String? callbackBodyType = jsonConvert.convert(json['callbackBodyType']); - if (callbackBodyType != null) { - aliyunOssUploadStsCallbackParam.callbackBodyType = callbackBodyType; - } - final String? callbackUrl = jsonConvert.convert(json['callbackUrl']); - if (callbackUrl != null) { - aliyunOssUploadStsCallbackParam.callbackUrl = callbackUrl; - } - return aliyunOssUploadStsCallbackParam; +extension AliyunOssUploadStsEntityExtension on AliyunOssUploadStsEntity { + AliyunOssUploadStsEntity copyWith({ + String? securityToken, + String? expiration, + String? endpoint, + String? fileKey, + String? accessKeyId, + String? accessKeySecret, + String? bucket, + String? ossDomain, + String? host, + AliyunOssUploadStsCallbackParam? callbackParam, + }) { + return AliyunOssUploadStsEntity() + ..securityToken = securityToken ?? this.securityToken + ..expiration = expiration ?? this.expiration + ..endpoint = endpoint ?? this.endpoint + ..fileKey = fileKey ?? this.fileKey + ..accessKeyId = accessKeyId ?? this.accessKeyId + ..accessKeySecret = accessKeySecret ?? this.accessKeySecret + ..bucket = bucket ?? this.bucket + ..ossDomain = ossDomain ?? this.ossDomain + ..host = host ?? this.host + ..callbackParam = callbackParam ?? this.callbackParam; + } } -Map $AliyunOssUploadStsCallbackParamToJson(AliyunOssUploadStsCallbackParam entity) { - final Map data = {}; - data['callbackBody'] = entity.callbackBody; - data['callbackBodyType'] = entity.callbackBodyType; - data['callbackUrl'] = entity.callbackUrl; - return data; +AliyunOssUploadStsCallbackParam $AliyunOssUploadStsCallbackParamFromJson( + Map json) { + final AliyunOssUploadStsCallbackParam aliyunOssUploadStsCallbackParam = AliyunOssUploadStsCallbackParam(); + final String? callbackBody = jsonConvert.convert( + json['callbackBody']); + if (callbackBody != null) { + aliyunOssUploadStsCallbackParam.callbackBody = callbackBody; + } + final String? callbackBodyType = jsonConvert.convert( + json['callbackBodyType']); + if (callbackBodyType != null) { + aliyunOssUploadStsCallbackParam.callbackBodyType = callbackBodyType; + } + final String? callbackUrl = jsonConvert.convert(json['callbackUrl']); + if (callbackUrl != null) { + aliyunOssUploadStsCallbackParam.callbackUrl = callbackUrl; + } + return aliyunOssUploadStsCallbackParam; } + +Map $AliyunOssUploadStsCallbackParamToJson( + AliyunOssUploadStsCallbackParam entity) { + final Map data = {}; + data['callbackBody'] = entity.callbackBody; + data['callbackBodyType'] = entity.callbackBodyType; + data['callbackUrl'] = entity.callbackUrl; + return data; +} + +extension AliyunOssUploadStsCallbackParamExtension on AliyunOssUploadStsCallbackParam { + AliyunOssUploadStsCallbackParam copyWith({ + String? callbackBody, + String? callbackBodyType, + String? callbackUrl, + }) { + return AliyunOssUploadStsCallbackParam() + ..callbackBody = callbackBody ?? this.callbackBody + ..callbackBodyType = callbackBodyType ?? this.callbackBodyType + ..callbackUrl = callbackUrl ?? this.callbackUrl; + } +} \ No newline at end of file diff --git a/lib/generated/json/base/json_convert_content.dart b/lib/generated/json/base/json_convert_content.dart index 2b24e4c..bac27fe 100644 --- a/lib/generated/json/base/json_convert_content.dart +++ b/lib/generated/json/base/json_convert_content.dart @@ -10,30 +10,47 @@ import 'package:wow_english/models/course_module_entity.dart'; import 'package:wow_english/models/course_process_entity.dart'; import 'package:wow_english/models/follow_read_entity.dart'; import 'package:wow_english/models/listen_entity.dart'; +import 'package:wow_english/models/product_entity.dart'; import 'package:wow_english/models/read_content_entity.dart'; import 'package:wow_english/models/user_entity.dart'; JsonConvert jsonConvert = JsonConvert(); + typedef JsonConvertFunction = T Function(Map json); typedef EnumConvertFunction = T Function(String value); +typedef ConvertExceptionHandler = void Function(Object error, StackTrace stackTrace); +extension MapSafeExt on Map { + T? getOrNull(K? key) { + if (!containsKey(key) || key == null) { + return null; + } else { + return this[key] as T?; + } + } +} class JsonConvert { - static final Map convertFuncMap = { - (AliyunOssUploadStsEntity).toString(): AliyunOssUploadStsEntity.fromJson, - (AliyunOssUploadStsCallbackParam).toString(): AliyunOssUploadStsCallbackParam.fromJson, - (CourseEntity).toString(): CourseEntity.fromJson, - (CourseCourseLessons).toString(): CourseCourseLessons.fromJson, - (CourseModuleEntity).toString(): CourseModuleEntity.fromJson, - (CourseProcessEntity).toString(): CourseProcessEntity.fromJson, - (CourseProcessReadings).toString(): CourseProcessReadings.fromJson, - (CourseProcessTopics).toString(): CourseProcessTopics.fromJson, - (CourseProcessTopicsTopicAnswerList).toString(): CourseProcessTopicsTopicAnswerList.fromJson, - (CourseProcessVideos).toString(): CourseProcessVideos.fromJson, - (FollowReadEntity).toString(): FollowReadEntity.fromJson, - (ListenEntity).toString(): ListenEntity.fromJson, - (ReadContentEntity).toString(): ReadContentEntity.fromJson, - (UserEntity).toString(): UserEntity.fromJson, - }; + static ConvertExceptionHandler? onError; + JsonConvertClassCollection convertFuncMap = JsonConvertClassCollection(); + + /// When you are in the development, to generate a new model class, hot-reload doesn't find new generation model class, you can build on MaterialApp method called jsonConvert. ReassembleConvertFuncMap (); This method only works in a development environment + /// https://flutter.cn/docs/development/tools/hot-reload + /// class MyApp extends StatelessWidget { + /// const MyApp({Key? key}) + /// : super(key: key); + /// + /// @override + /// Widget build(BuildContext context) { + /// jsonConvert.reassembleConvertFuncMap(); + /// return MaterialApp(); + /// } + /// } + void reassembleConvertFuncMap() { + bool isReleaseMode = const bool.fromEnvironment('dart.vm.product'); + if (!isReleaseMode) { + convertFuncMap = JsonConvertClassCollection(); + } + } T? convert(dynamic value, {EnumConvertFunction? enumConvert}) { if (value == null) { @@ -46,30 +63,43 @@ class JsonConvert { return _asT(value, enumConvert: enumConvert); } catch (e, stackTrace) { debugPrint('asT<$T> $e $stackTrace'); + if (onError != null) { + onError!(e, stackTrace); + } return null; } } - List? convertList(List? value, {EnumConvertFunction? enumConvert}) { + List? convertList(List? value, + {EnumConvertFunction? enumConvert}) { if (value == null) { return null; } try { - return value.map((dynamic e) => _asT(e,enumConvert: enumConvert)).toList(); + return value.map((dynamic e) => _asT(e, enumConvert: enumConvert)) + .toList(); } catch (e, stackTrace) { debugPrint('asT<$T> $e $stackTrace'); + if (onError != null) { + onError!(e, stackTrace); + } return []; } } -List? convertListNotNull(dynamic value, {EnumConvertFunction? enumConvert}) { + List? convertListNotNull(dynamic value, + {EnumConvertFunction? enumConvert}) { if (value == null) { return null; } try { - return (value as List).map((dynamic e) => _asT(e,enumConvert: enumConvert)!).toList(); + return (value as List).map((dynamic e) => + _asT(e, enumConvert: enumConvert)!).toList(); } catch (e, stackTrace) { debugPrint('asT<$T> $e $stackTrace'); + if (onError != null) { + onError!(e, stackTrace); + } return []; } } @@ -102,68 +132,126 @@ List? convertListNotNull(dynamic value, {EnumConvertFunction? enumConvert} return value as T; } else { if (convertFuncMap.containsKey(type)) { - return convertFuncMap[type]!(Map.from(value)) as T; + if (value == null) { + return null; + } + return convertFuncMap[type]!(value as Map) as T; } else { - throw UnimplementedError('$type unimplemented'); + throw UnimplementedError( + '$type unimplemented,you can try running the app again'); } } } - //list is returned by type - static M? _getListChildType(List> data) { - if([] is M){ - return data.map((Map e) => AliyunOssUploadStsEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => AliyunOssUploadStsCallbackParam.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseCourseLessons.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseModuleEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseProcessEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseProcessReadings.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseProcessTopics.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseProcessTopicsTopicAnswerList.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => CourseProcessVideos.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => FollowReadEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => ListenEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => ReadContentEntity.fromJson(e)).toList() as M; - } - if([] is M){ - return data.map((Map e) => UserEntity.fromJson(e)).toList() as M; - } - - debugPrint("${M.toString()} not found"); - - return null; -} + //list is returned by type + static M? _getListChildType(List> data) { + if ([] is M) { + return data.map((Map e) => + AliyunOssUploadStsEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map(( + Map e) => + AliyunOssUploadStsCallbackParam.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseCourseLessons.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseModuleEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseProcessEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseProcessReadings.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseProcessTopics.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map(( + Map e) => + CourseProcessTopicsTopicAnswerList.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + CourseProcessVideos.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + FollowReadEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + ListenEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + ProductEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + ReadContentEntity.fromJson(e)).toList() as M; + } + if ([] is M) { + return data.map((Map e) => + UserEntity.fromJson(e)).toList() as M; + } - static M? fromJsonAsT(dynamic json) { - if (json is List) { - return _getListChildType(json.map((e) => e as Map).toList()); - } else { - return jsonConvert.convert(json); - } - } + debugPrint("$M not found"); + + return null; + } + + static M? fromJsonAsT(dynamic json) { + if (json is M) { + return json; + } + if (json is List) { + return _getListChildType( + json.map((dynamic e) => e as Map).toList()); + } else { + return jsonConvert.convert(json); + } + } } + +class JsonConvertClassCollection { + Map convertFuncMap = { + (AliyunOssUploadStsEntity).toString(): AliyunOssUploadStsEntity.fromJson, + (AliyunOssUploadStsCallbackParam) + .toString(): AliyunOssUploadStsCallbackParam.fromJson, + (CourseEntity).toString(): CourseEntity.fromJson, + (CourseCourseLessons).toString(): CourseCourseLessons.fromJson, + (CourseModuleEntity).toString(): CourseModuleEntity.fromJson, + (CourseProcessEntity).toString(): CourseProcessEntity.fromJson, + (CourseProcessReadings).toString(): CourseProcessReadings.fromJson, + (CourseProcessTopics).toString(): CourseProcessTopics.fromJson, + (CourseProcessTopicsTopicAnswerList) + .toString(): CourseProcessTopicsTopicAnswerList.fromJson, + (CourseProcessVideos).toString(): CourseProcessVideos.fromJson, + (FollowReadEntity).toString(): FollowReadEntity.fromJson, + (ListenEntity).toString(): ListenEntity.fromJson, + (ProductEntity).toString(): ProductEntity.fromJson, + (ReadContentEntity).toString(): ReadContentEntity.fromJson, + (UserEntity).toString(): UserEntity.fromJson, + }; + + bool containsKey(String type) { + return convertFuncMap.containsKey(type); + } + + JsonConvertFunction? operator [](String key) { + return convertFuncMap[key]; + } +} \ No newline at end of file diff --git a/lib/generated/json/base/json_field.dart b/lib/generated/json/base/json_field.dart index a2fcac9..8c967d4 100644 --- a/lib/generated/json/base/json_field.dart +++ b/lib/generated/json/base/json_field.dart @@ -4,10 +4,14 @@ // This file is automatically generated. DO NOT EDIT, all your changes would be lost. -class JsonSerializable{ - const JsonSerializable(); +import 'package:meta/meta_meta.dart'; + +@Target({TargetKind.classType}) +class JsonSerializable { + const JsonSerializable(); } +@Target({TargetKind.field}) class JSONField { //Specify the parse field name final String? name; @@ -18,8 +22,11 @@ class JSONField { //Whether to participate in fromMap final bool? deserialize; + //Whether to participate in copyWith + final bool? copyWith; + //Enumeration or not final bool? isEnum; - const JSONField({this.name, this.serialize, this.deserialize, this.isEnum}); + const JSONField({this.name, this.serialize, this.deserialize, this.isEnum, this.copyWith}); } diff --git a/lib/generated/json/course_entity.g.dart b/lib/generated/json/course_entity.g.dart index 1b95459..bf01762 100644 --- a/lib/generated/json/course_entity.g.dart +++ b/lib/generated/json/course_entity.g.dart @@ -2,116 +2,181 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/course_entity.dart'; CourseEntity $CourseEntityFromJson(Map json) { - final CourseEntity courseEntity = CourseEntity(); - final List? courseLessons = jsonConvert.convertListNotNull(json['courseLessons']); - if (courseLessons != null) { - courseEntity.courseLessons = courseLessons; - } - final int? nowCourseLesson = jsonConvert.convert(json['nowCourseLesson']); - if (nowCourseLesson != null) { - courseEntity.nowCourseLesson = nowCourseLesson; - } - final int? nowCourseModuleId = jsonConvert.convert(json['nowCourseModuleId']); - if (nowCourseModuleId != null) { - courseEntity.nowCourseModuleId = nowCourseModuleId; - } - final String? nowCourseModuleName = jsonConvert.convert(json['nowCourseModuleName']); - if (nowCourseModuleName != null) { - courseEntity.nowCourseModuleName = nowCourseModuleName; - } - final int? totalCourseLesson = jsonConvert.convert(json['totalCourseLesson']); - if (totalCourseLesson != null) { - courseEntity.totalCourseLesson = totalCourseLesson; - } - final String? courseModuleThemeColor = jsonConvert.convert(json['courseModuleThemeColor']); - if (courseModuleThemeColor != null) { - courseEntity.courseModuleThemeColor = courseModuleThemeColor; - } - final String? courseModuleCode = jsonConvert.convert(json['courseModuleCode']); - if (courseModuleCode != null) { - courseEntity.courseModuleCode = courseModuleCode; - } - return courseEntity; + final CourseEntity courseEntity = CourseEntity(); + final List< + CourseCourseLessons>? courseLessons = (json['courseLessons'] as List< + dynamic>?) + ?.map( + (e) => + jsonConvert.convert(e) as CourseCourseLessons) + .toList(); + if (courseLessons != null) { + courseEntity.courseLessons = courseLessons; + } + final int? nowCourseLesson = jsonConvert.convert( + json['nowCourseLesson']); + if (nowCourseLesson != null) { + courseEntity.nowCourseLesson = nowCourseLesson; + } + final int? nowCourseModuleId = jsonConvert.convert( + json['nowCourseModuleId']); + if (nowCourseModuleId != null) { + courseEntity.nowCourseModuleId = nowCourseModuleId; + } + final String? nowCourseModuleName = jsonConvert.convert( + json['nowCourseModuleName']); + if (nowCourseModuleName != null) { + courseEntity.nowCourseModuleName = nowCourseModuleName; + } + final int? totalCourseLesson = jsonConvert.convert( + json['totalCourseLesson']); + if (totalCourseLesson != null) { + courseEntity.totalCourseLesson = totalCourseLesson; + } + final String? courseModuleThemeColor = jsonConvert.convert( + json['courseModuleThemeColor']); + if (courseModuleThemeColor != null) { + courseEntity.courseModuleThemeColor = courseModuleThemeColor; + } + final String? courseModuleCode = jsonConvert.convert( + json['courseModuleCode']); + if (courseModuleCode != null) { + courseEntity.courseModuleCode = courseModuleCode; + } + return courseEntity; } Map $CourseEntityToJson(CourseEntity entity) { - final Map data = {}; - data['courseLessons'] = entity.courseLessons?.map((v) => v.toJson()).toList(); - data['nowCourseLesson'] = entity.nowCourseLesson; - data['nowCourseModuleId'] = entity.nowCourseModuleId; - data['nowCourseModuleName'] = entity.nowCourseModuleName; - data['totalCourseLesson'] = entity.totalCourseLesson; - data['courseModuleThemeColor'] = entity.courseModuleThemeColor; - data['courseModuleCode'] = entity.courseModuleCode; - return data; + final Map data = {}; + data['courseLessons'] = entity.courseLessons?.map((v) => v.toJson()).toList(); + data['nowCourseLesson'] = entity.nowCourseLesson; + data['nowCourseModuleId'] = entity.nowCourseModuleId; + data['nowCourseModuleName'] = entity.nowCourseModuleName; + data['totalCourseLesson'] = entity.totalCourseLesson; + data['courseModuleThemeColor'] = entity.courseModuleThemeColor; + data['courseModuleCode'] = entity.courseModuleCode; + return data; +} + +extension CourseEntityExtension on CourseEntity { + CourseEntity copyWith({ + List? courseLessons, + int? nowCourseLesson, + int? nowCourseModuleId, + String? nowCourseModuleName, + int? totalCourseLesson, + String? courseModuleThemeColor, + String? courseModuleCode, + }) { + return CourseEntity() + ..courseLessons = courseLessons ?? this.courseLessons + ..nowCourseLesson = nowCourseLesson ?? this.nowCourseLesson + ..nowCourseModuleId = nowCourseModuleId ?? this.nowCourseModuleId + ..nowCourseModuleName = nowCourseModuleName ?? this.nowCourseModuleName + ..totalCourseLesson = totalCourseLesson ?? this.totalCourseLesson + ..courseModuleThemeColor = courseModuleThemeColor ?? + this.courseModuleThemeColor + ..courseModuleCode = courseModuleCode ?? this.courseModuleCode; + } } CourseCourseLessons $CourseCourseLessonsFromJson(Map json) { - final CourseCourseLessons courseCourseLessons = CourseCourseLessons(); - final int? courseModuleId = jsonConvert.convert(json['courseModuleId']); - if (courseModuleId != null) { - courseCourseLessons.courseModuleId = courseModuleId; - } - final int? courseType = jsonConvert.convert(json['courseType']); - if (courseType != null) { - courseCourseLessons.courseType = courseType; - } - final String? coverUrl = jsonConvert.convert(json['coverUrl']); - if (coverUrl != null) { - courseCourseLessons.coverUrl = coverUrl; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseCourseLessons.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseCourseLessons.deleted = deleted; - } - final String? des = jsonConvert.convert(json['des']); - if (des != null) { - courseCourseLessons.des = des; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseCourseLessons.id = id; - } - final bool? lock = jsonConvert.convert(json['lock']); - if (lock != null) { - courseCourseLessons.lock = lock; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseCourseLessons.modifyTime = modifyTime; - } - final String? name = jsonConvert.convert(json['name']); - if (name != null) { - courseCourseLessons.name = name; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseCourseLessons.sortOrder = sortOrder; - } - final int? status = jsonConvert.convert(json['status']); - if (status != null) { - courseCourseLessons.status = status; - } - return courseCourseLessons; + final CourseCourseLessons courseCourseLessons = CourseCourseLessons(); + final int? courseModuleId = jsonConvert.convert(json['courseModuleId']); + if (courseModuleId != null) { + courseCourseLessons.courseModuleId = courseModuleId; + } + final int? courseType = jsonConvert.convert(json['courseType']); + if (courseType != null) { + courseCourseLessons.courseType = courseType; + } + final String? coverUrl = jsonConvert.convert(json['coverUrl']); + if (coverUrl != null) { + courseCourseLessons.coverUrl = coverUrl; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseCourseLessons.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseCourseLessons.deleted = deleted; + } + final String? des = jsonConvert.convert(json['des']); + if (des != null) { + courseCourseLessons.des = des; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseCourseLessons.id = id; + } + final bool? lock = jsonConvert.convert(json['lock']); + if (lock != null) { + courseCourseLessons.lock = lock; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseCourseLessons.modifyTime = modifyTime; + } + final String? name = jsonConvert.convert(json['name']); + if (name != null) { + courseCourseLessons.name = name; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseCourseLessons.sortOrder = sortOrder; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + courseCourseLessons.status = status; + } + return courseCourseLessons; } Map $CourseCourseLessonsToJson(CourseCourseLessons entity) { - final Map data = {}; - data['courseModuleId'] = entity.courseModuleId; - data['courseType'] = entity.courseType; - data['coverUrl'] = entity.coverUrl; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['des'] = entity.des; - data['id'] = entity.id; - data['lock'] = entity.lock; - data['modifyTime'] = entity.modifyTime; - data['name'] = entity.name; - data['sortOrder'] = entity.sortOrder; - data['status'] = entity.status; - return data; + final Map data = {}; + data['courseModuleId'] = entity.courseModuleId; + data['courseType'] = entity.courseType; + data['coverUrl'] = entity.coverUrl; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['des'] = entity.des; + data['id'] = entity.id; + data['lock'] = entity.lock; + data['modifyTime'] = entity.modifyTime; + data['name'] = entity.name; + data['sortOrder'] = entity.sortOrder; + data['status'] = entity.status; + return data; +} + +extension CourseCourseLessonsExtension on CourseCourseLessons { + CourseCourseLessons copyWith({ + int? courseModuleId, + int? courseType, + String? coverUrl, + String? createTime, + String? deleted, + String? des, + String? id, + bool? lock, + String? modifyTime, + String? name, + int? sortOrder, + int? status, + }) { + return CourseCourseLessons() + ..courseModuleId = courseModuleId ?? this.courseModuleId + ..courseType = courseType ?? this.courseType + ..coverUrl = coverUrl ?? this.coverUrl + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..des = des ?? this.des + ..id = id ?? this.id + ..lock = lock ?? this.lock + ..modifyTime = modifyTime ?? this.modifyTime + ..name = name ?? this.name + ..sortOrder = sortOrder ?? this.sortOrder + ..status = status ?? this.status; + } } \ No newline at end of file diff --git a/lib/generated/json/course_module_entity.g.dart b/lib/generated/json/course_module_entity.g.dart index 1e9182d..e639928 100644 --- a/lib/generated/json/course_module_entity.g.dart +++ b/lib/generated/json/course_module_entity.g.dart @@ -2,86 +2,126 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/course_module_entity.dart'; CourseModuleEntity $CourseModuleEntityFromJson(Map json) { - final CourseModuleEntity courseModuleEntity = CourseModuleEntity(); - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseModuleEntity.id = id; - } - final String? code = jsonConvert.convert(json['code']); - if (code != null) { - courseModuleEntity.code = code; - } - final int? courseModuleThemeId = jsonConvert.convert(json['courseModuleThemeId']); - if (courseModuleThemeId != null) { - courseModuleEntity.courseModuleThemeId = courseModuleThemeId; - } - final int? courseTotal = jsonConvert.convert(json['courseTotal']); - if (courseTotal != null) { - courseModuleEntity.courseTotal = courseTotal; - } - final String? coverUrl = jsonConvert.convert(json['coverUrl']); - if (coverUrl != null) { - courseModuleEntity.coverUrl = coverUrl; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseModuleEntity.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseModuleEntity.deleted = deleted; - } - final String? des = jsonConvert.convert(json['des']); - if (des != null) { - courseModuleEntity.des = des; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseModuleEntity.modifyTime = modifyTime; - } - final String? name = jsonConvert.convert(json['name']); - if (name != null) { - courseModuleEntity.name = name; - } - final int? opening = jsonConvert.convert(json['opening']); - if (opening != null) { - courseModuleEntity.opening = opening; - } - final String? picUrl = jsonConvert.convert(json['picUrl']); - if (picUrl != null) { - courseModuleEntity.picUrl = picUrl; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseModuleEntity.sortOrder = sortOrder; - } - final int? status = jsonConvert.convert(json['status']); - if (status != null) { - courseModuleEntity.status = status; - } - final String? courseModuleThemeColor = jsonConvert.convert(json['courseModuleThemeColor']); - if (courseModuleThemeColor != null) { - courseModuleEntity.courseModuleThemeColor = courseModuleThemeColor; - } - return courseModuleEntity; + final CourseModuleEntity courseModuleEntity = CourseModuleEntity(); + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseModuleEntity.id = id; + } + final String? code = jsonConvert.convert(json['code']); + if (code != null) { + courseModuleEntity.code = code; + } + final int? courseModuleThemeId = jsonConvert.convert( + json['courseModuleThemeId']); + if (courseModuleThemeId != null) { + courseModuleEntity.courseModuleThemeId = courseModuleThemeId; + } + final int? courseTotal = jsonConvert.convert(json['courseTotal']); + if (courseTotal != null) { + courseModuleEntity.courseTotal = courseTotal; + } + final String? coverUrl = jsonConvert.convert(json['coverUrl']); + if (coverUrl != null) { + courseModuleEntity.coverUrl = coverUrl; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseModuleEntity.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseModuleEntity.deleted = deleted; + } + final String? des = jsonConvert.convert(json['des']); + if (des != null) { + courseModuleEntity.des = des; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseModuleEntity.modifyTime = modifyTime; + } + final String? name = jsonConvert.convert(json['name']); + if (name != null) { + courseModuleEntity.name = name; + } + final int? opening = jsonConvert.convert(json['opening']); + if (opening != null) { + courseModuleEntity.opening = opening; + } + final String? picUrl = jsonConvert.convert(json['picUrl']); + if (picUrl != null) { + courseModuleEntity.picUrl = picUrl; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseModuleEntity.sortOrder = sortOrder; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + courseModuleEntity.status = status; + } + final String? courseModuleThemeColor = jsonConvert.convert( + json['courseModuleThemeColor']); + if (courseModuleThemeColor != null) { + courseModuleEntity.courseModuleThemeColor = courseModuleThemeColor; + } + return courseModuleEntity; } Map $CourseModuleEntityToJson(CourseModuleEntity entity) { - final Map data = {}; - data['id'] = entity.id; - data['code'] = entity.code; - data['courseModuleThemeId'] = entity.courseModuleThemeId; - data['courseTotal'] = entity.courseTotal; - data['coverUrl'] = entity.coverUrl; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['des'] = entity.des; - data['modifyTime'] = entity.modifyTime; - data['name'] = entity.name; - data['opening'] = entity.opening; - data['picUrl'] = entity.picUrl; - data['sortOrder'] = entity.sortOrder; - data['status'] = entity.status; - data['courseModuleThemeColor'] = entity.courseModuleThemeColor; - return data; + final Map data = {}; + data['id'] = entity.id; + data['code'] = entity.code; + data['courseModuleThemeId'] = entity.courseModuleThemeId; + data['courseTotal'] = entity.courseTotal; + data['coverUrl'] = entity.coverUrl; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['des'] = entity.des; + data['modifyTime'] = entity.modifyTime; + data['name'] = entity.name; + data['opening'] = entity.opening; + data['picUrl'] = entity.picUrl; + data['sortOrder'] = entity.sortOrder; + data['status'] = entity.status; + data['courseModuleThemeColor'] = entity.courseModuleThemeColor; + return data; } + +extension CourseModuleEntityExtension on CourseModuleEntity { + CourseModuleEntity copyWith({ + String? id, + String? code, + int? courseModuleThemeId, + int? courseTotal, + String? coverUrl, + String? createTime, + String? deleted, + String? des, + String? modifyTime, + String? name, + int? opening, + String? picUrl, + int? sortOrder, + int? status, + String? courseModuleThemeColor, + }) { + return CourseModuleEntity() + ..id = id ?? this.id + ..code = code ?? this.code + ..courseModuleThemeId = courseModuleThemeId ?? this.courseModuleThemeId + ..courseTotal = courseTotal ?? this.courseTotal + ..coverUrl = coverUrl ?? this.coverUrl + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..des = des ?? this.des + ..modifyTime = modifyTime ?? this.modifyTime + ..name = name ?? this.name + ..opening = opening ?? this.opening + ..picUrl = picUrl ?? this.picUrl + ..sortOrder = sortOrder ?? this.sortOrder + ..status = status ?? this.status + ..courseModuleThemeColor = courseModuleThemeColor ?? + this.courseModuleThemeColor; + } +} \ No newline at end of file diff --git a/lib/generated/json/course_process_entity.g.dart b/lib/generated/json/course_process_entity.g.dart index 3c6e33d..1f387ec 100644 --- a/lib/generated/json/course_process_entity.g.dart +++ b/lib/generated/json/course_process_entity.g.dart @@ -2,286 +2,435 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/course_process_entity.dart'; CourseProcessEntity $CourseProcessEntityFromJson(Map json) { - final CourseProcessEntity courseProcessEntity = CourseProcessEntity(); - final int? currentStep = jsonConvert.convert(json['currentStep']); - if (currentStep != null) { - courseProcessEntity.currentStep = currentStep; - } - final int? currentTime = jsonConvert.convert(json['currentTime']); - if (currentTime != null) { - courseProcessEntity.currentTime = currentTime; - } - final List? readings = jsonConvert.convertListNotNull(json['readings']); - if (readings != null) { - courseProcessEntity.readings = readings; - } - final List? topics = jsonConvert.convertListNotNull(json['topics']); - if (topics != null) { - courseProcessEntity.topics = topics; - } - final CourseProcessVideos? videos = jsonConvert.convert(json['videos']); - if (videos != null) { - courseProcessEntity.videos = videos; - } - return courseProcessEntity; + final CourseProcessEntity courseProcessEntity = CourseProcessEntity(); + final int? currentStep = jsonConvert.convert(json['currentStep']); + if (currentStep != null) { + courseProcessEntity.currentStep = currentStep; + } + final int? currentTime = jsonConvert.convert(json['currentTime']); + if (currentTime != null) { + courseProcessEntity.currentTime = currentTime; + } + final List? readings = (json['readings'] as List< + dynamic>?) + ?.map( + (e) => + jsonConvert.convert(e) as CourseProcessReadings) + .toList(); + if (readings != null) { + courseProcessEntity.readings = readings; + } + final List? topics = (json['topics'] as List?) + ?.map( + (e) => + jsonConvert.convert(e) as CourseProcessTopics) + .toList(); + if (topics != null) { + courseProcessEntity.topics = topics; + } + final CourseProcessVideos? videos = jsonConvert.convert( + json['videos']); + if (videos != null) { + courseProcessEntity.videos = videos; + } + return courseProcessEntity; } Map $CourseProcessEntityToJson(CourseProcessEntity entity) { - final Map data = {}; - data['currentStep'] = entity.currentStep; - data['currentTime'] = entity.currentTime; - data['readings'] = entity.readings?.map((v) => v.toJson()).toList(); - data['topics'] = entity.topics?.map((v) => v.toJson()).toList(); - data['videos'] = entity.videos?.toJson(); - return data; + final Map data = {}; + data['currentStep'] = entity.currentStep; + data['currentTime'] = entity.currentTime; + data['readings'] = entity.readings?.map((v) => v.toJson()).toList(); + data['topics'] = entity.topics?.map((v) => v.toJson()).toList(); + data['videos'] = entity.videos?.toJson(); + return data; } -CourseProcessReadings $CourseProcessReadingsFromJson(Map json) { - final CourseProcessReadings courseProcessReadings = CourseProcessReadings(); - final String? audioUrl = jsonConvert.convert(json['audioUrl']); - if (audioUrl != null) { - courseProcessReadings.audioUrl = audioUrl; - } - final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); - if (courseLessonId != null) { - courseProcessReadings.courseLessonId = courseLessonId; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseProcessReadings.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseProcessReadings.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseProcessReadings.id = id; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseProcessReadings.modifyTime = modifyTime; - } - final String? padPicUrl = jsonConvert.convert(json['padPicUrl']); - if (padPicUrl != null) { - courseProcessReadings.padPicUrl = padPicUrl; - } - final String? picUrl = jsonConvert.convert(json['picUrl']); - if (picUrl != null) { - courseProcessReadings.picUrl = picUrl; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseProcessReadings.sortOrder = sortOrder; - } - final String? word = jsonConvert.convert(json['word']); - if (word != null) { - courseProcessReadings.word = word; - } - final String? recordUrl = jsonConvert.convert(json['recordUrl']); - if (recordUrl != null) { - courseProcessReadings.recordUrl = recordUrl; - } - final String? recordScore = jsonConvert.convert(json['recordScore']); - if (recordScore != null) { - courseProcessReadings.recordScore = recordScore; - } - return courseProcessReadings; +extension CourseProcessEntityExtension on CourseProcessEntity { + CourseProcessEntity copyWith({ + int? currentStep, + int? currentTime, + List? readings, + List? topics, + CourseProcessVideos? videos, + }) { + return CourseProcessEntity() + ..currentStep = currentStep ?? this.currentStep + ..currentTime = currentTime ?? this.currentTime + ..readings = readings ?? this.readings + ..topics = topics ?? this.topics + ..videos = videos ?? this.videos; + } } -Map $CourseProcessReadingsToJson(CourseProcessReadings entity) { - final Map data = {}; - data['audioUrl'] = entity.audioUrl; - data['courseLessonId'] = entity.courseLessonId; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['modifyTime'] = entity.modifyTime; - data['padPicUrl'] = entity.padPicUrl; - data['picUrl'] = entity.picUrl; - data['sortOrder'] = entity.sortOrder; - data['word'] = entity.word; - data['recordUrl'] = entity.recordUrl; - data['recordScore'] = entity.recordScore; - return data; +CourseProcessReadings $CourseProcessReadingsFromJson( + Map json) { + final CourseProcessReadings courseProcessReadings = CourseProcessReadings(); + final String? audioUrl = jsonConvert.convert(json['audioUrl']); + if (audioUrl != null) { + courseProcessReadings.audioUrl = audioUrl; + } + final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); + if (courseLessonId != null) { + courseProcessReadings.courseLessonId = courseLessonId; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseProcessReadings.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseProcessReadings.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseProcessReadings.id = id; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseProcessReadings.modifyTime = modifyTime; + } + final String? padPicUrl = jsonConvert.convert(json['padPicUrl']); + if (padPicUrl != null) { + courseProcessReadings.padPicUrl = padPicUrl; + } + final String? picUrl = jsonConvert.convert(json['picUrl']); + if (picUrl != null) { + courseProcessReadings.picUrl = picUrl; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseProcessReadings.sortOrder = sortOrder; + } + final String? word = jsonConvert.convert(json['word']); + if (word != null) { + courseProcessReadings.word = word; + } + final String? recordUrl = jsonConvert.convert(json['recordUrl']); + if (recordUrl != null) { + courseProcessReadings.recordUrl = recordUrl; + } + final String? recordScore = jsonConvert.convert(json['recordScore']); + if (recordScore != null) { + courseProcessReadings.recordScore = recordScore; + } + return courseProcessReadings; +} + +Map $CourseProcessReadingsToJson( + CourseProcessReadings entity) { + final Map data = {}; + data['audioUrl'] = entity.audioUrl; + data['courseLessonId'] = entity.courseLessonId; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['modifyTime'] = entity.modifyTime; + data['padPicUrl'] = entity.padPicUrl; + data['picUrl'] = entity.picUrl; + data['sortOrder'] = entity.sortOrder; + data['word'] = entity.word; + data['recordUrl'] = entity.recordUrl; + data['recordScore'] = entity.recordScore; + return data; +} + +extension CourseProcessReadingsExtension on CourseProcessReadings { + CourseProcessReadings copyWith({ + String? audioUrl, + int? courseLessonId, + String? createTime, + String? deleted, + String? id, + String? modifyTime, + String? padPicUrl, + String? picUrl, + int? sortOrder, + String? word, + String? recordUrl, + String? recordScore, + }) { + return CourseProcessReadings() + ..audioUrl = audioUrl ?? this.audioUrl + ..courseLessonId = courseLessonId ?? this.courseLessonId + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..modifyTime = modifyTime ?? this.modifyTime + ..padPicUrl = padPicUrl ?? this.padPicUrl + ..picUrl = picUrl ?? this.picUrl + ..sortOrder = sortOrder ?? this.sortOrder + ..word = word ?? this.word + ..recordUrl = recordUrl ?? this.recordUrl + ..recordScore = recordScore ?? this.recordScore; + } } CourseProcessTopics $CourseProcessTopicsFromJson(Map json) { - final CourseProcessTopics courseProcessTopics = CourseProcessTopics(); - final String? audioUrl = jsonConvert.convert(json['audioUrl']); - if (audioUrl != null) { - courseProcessTopics.audioUrl = audioUrl; - } - final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); - if (courseLessonId != null) { - courseProcessTopics.courseLessonId = courseLessonId; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseProcessTopics.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseProcessTopics.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseProcessTopics.id = id; - } - final String? keyWord = jsonConvert.convert(json['keyWord']); - if (keyWord != null) { - courseProcessTopics.keyWord = keyWord; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseProcessTopics.modifyTime = modifyTime; - } - final String? picUrl = jsonConvert.convert(json['picUrl']); - if (picUrl != null) { - courseProcessTopics.picUrl = picUrl; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseProcessTopics.sortOrder = sortOrder; - } - final int? status = jsonConvert.convert(json['status']); - if (status != null) { - courseProcessTopics.status = status; - } - final List? topicAnswerList = jsonConvert.convertListNotNull(json['topicAnswerList']); - if (topicAnswerList != null) { - courseProcessTopics.topicAnswerList = topicAnswerList; - } - final int? type = jsonConvert.convert(json['type']); - if (type != null) { - courseProcessTopics.type = type; - } - final String? word = jsonConvert.convert(json['word']); - if (word != null) { - courseProcessTopics.word = word; - } - return courseProcessTopics; + final CourseProcessTopics courseProcessTopics = CourseProcessTopics(); + final String? audioUrl = jsonConvert.convert(json['audioUrl']); + if (audioUrl != null) { + courseProcessTopics.audioUrl = audioUrl; + } + final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); + if (courseLessonId != null) { + courseProcessTopics.courseLessonId = courseLessonId; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseProcessTopics.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseProcessTopics.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseProcessTopics.id = id; + } + final String? keyWord = jsonConvert.convert(json['keyWord']); + if (keyWord != null) { + courseProcessTopics.keyWord = keyWord; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseProcessTopics.modifyTime = modifyTime; + } + final String? picUrl = jsonConvert.convert(json['picUrl']); + if (picUrl != null) { + courseProcessTopics.picUrl = picUrl; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseProcessTopics.sortOrder = sortOrder; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + courseProcessTopics.status = status; + } + final List< + CourseProcessTopicsTopicAnswerList>? topicAnswerList = (json['topicAnswerList'] as List< + dynamic>?)?.map( + (e) => + jsonConvert.convert( + e) as CourseProcessTopicsTopicAnswerList).toList(); + if (topicAnswerList != null) { + courseProcessTopics.topicAnswerList = topicAnswerList; + } + final int? type = jsonConvert.convert(json['type']); + if (type != null) { + courseProcessTopics.type = type; + } + final String? word = jsonConvert.convert(json['word']); + if (word != null) { + courseProcessTopics.word = word; + } + return courseProcessTopics; } Map $CourseProcessTopicsToJson(CourseProcessTopics entity) { - final Map data = {}; - data['audioUrl'] = entity.audioUrl; - data['courseLessonId'] = entity.courseLessonId; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['keyWord'] = entity.keyWord; - data['modifyTime'] = entity.modifyTime; - data['picUrl'] = entity.picUrl; - data['sortOrder'] = entity.sortOrder; - data['status'] = entity.status; - data['topicAnswerList'] = entity.topicAnswerList?.map((v) => v.toJson()).toList(); - data['type'] = entity.type; - data['word'] = entity.word; - return data; + final Map data = {}; + data['audioUrl'] = entity.audioUrl; + data['courseLessonId'] = entity.courseLessonId; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['keyWord'] = entity.keyWord; + data['modifyTime'] = entity.modifyTime; + data['picUrl'] = entity.picUrl; + data['sortOrder'] = entity.sortOrder; + data['status'] = entity.status; + data['topicAnswerList'] = + entity.topicAnswerList?.map((v) => v.toJson()).toList(); + data['type'] = entity.type; + data['word'] = entity.word; + return data; +} + +extension CourseProcessTopicsExtension on CourseProcessTopics { + CourseProcessTopics copyWith({ + String? audioUrl, + int? courseLessonId, + String? createTime, + String? deleted, + String? id, + String? keyWord, + String? modifyTime, + String? picUrl, + int? sortOrder, + int? status, + List? topicAnswerList, + int? type, + String? word, + }) { + return CourseProcessTopics() + ..audioUrl = audioUrl ?? this.audioUrl + ..courseLessonId = courseLessonId ?? this.courseLessonId + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..keyWord = keyWord ?? this.keyWord + ..modifyTime = modifyTime ?? this.modifyTime + ..picUrl = picUrl ?? this.picUrl + ..sortOrder = sortOrder ?? this.sortOrder + ..status = status ?? this.status + ..topicAnswerList = topicAnswerList ?? this.topicAnswerList + ..type = type ?? this.type + ..word = word ?? this.word; + } +} + +CourseProcessTopicsTopicAnswerList $CourseProcessTopicsTopicAnswerListFromJson( + Map json) { + final CourseProcessTopicsTopicAnswerList courseProcessTopicsTopicAnswerList = CourseProcessTopicsTopicAnswerList(); + final int? correct = jsonConvert.convert(json['correct']); + if (correct != null) { + courseProcessTopicsTopicAnswerList.correct = correct; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseProcessTopicsTopicAnswerList.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseProcessTopicsTopicAnswerList.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseProcessTopicsTopicAnswerList.id = id; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseProcessTopicsTopicAnswerList.modifyTime = modifyTime; + } + final String? picUrl = jsonConvert.convert(json['picUrl']); + if (picUrl != null) { + courseProcessTopicsTopicAnswerList.picUrl = picUrl; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseProcessTopicsTopicAnswerList.sortOrder = sortOrder; + } + final int? topicId = jsonConvert.convert(json['topicId']); + if (topicId != null) { + courseProcessTopicsTopicAnswerList.topicId = topicId; + } + final String? word = jsonConvert.convert(json['word']); + if (word != null) { + courseProcessTopicsTopicAnswerList.word = word; + } + return courseProcessTopicsTopicAnswerList; } -CourseProcessTopicsTopicAnswerList $CourseProcessTopicsTopicAnswerListFromJson(Map json) { - final CourseProcessTopicsTopicAnswerList courseProcessTopicsTopicAnswerList = CourseProcessTopicsTopicAnswerList(); - final int? correct = jsonConvert.convert(json['correct']); - if (correct != null) { - courseProcessTopicsTopicAnswerList.correct = correct; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseProcessTopicsTopicAnswerList.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseProcessTopicsTopicAnswerList.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseProcessTopicsTopicAnswerList.id = id; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseProcessTopicsTopicAnswerList.modifyTime = modifyTime; - } - final String? picUrl = jsonConvert.convert(json['picUrl']); - if (picUrl != null) { - courseProcessTopicsTopicAnswerList.picUrl = picUrl; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseProcessTopicsTopicAnswerList.sortOrder = sortOrder; - } - final int? topicId = jsonConvert.convert(json['topicId']); - if (topicId != null) { - courseProcessTopicsTopicAnswerList.topicId = topicId; - } - final String? word = jsonConvert.convert(json['word']); - if (word != null) { - courseProcessTopicsTopicAnswerList.word = word; - } - return courseProcessTopicsTopicAnswerList; +Map $CourseProcessTopicsTopicAnswerListToJson( + CourseProcessTopicsTopicAnswerList entity) { + final Map data = {}; + data['correct'] = entity.correct; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['modifyTime'] = entity.modifyTime; + data['picUrl'] = entity.picUrl; + data['sortOrder'] = entity.sortOrder; + data['topicId'] = entity.topicId; + data['word'] = entity.word; + return data; } -Map $CourseProcessTopicsTopicAnswerListToJson(CourseProcessTopicsTopicAnswerList entity) { - final Map data = {}; - data['correct'] = entity.correct; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['modifyTime'] = entity.modifyTime; - data['picUrl'] = entity.picUrl; - data['sortOrder'] = entity.sortOrder; - data['topicId'] = entity.topicId; - data['word'] = entity.word; - return data; +extension CourseProcessTopicsTopicAnswerListExtension on CourseProcessTopicsTopicAnswerList { + CourseProcessTopicsTopicAnswerList copyWith({ + int? correct, + String? createTime, + String? deleted, + String? id, + String? modifyTime, + String? picUrl, + int? sortOrder, + int? topicId, + String? word, + }) { + return CourseProcessTopicsTopicAnswerList() + ..correct = correct ?? this.correct + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..modifyTime = modifyTime ?? this.modifyTime + ..picUrl = picUrl ?? this.picUrl + ..sortOrder = sortOrder ?? this.sortOrder + ..topicId = topicId ?? this.topicId + ..word = word ?? this.word; + } } CourseProcessVideos $CourseProcessVideosFromJson(Map json) { - final CourseProcessVideos courseProcessVideos = CourseProcessVideos(); - final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); - if (courseLessonId != null) { - courseProcessVideos.courseLessonId = courseLessonId; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - courseProcessVideos.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - courseProcessVideos.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - courseProcessVideos.id = id; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - courseProcessVideos.modifyTime = modifyTime; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - courseProcessVideos.sortOrder = sortOrder; - } - final String? subtitleUrl = jsonConvert.convert(json['subtitleUrl']); - if (subtitleUrl != null) { - courseProcessVideos.subtitleUrl = subtitleUrl; - } - final String? videoUrl = jsonConvert.convert(json['videoUrl']); - if (videoUrl != null) { - courseProcessVideos.videoUrl = videoUrl; - } - return courseProcessVideos; + final CourseProcessVideos courseProcessVideos = CourseProcessVideos(); + final int? courseLessonId = jsonConvert.convert(json['courseLessonId']); + if (courseLessonId != null) { + courseProcessVideos.courseLessonId = courseLessonId; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + courseProcessVideos.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + courseProcessVideos.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + courseProcessVideos.id = id; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + courseProcessVideos.modifyTime = modifyTime; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + courseProcessVideos.sortOrder = sortOrder; + } + final String? subtitleUrl = jsonConvert.convert(json['subtitleUrl']); + if (subtitleUrl != null) { + courseProcessVideos.subtitleUrl = subtitleUrl; + } + final String? videoUrl = jsonConvert.convert(json['videoUrl']); + if (videoUrl != null) { + courseProcessVideos.videoUrl = videoUrl; + } + return courseProcessVideos; } Map $CourseProcessVideosToJson(CourseProcessVideos entity) { - final Map data = {}; - data['courseLessonId'] = entity.courseLessonId; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['modifyTime'] = entity.modifyTime; - data['sortOrder'] = entity.sortOrder; - data['subtitleUrl'] = entity.subtitleUrl; - data['videoUrl'] = entity.videoUrl; - return data; + final Map data = {}; + data['courseLessonId'] = entity.courseLessonId; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['modifyTime'] = entity.modifyTime; + data['sortOrder'] = entity.sortOrder; + data['subtitleUrl'] = entity.subtitleUrl; + data['videoUrl'] = entity.videoUrl; + return data; +} + +extension CourseProcessVideosExtension on CourseProcessVideos { + CourseProcessVideos copyWith({ + int? courseLessonId, + String? createTime, + String? deleted, + String? id, + String? modifyTime, + int? sortOrder, + String? subtitleUrl, + String? videoUrl, + }) { + return CourseProcessVideos() + ..courseLessonId = courseLessonId ?? this.courseLessonId + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..modifyTime = modifyTime ?? this.modifyTime + ..sortOrder = sortOrder ?? this.sortOrder + ..subtitleUrl = subtitleUrl ?? this.subtitleUrl + ..videoUrl = videoUrl ?? this.videoUrl; + } } \ No newline at end of file diff --git a/lib/generated/json/follow_read_entity.g.dart b/lib/generated/json/follow_read_entity.g.dart index cf03988..554be46 100644 --- a/lib/generated/json/follow_read_entity.g.dart +++ b/lib/generated/json/follow_read_entity.g.dart @@ -2,66 +2,95 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/follow_read_entity.dart'; FollowReadEntity $FollowReadEntityFromJson(Map json) { - final FollowReadEntity followReadEntity = FollowReadEntity(); - final String? coverUrl = jsonConvert.convert(json['coverUrl']); - if (coverUrl != null) { - followReadEntity.coverUrl = coverUrl; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - followReadEntity.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - followReadEntity.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - followReadEntity.id = id; - } - final bool? lock = jsonConvert.convert(json['lock']); - if (lock != null) { - followReadEntity.lock = lock; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - followReadEntity.modifyTime = modifyTime; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - followReadEntity.sortOrder = sortOrder; - } - final int? star = jsonConvert.convert(json['star']); - if (star != null) { - followReadEntity.star = star; - } - final int? status = jsonConvert.convert(json['status']); - if (status != null) { - followReadEntity.status = status; - } - final String? title = jsonConvert.convert(json['title']); - if (title != null) { - followReadEntity.title = title; - } - final int? videoTotal = jsonConvert.convert(json['videoTotal']); - if (videoTotal != null) { - followReadEntity.videoTotal = videoTotal; - } - return followReadEntity; + final FollowReadEntity followReadEntity = FollowReadEntity(); + final String? coverUrl = jsonConvert.convert(json['coverUrl']); + if (coverUrl != null) { + followReadEntity.coverUrl = coverUrl; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + followReadEntity.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + followReadEntity.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + followReadEntity.id = id; + } + final bool? lock = jsonConvert.convert(json['lock']); + if (lock != null) { + followReadEntity.lock = lock; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + followReadEntity.modifyTime = modifyTime; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + followReadEntity.sortOrder = sortOrder; + } + final int? star = jsonConvert.convert(json['star']); + if (star != null) { + followReadEntity.star = star; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + followReadEntity.status = status; + } + final String? title = jsonConvert.convert(json['title']); + if (title != null) { + followReadEntity.title = title; + } + final int? videoTotal = jsonConvert.convert(json['videoTotal']); + if (videoTotal != null) { + followReadEntity.videoTotal = videoTotal; + } + return followReadEntity; } Map $FollowReadEntityToJson(FollowReadEntity entity) { - final Map data = {}; - data['coverUrl'] = entity.coverUrl; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['lock'] = entity.lock; - data['modifyTime'] = entity.modifyTime; - data['sortOrder'] = entity.sortOrder; - data['star'] = entity.star; - data['status'] = entity.status; - data['title'] = entity.title; - data['videoTotal'] = entity.videoTotal; - return data; + final Map data = {}; + data['coverUrl'] = entity.coverUrl; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['lock'] = entity.lock; + data['modifyTime'] = entity.modifyTime; + data['sortOrder'] = entity.sortOrder; + data['star'] = entity.star; + data['status'] = entity.status; + data['title'] = entity.title; + data['videoTotal'] = entity.videoTotal; + return data; +} + +extension FollowReadEntityExtension on FollowReadEntity { + FollowReadEntity copyWith({ + String? coverUrl, + String? createTime, + String? deleted, + String? id, + bool? lock, + String? modifyTime, + int? sortOrder, + int? star, + int? status, + String? title, + int? videoTotal, + }) { + return FollowReadEntity() + ..coverUrl = coverUrl ?? this.coverUrl + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..lock = lock ?? this.lock + ..modifyTime = modifyTime ?? this.modifyTime + ..sortOrder = sortOrder ?? this.sortOrder + ..star = star ?? this.star + ..status = status ?? this.status + ..title = title ?? this.title + ..videoTotal = videoTotal ?? this.videoTotal; + } } \ No newline at end of file diff --git a/lib/generated/json/listen_entity.g.dart b/lib/generated/json/listen_entity.g.dart index 15509b7..2c0391b 100644 --- a/lib/generated/json/listen_entity.g.dart +++ b/lib/generated/json/listen_entity.g.dart @@ -2,66 +2,95 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/listen_entity.dart'; ListenEntity $ListenEntityFromJson(Map json) { - final ListenEntity listenEntity = ListenEntity(); - final String? coverUrl = jsonConvert.convert(json['coverUrl']); - if (coverUrl != null) { - listenEntity.coverUrl = coverUrl; - } - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - listenEntity.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - listenEntity.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - listenEntity.id = id; - } - final bool? lock = jsonConvert.convert(json['lock']); - if (lock != null) { - listenEntity.lock = lock; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - listenEntity.modifyTime = modifyTime; - } - final double? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - listenEntity.sortOrder = sortOrder; - } - final double? status = jsonConvert.convert(json['status']); - if (status != null) { - listenEntity.status = status; - } - final String? subtitleUrl = jsonConvert.convert(json['subtitleUrl']); - if (subtitleUrl != null) { - listenEntity.subtitleUrl = subtitleUrl; - } - final String? title = jsonConvert.convert(json['title']); - if (title != null) { - listenEntity.title = title; - } - final String? videoUrl = jsonConvert.convert(json['videoUrl']); - if (videoUrl != null) { - listenEntity.videoUrl = videoUrl; - } - return listenEntity; + final ListenEntity listenEntity = ListenEntity(); + final String? coverUrl = jsonConvert.convert(json['coverUrl']); + if (coverUrl != null) { + listenEntity.coverUrl = coverUrl; + } + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + listenEntity.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + listenEntity.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + listenEntity.id = id; + } + final bool? lock = jsonConvert.convert(json['lock']); + if (lock != null) { + listenEntity.lock = lock; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + listenEntity.modifyTime = modifyTime; + } + final double? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + listenEntity.sortOrder = sortOrder; + } + final double? status = jsonConvert.convert(json['status']); + if (status != null) { + listenEntity.status = status; + } + final String? subtitleUrl = jsonConvert.convert(json['subtitleUrl']); + if (subtitleUrl != null) { + listenEntity.subtitleUrl = subtitleUrl; + } + final String? title = jsonConvert.convert(json['title']); + if (title != null) { + listenEntity.title = title; + } + final String? videoUrl = jsonConvert.convert(json['videoUrl']); + if (videoUrl != null) { + listenEntity.videoUrl = videoUrl; + } + return listenEntity; } Map $ListenEntityToJson(ListenEntity entity) { - final Map data = {}; - data['coverUrl'] = entity.coverUrl; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['lock'] = entity.lock; - data['modifyTime'] = entity.modifyTime; - data['sortOrder'] = entity.sortOrder; - data['status'] = entity.status; - data['subtitleUrl'] = entity.subtitleUrl; - data['title'] = entity.title; - data['videoUrl'] = entity.videoUrl; - return data; + final Map data = {}; + data['coverUrl'] = entity.coverUrl; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['lock'] = entity.lock; + data['modifyTime'] = entity.modifyTime; + data['sortOrder'] = entity.sortOrder; + data['status'] = entity.status; + data['subtitleUrl'] = entity.subtitleUrl; + data['title'] = entity.title; + data['videoUrl'] = entity.videoUrl; + return data; +} + +extension ListenEntityExtension on ListenEntity { + ListenEntity copyWith({ + String? coverUrl, + String? createTime, + String? deleted, + String? id, + bool? lock, + String? modifyTime, + double? sortOrder, + double? status, + String? subtitleUrl, + String? title, + String? videoUrl, + }) { + return ListenEntity() + ..coverUrl = coverUrl ?? this.coverUrl + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..lock = lock ?? this.lock + ..modifyTime = modifyTime ?? this.modifyTime + ..sortOrder = sortOrder ?? this.sortOrder + ..status = status ?? this.status + ..subtitleUrl = subtitleUrl ?? this.subtitleUrl + ..title = title ?? this.title + ..videoUrl = videoUrl ?? this.videoUrl; + } } \ No newline at end of file diff --git a/lib/generated/json/product_entity.g.dart b/lib/generated/json/product_entity.g.dart new file mode 100644 index 0000000..229d457 --- /dev/null +++ b/lib/generated/json/product_entity.g.dart @@ -0,0 +1,33 @@ +import 'package:wow_english/generated/json/base/json_convert_content.dart'; +import 'package:wow_english/models/product_entity.dart'; + +ProductEntity $ProductEntityFromJson(Map json) { + final ProductEntity productEntity = ProductEntity(); + final String? name = jsonConvert.convert(json['name']); + if (name != null) { + productEntity.name = name; + } + final double? price = jsonConvert.convert(json['price']); + if (price != null) { + productEntity.price = price; + } + return productEntity; +} + +Map $ProductEntityToJson(ProductEntity entity) { + final Map data = {}; + data['name'] = entity.name; + data['price'] = entity.price; + return data; +} + +extension ProductEntityExtension on ProductEntity { + ProductEntity copyWith({ + String? name, + double? price, + }) { + return ProductEntity() + ..name = name ?? this.name + ..price = price ?? this.price; + } +} \ No newline at end of file diff --git a/lib/generated/json/read_content_entity.g.dart b/lib/generated/json/read_content_entity.g.dart index 908470a..07a2b1a 100644 --- a/lib/generated/json/read_content_entity.g.dart +++ b/lib/generated/json/read_content_entity.g.dart @@ -2,56 +2,82 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/read_content_entity.dart'; ReadContentEntity $ReadContentEntityFromJson(Map json) { - final ReadContentEntity readContentEntity = ReadContentEntity(); - final String? createTime = jsonConvert.convert(json['createTime']); - if (createTime != null) { - readContentEntity.createTime = createTime; - } - final String? deleted = jsonConvert.convert(json['deleted']); - if (deleted != null) { - readContentEntity.deleted = deleted; - } - final String? id = jsonConvert.convert(json['id']); - if (id != null) { - readContentEntity.id = id; - } - final String? modifyTime = jsonConvert.convert(json['modifyTime']); - if (modifyTime != null) { - readContentEntity.modifyTime = modifyTime; - } - final int? sortOrder = jsonConvert.convert(json['sortOrder']); - if (sortOrder != null) { - readContentEntity.sortOrder = sortOrder; - } - final int? status = jsonConvert.convert(json['status']); - if (status != null) { - readContentEntity.status = status; - } - final int? videoFollowReadId = jsonConvert.convert(json['videoFollowReadId']); - if (videoFollowReadId != null) { - readContentEntity.videoFollowReadId = videoFollowReadId; - } - final String? videoUrl = jsonConvert.convert(json['videoUrl']); - if (videoUrl != null) { - readContentEntity.videoUrl = videoUrl; - } - final String? word = jsonConvert.convert(json['word']); - if (word != null) { - readContentEntity.word = word; - } - return readContentEntity; + final ReadContentEntity readContentEntity = ReadContentEntity(); + final String? createTime = jsonConvert.convert(json['createTime']); + if (createTime != null) { + readContentEntity.createTime = createTime; + } + final String? deleted = jsonConvert.convert(json['deleted']); + if (deleted != null) { + readContentEntity.deleted = deleted; + } + final String? id = jsonConvert.convert(json['id']); + if (id != null) { + readContentEntity.id = id; + } + final String? modifyTime = jsonConvert.convert(json['modifyTime']); + if (modifyTime != null) { + readContentEntity.modifyTime = modifyTime; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + readContentEntity.sortOrder = sortOrder; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + readContentEntity.status = status; + } + final int? videoFollowReadId = jsonConvert.convert( + json['videoFollowReadId']); + if (videoFollowReadId != null) { + readContentEntity.videoFollowReadId = videoFollowReadId; + } + final String? videoUrl = jsonConvert.convert(json['videoUrl']); + if (videoUrl != null) { + readContentEntity.videoUrl = videoUrl; + } + final String? word = jsonConvert.convert(json['word']); + if (word != null) { + readContentEntity.word = word; + } + return readContentEntity; } Map $ReadContentEntityToJson(ReadContentEntity entity) { - final Map data = {}; - data['createTime'] = entity.createTime; - data['deleted'] = entity.deleted; - data['id'] = entity.id; - data['modifyTime'] = entity.modifyTime; - data['sortOrder'] = entity.sortOrder; - data['status'] = entity.status; - data['videoFollowReadId'] = entity.videoFollowReadId; - data['videoUrl'] = entity.videoUrl; - data['word'] = entity.word; - return data; + final Map data = {}; + data['createTime'] = entity.createTime; + data['deleted'] = entity.deleted; + data['id'] = entity.id; + data['modifyTime'] = entity.modifyTime; + data['sortOrder'] = entity.sortOrder; + data['status'] = entity.status; + data['videoFollowReadId'] = entity.videoFollowReadId; + data['videoUrl'] = entity.videoUrl; + data['word'] = entity.word; + return data; +} + +extension ReadContentEntityExtension on ReadContentEntity { + ReadContentEntity copyWith({ + String? createTime, + String? deleted, + String? id, + String? modifyTime, + int? sortOrder, + int? status, + int? videoFollowReadId, + String? videoUrl, + String? word, + }) { + return ReadContentEntity() + ..createTime = createTime ?? this.createTime + ..deleted = deleted ?? this.deleted + ..id = id ?? this.id + ..modifyTime = modifyTime ?? this.modifyTime + ..sortOrder = sortOrder ?? this.sortOrder + ..status = status ?? this.status + ..videoFollowReadId = videoFollowReadId ?? this.videoFollowReadId + ..videoUrl = videoUrl ?? this.videoUrl + ..word = word ?? this.word; + } } \ 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 58db2a3..730c6dc 100644 --- a/lib/generated/json/user_entity.g.dart +++ b/lib/generated/json/user_entity.g.dart @@ -2,61 +2,90 @@ import 'package:wow_english/generated/json/base/json_convert_content.dart'; import 'package:wow_english/models/user_entity.dart'; UserEntity $UserEntityFromJson(Map json) { - final UserEntity userEntity = UserEntity(); - final int? id = jsonConvert.convert(json['id']); - if (id != null) { - userEntity.id = id; - } - final String? name = jsonConvert.convert(json['name']); - 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; - } - final int? gender = jsonConvert.convert(json['gender']); - if (gender != null) { - userEntity.gender = gender; - } - final String? avatarUrl = jsonConvert.convert(json['avatarUrl']); - if (avatarUrl != null) { - userEntity.avatarUrl = avatarUrl; - } - final String? phoneNum = jsonConvert.convert(json['phoneNum']); - if (phoneNum != null) { - userEntity.phoneNum = phoneNum; - } - 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 String? effectiveDate = jsonConvert.convert(json['effectiveDate']); - if (effectiveDate != null) { - userEntity.effectiveDate = effectiveDate; - } - return userEntity; + final UserEntity userEntity = UserEntity(); + final int? id = jsonConvert.convert(json['id']); + if (id != null) { + userEntity.id = id; + } + final String? name = jsonConvert.convert(json['name']); + 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; + } + final int? gender = jsonConvert.convert(json['gender']); + if (gender != null) { + userEntity.gender = gender; + } + final String? avatarUrl = jsonConvert.convert(json['avatarUrl']); + if (avatarUrl != null) { + userEntity.avatarUrl = avatarUrl; + } + final String? phoneNum = jsonConvert.convert(json['phoneNum']); + if (phoneNum != null) { + userEntity.phoneNum = phoneNum; + } + 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 String? effectiveDate = jsonConvert.convert( + json['effectiveDate']); + if (effectiveDate != null) { + userEntity.effectiveDate = effectiveDate; + } + return userEntity; } 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['fillUserInfo'] = entity.fillUserInfo; - data['nowCourseModuleId'] = entity.nowCourseModuleId; - data['effectiveDate'] = entity.effectiveDate; - return data; + 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['fillUserInfo'] = entity.fillUserInfo; + data['nowCourseModuleId'] = entity.nowCourseModuleId; + data['effectiveDate'] = entity.effectiveDate; + return data; +} + +extension UserEntityExtension on UserEntity { + UserEntity copyWith({ + int? id, + String? name, + String? token, + int? age, + int? gender, + String? avatarUrl, + String? phoneNum, + int? fillUserInfo, + int? nowCourseModuleId, + String? effectiveDate, + }) { + return UserEntity() + ..id = id ?? this.id + ..name = name ?? this.name + ..token = token ?? this.token + ..age = age ?? this.age + ..gender = gender ?? this.gender + ..avatarUrl = avatarUrl ?? this.avatarUrl + ..phoneNum = phoneNum ?? this.phoneNum + ..fillUserInfo = fillUserInfo ?? this.fillUserInfo + ..nowCourseModuleId = nowCourseModuleId ?? this.nowCourseModuleId + ..effectiveDate = effectiveDate ?? this.effectiveDate; + } } \ No newline at end of file diff --git a/lib/models/product_entity.dart b/lib/models/product_entity.dart new file mode 100644 index 0000000..98c6366 --- /dev/null +++ b/lib/models/product_entity.dart @@ -0,0 +1,22 @@ +import 'package:wow_english/generated/json/base/json_field.dart'; +import 'package:wow_english/generated/json/product_entity.g.dart'; +import 'dart:convert'; +export 'package:wow_english/generated/json/product_entity.g.dart'; + +@JsonSerializable() +class ProductEntity { + late String name; + late double price; + late String url; + + ProductEntity(); + + factory ProductEntity.fromJson(Map json) => $ProductEntityFromJson(json); + + Map toJson() => $ProductEntityToJson(this); + + @override + String toString() { + return jsonEncode(this); + } +} \ No newline at end of file diff --git a/lib/pages/shop/home/shop_home_page.dart b/lib/pages/shop/home/shop_home_page.dart index 907dc43..ede8e6d 100644 --- a/lib/pages/shop/home/shop_home_page.dart +++ b/lib/pages/shop/home/shop_home_page.dart @@ -72,6 +72,7 @@ class _ShopHomeView extends StatelessWidget { itemBuilder: (BuildContext context, int index) { return LessonCardItem(onTap: () { showToast('购买'); + pushNamed(AppRouteName.pay); }); }), ), diff --git a/lib/pages/shopping/bloc.dart b/lib/pages/shopping/bloc.dart new file mode 100644 index 0000000..8f81254 --- /dev/null +++ b/lib/pages/shopping/bloc.dart @@ -0,0 +1,56 @@ +import 'package:bloc/bloc.dart'; +import 'package:wow_english/models/product_entity.dart'; + +import '../../utils/log_util.dart'; +import 'event.dart'; +import 'state.dart'; + +class ShoppingBloc extends Bloc { + + ProductEntity? _productData; + + ProductEntity? get productData => _productData; + + PaymentChannel _curPaymentChannel = PaymentChannel.wechatPay; + + PaymentChannel get curPaymentChannel => _curPaymentChannel; + + + ShoppingBloc() : super(ShoppingState().init()) { + //页面初始化时刻 + on(_init); + on(_changePaymentChannel); + } + + void _init(InitEvent event, Emitter emit) async { + //处理一些初始化操作,然后刷新界面 + emit(state.clone()); + } + + /// 更换支付渠道 + void _changePaymentChannel(ChangePaymentChannelEvent event, + Emitter emitter) async { + Log.d("_curPaymentChannel=$_curPaymentChannel, event.paymentChannel=${event.paymentChannel}"); + if (_curPaymentChannel != event.paymentChannel) { + _curPaymentChannel = event.paymentChannel; + emitter(PaymentChannelChangeState()); + } + } + + void _gotoPay() { + // 跳转到支付页面 + } +} + +enum PaymentChannel { + + wechatPay(1, "微信支付"), + + aliPay(2, "支付宝支付"); + + const PaymentChannel(this.payChannelType, this.payChannelName); + + final int payChannelType; + + final String payChannelName; +} diff --git a/lib/pages/shopping/event.dart b/lib/pages/shopping/event.dart new file mode 100644 index 0000000..ead0a38 --- /dev/null +++ b/lib/pages/shopping/event.dart @@ -0,0 +1,11 @@ +import 'bloc.dart'; + +abstract class ShoppingEvent {} + +class InitEvent extends ShoppingEvent {} + +class ChangePaymentChannelEvent extends ShoppingEvent { + final PaymentChannel paymentChannel; + + ChangePaymentChannelEvent(this.paymentChannel); +} \ No newline at end of file diff --git a/lib/pages/shopping/state.dart b/lib/pages/shopping/state.dart new file mode 100644 index 0000000..39088d4 --- /dev/null +++ b/lib/pages/shopping/state.dart @@ -0,0 +1,11 @@ +class ShoppingState { + ShoppingState init() { + return ShoppingState(); + } + + ShoppingState clone() { + return ShoppingState(); + } +} + +class PaymentChannelChangeState extends ShoppingState {} \ No newline at end of file diff --git a/lib/pages/shopping/view.dart b/lib/pages/shopping/view.dart new file mode 100644 index 0000000..1ee7d0a --- /dev/null +++ b/lib/pages/shopping/view.dart @@ -0,0 +1,171 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:wow_english/common/extension/string_extension.dart'; + +import '../../common/core/assets_const.dart'; +import '../../common/widgets/we_app_bar.dart'; +import '../../utils/image_util.dart'; +import 'bloc.dart'; +import 'event.dart'; +import 'state.dart'; + +Widget buildRadioOption({ + required int value, + required ImageProvider icon, + required String text, + required int groupValue, + required ValueChanged onChanged, +}) { + return Row( + children: [ + Image(image: icon, + width: 20.0.w, + height: 20.0.h, + fit: BoxFit.contain), + const SizedBox(width: 10.0), + // Expanded( + // child: Text( + // text, + // style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp), + // ), + // ), + Text( + text, + style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp), + ), + Radio( + value: value, + groupValue: groupValue, + onChanged: onChanged + ), + ], + ); +} + +class ShoppingPage extends StatelessWidget { + const ShoppingPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => + ShoppingBloc() + ..add(InitEvent()), + child: _ShoppingView(), + ); + } +} + +class _ShoppingView extends StatelessWidget { + + @override + Widget build(BuildContext context) { + final bloc = BlocProvider.of(context); + return BlocListener( + listener: (context, state) { + }, + child: Scaffold( + appBar: const WEAppBar( + //标题传进来的 + titleText: '支付', + ), + body: Container( + margin: const EdgeInsets.only(left: 80.0, top: 28.0, right: 56.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CachedNetworkImage( + imageUrl: "${bloc.productData?.url}", + imageBuilder: (context, imageProvider) => + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + borderRadius: BorderRadius.circular(5.0), + ), + ), + placeholder: (context, url) => + const CircularProgressIndicator(), + // errorWidget: (context, url, error) => const Icon(Icons.error), + height: 210.0.h, + width: 210.0.w, + ), + const SizedBox(width: 35.5), + _paymentWidget(), + ], + ), + ), + ),); + } +} + +Widget _paymentWidget() => + BlocBuilder + ( + builder: (context, state) { + final bloc = BlocProvider.of(context); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('套餐价格:${bloc.productData?.price ?? "199(记得删除)"}', + style: TextStyle( + color: const Color(0xFF333333), fontSize: 16.sp)), + const SizedBox(height: 15.0), + Text('套餐名称:${bloc.productData?.name ?? ''}', + style: TextStyle( + color: const Color(0xFF333333), fontSize: 16.sp)), + const SizedBox(height: 15.0), + Container( + padding: + EdgeInsets.symmetric(horizontal: 6.w, vertical: 10.h), + decoration: BoxDecoration( + image: DecorationImage( + image: ImageUtil.getImageProviderOnDefault( + AssetsConst.bgUserInformationText), + fit: BoxFit.fill)), + child: const Text('支付方式选择', + style: TextStyle( + color: Color(0xFF333333), + fontSize: 12, + fontFamily: 'PingFangSC-Regular')), + ), + const SizedBox(height: 15.0), + buildRadioOption( + value: PaymentChannel.wechatPay.payChannelType, + icon: AssetImage('weixin'.assetPng), + text: PaymentChannel.wechatPay.payChannelName, + groupValue: bloc.curPaymentChannel.payChannelType, + onChanged: (newValue) { + bloc.add( + ChangePaymentChannelEvent(PaymentChannel.wechatPay)); + }, + ), + buildRadioOption( + value: PaymentChannel.aliPay.payChannelType, + icon: AssetImage('zhifubao'.assetPng), + text: PaymentChannel.aliPay.payChannelName, + groupValue: bloc.curPaymentChannel.payChannelType, + onChanged: (newValue) { + bloc.add( + ChangePaymentChannelEvent(PaymentChannel.aliPay)); + }, + ), + const SizedBox(height: 15.0), + // 确认支付按钮 + InkWell( + onTap: () { + }, + child: Image( + width: 125.w, + height: 45.h, + image: AssetImage('btn_pay'.assetPng), + ), + ), + ], + ); + }, + ); diff --git a/lib/route/route.dart b/lib/route/route.dart index 375b738..e2850b4 100644 --- a/lib/route/route.dart +++ b/lib/route/route.dart @@ -23,6 +23,7 @@ import 'package:wow_english/pages/user/user_page.dart'; import 'package:wow_english/pages/video/lookvideo/look_video_page.dart'; import '../pages/reading/reading_page.dart'; +import '../pages/shopping/view.dart'; import '../pages/user/setting/delete_account_page.dart'; import '../pages/user/setting/reback_page.dart'; @@ -43,6 +44,7 @@ class AppRouteName { static const String reAfter = 'reAfter'; static const String topicPic = 'topicPic'; static const String user = 'user'; + static const String pay = 'pay'; /// 用户详细信息页 static const String userInformation = 'userInformation'; @@ -101,6 +103,8 @@ class AppRouter { return CupertinoPageRoute(builder: (_) => const ListenPage()); case AppRouteName.shop: return CupertinoPageRoute(builder: (_) => const ShopHomePage()); + case AppRouteName.pay: + return CupertinoPageRoute(builder: (_) => const ShoppingPage()); case AppRouteName.exLesson: return CupertinoPageRoute(builder: (_) => const ExchangeLessonPage()); case AppRouteName.exList: diff --git a/pubspec.yaml b/pubspec.yaml index 9dc0754..63705f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,9 +66,9 @@ dependencies: # 拍照,从相册中选择 https://pub.flutter-io.cn/packages/image_picker image_picker: ^0.8.7+5 # 支付宝支付SDK https://pub.flutter-io.cn/packages/tobias - # tobias: ^3.1.0 + tobias: ^3.1.0 # 微信SDK相关 https://pub.flutter-io.cn/packages/fluwx - # fluwx: ^4.2.4+1 + fluwx: ^4.5.5 # json数据解析 https://pub.flutter-io.cn/packages/json_annotation json_annotation: ^4.8.1 # double丢失精度问题 https://pub.dev/packages/decimal -- libgit2 0.22.2