diff --git a/android/app/build.gradle b/android/app/build.gradle index 4f7fa94..7664254 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -29,7 +29,7 @@ android { namespace "com.kouyuxingqiu.wow_english" // compileSdkVersion flutter.compileSdkVersion compileSdkVersion 33 - // 展示没有ndk需求 + // 暂时没有ndk需求 // ndkVersion flutter.ndkVersion compileOptions { @@ -87,4 +87,5 @@ dependencies { implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' // kotlin扩展(可选) implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' + implementation 'io.keyss.android.library:bjgame:1.0.2' } diff --git a/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt index 6e2bb0e..4d8363e 100644 --- a/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt +++ b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt @@ -8,6 +8,7 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import com.gyf.immersionbar.BarHide import com.gyf.immersionbar.ImmersionBar +import com.kouyuxingqiu.wow_english.methodChannels.GameMethodChannel import com.kouyuxingqiu.wow_english.methodChannels.SingSoungMethodChannel import io.flutter.embedding.android.FlutterActivity @@ -17,7 +18,10 @@ class MainActivity : FlutterActivity() { Log.i("WowEnglish", "MainActivity onCreate") //隐藏状态栏和导航栏 ImmersionBar.with(this).hideBar(BarHide.FLAG_HIDE_BAR).init() - flutterEngine?.let { SingSoungMethodChannel(this, it) } + flutterEngine?.let { + SingSoungMethodChannel(this, it) + GameMethodChannel(this, it) + } } override fun onResume() { diff --git a/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/methodChannels/GameMethodChannel.kt b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/methodChannels/GameMethodChannel.kt new file mode 100644 index 0000000..7838dad --- /dev/null +++ b/android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/methodChannels/GameMethodChannel.kt @@ -0,0 +1,59 @@ +package com.kouyuxingqiu.wow_english.methodChannels + +import android.content.Intent +import android.content.Intent.getIntent +import android.util.Log +import androidx.core.content.ContextCompat.startActivity +import com.kouyuxingqiu.wow_english.singsound.SingEngineHelper +import com.kouyuxingqiu.wow_english.util.GlobalHandler +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.MethodChannel +import org.cocos2dx.cpp.AppActivity +import java.lang.ref.WeakReference + + +/** + * @author: stay + * @date: 2024/4/22 18:36 + * @description: 游戏方法通道 + */ +class GameMethodChannel(activity: FlutterActivity, flutterEngine: FlutterEngine) { + private var methodChannel: MethodChannel? = null + private val TAG = "GameMethodChannel" + + companion object { + var channel: WeakReference? = null + + fun invokeMethod(method: String, arguments: Any?) { + channel?.get()?.methodChannel?.invokeMethod(method, arguments) + } + } + + init { + // name需与flutter端一致 + methodChannel = + MethodChannel( + flutterEngine.dartExecutor.binaryMessenger, + "wow_english/game_method_channel" + ) + methodChannel?.setMethodCallHandler { call, result -> + Log.d(TAG, "call=${call.method} ${call.arguments} result=$result") + when (call.method) { + "openGamePage" -> { + if (call.hasArgument("gameId")) { + val gameId = call.argument("gameId") + activity.startActivity( + Intent(activity, AppActivity::class.java).apply { + putExtra("game", gameId) + }) + result.success(true) + } else { + result.success(false) + } + } + } + } + channel = WeakReference(this) + } +} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 9151f20..482dae9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -17,6 +17,7 @@ allprojects { google() mavenCentral() maven { url 'https://repo.singsound.com/repository/singsound_ginger_android_sdk/' } + maven { url 'https://maven.zjzxsl.com/repository/android-public/' } } } diff --git a/assets/images/apple_pay.png b/assets/images/apple_pay.png new file mode 100644 index 0000000..2850364 --- /dev/null +++ b/assets/images/apple_pay.png diff --git a/assets/images/bg_frame_module.png b/assets/images/bg_frame_module.png new file mode 100644 index 0000000..777b5a5 --- /dev/null +++ b/assets/images/bg_frame_module.png diff --git a/assets/images/bg_header_sliver.png b/assets/images/bg_header_sliver.png new file mode 100644 index 0000000..452987d --- /dev/null +++ b/assets/images/bg_header_sliver.png diff --git a/assets/images/btn_pay.png b/assets/images/btn_pay.png new file mode 100644 index 0000000..8480685 --- /dev/null +++ b/assets/images/btn_pay.png diff --git a/assets/images/checked.png b/assets/images/checked.png new file mode 100644 index 0000000..7c56172 --- /dev/null +++ b/assets/images/checked.png diff --git a/assets/images/ic_countdown.png b/assets/images/ic_countdown.png new file mode 100644 index 0000000..77aac71 --- /dev/null +++ b/assets/images/ic_countdown.png diff --git a/assets/images/label_module_game.png b/assets/images/label_module_game.png new file mode 100644 index 0000000..3bd4b39 --- /dev/null +++ b/assets/images/label_module_game.png diff --git a/assets/images/label_module_study.png b/assets/images/label_module_study.png new file mode 100644 index 0000000..506c924 --- /dev/null +++ b/assets/images/label_module_study.png diff --git a/assets/images/pic_module_game.png b/assets/images/pic_module_game.png new file mode 100644 index 0000000..a7468d6 --- /dev/null +++ b/assets/images/pic_module_game.png diff --git a/assets/images/pic_module_study.png b/assets/images/pic_module_study.png new file mode 100644 index 0000000..f7f3388 --- /dev/null +++ b/assets/images/pic_module_study.png diff --git a/assets/images/unchecked.png b/assets/images/unchecked.png new file mode 100644 index 0000000..d6676b5 --- /dev/null +++ b/assets/images/unchecked.png diff --git a/assets/images/weixin.png b/assets/images/weixin.png new file mode 100644 index 0000000..931bf9e --- /dev/null +++ b/assets/images/weixin.png diff --git a/assets/images/zhifubao.png b/assets/images/zhifubao.png new file mode 100644 index 0000000..a8b77a8 --- /dev/null +++ b/assets/images/zhifubao.png diff --git a/ios/Podfile b/ios/Podfile index ebbee83..555ec92 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -33,7 +33,7 @@ target 'Runner' do use_frameworks! use_modular_headers! pod 'SingSoundSDK' - + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) target 'RunnerTests' do inherit! :search_paths diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1dc8249..19cdee8 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -24,10 +24,7 @@ B891A6152BD21EF3006CB06E /* game_food in Resources */ = {isa = PBXBuildFile; fileRef = B891A6112BD21EEF006CB06E /* game_food */; }; B891A6162BD21EF3006CB06E /* game_halloween in Resources */ = {isa = PBXBuildFile; fileRef = B891A6122BD21EF2006CB06E /* game_halloween */; }; B891A6172BD21EF3006CB06E /* game_animal in Resources */ = {isa = PBXBuildFile; fileRef = B891A6132BD21EF3006CB06E /* game_animal */; }; - B891A61A2BD21F2B006CB06E /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = B891A6182BD21F2B006CB06E /* CloseNormal.png */; }; - B891A61B2BD21F2B006CB06E /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = B891A6192BD21F2B006CB06E /* CloseSelected.png */; }; B891A61D2BD21F6B006CB06E /* res in Resources */ = {isa = PBXBuildFile; fileRef = B891A61C2BD21F6B006CB06E /* res */; }; - B891A61F2BD21FA2006CB06E /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = B891A61E2BD21FA2006CB06E /* HelloWorld.png */; }; B891A7FE2BD24EFA006CB06E /* ActionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B891A6202BD24EF9006CB06E /* ActionData.cpp */; }; B891A7FF2BD24EFA006CB06E /* AlertView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B891A6222BD24EF9006CB06E /* AlertView.cpp */; }; B891A8002BD24EFA006CB06E /* AppLinksView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B891A6242BD24EF9006CB06E /* AppLinksView.cpp */; }; @@ -476,10 +473,7 @@ B891A6112BD21EEF006CB06E /* game_food */ = {isa = PBXFileReference; lastKnownFileType = folder; path = game_food; sourceTree = ""; }; B891A6122BD21EF2006CB06E /* game_halloween */ = {isa = PBXFileReference; lastKnownFileType = folder; path = game_halloween; sourceTree = ""; }; B891A6132BD21EF3006CB06E /* game_animal */ = {isa = PBXFileReference; lastKnownFileType = folder; path = game_animal; sourceTree = ""; }; - B891A6182BD21F2B006CB06E /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; - B891A6192BD21F2B006CB06E /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; B891A61C2BD21F6B006CB06E /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; path = res; sourceTree = ""; }; - B891A61E2BD21FA2006CB06E /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = ""; }; B891A6202BD24EF9006CB06E /* ActionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionData.cpp; sourceTree = ""; }; B891A6212BD24EF9006CB06E /* ActionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionData.h; sourceTree = ""; }; B891A6222BD24EF9006CB06E /* AlertView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlertView.cpp; sourceTree = ""; }; @@ -1085,9 +1079,6 @@ B891A4112BCD13AB006CB06E /* Resources */ = { isa = PBXGroup; children = ( - B891A61E2BD21FA2006CB06E /* HelloWorld.png */, - B891A6182BD21F2B006CB06E /* CloseNormal.png */, - B891A6192BD21F2B006CB06E /* CloseSelected.png */, B891A61C2BD21F6B006CB06E /* res */, B891A6132BD21EF3006CB06E /* game_animal */, B891A6112BD21EEF006CB06E /* game_food */, @@ -1805,15 +1796,12 @@ buildActionMask = 2147483647; files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, - B891A61B2BD21F2B006CB06E /* CloseSelected.png in Resources */, B891A6152BD21EF3006CB06E /* game_food in Resources */, B891A60F2BD21BBC006CB06E /* fonts in Resources */, - B891A61F2BD21FA2006CB06E /* HelloWorld.png in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, B891A6172BD21EF3006CB06E /* game_animal in Resources */, B891A6142BD21EF3006CB06E /* game_toy in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - B891A61A2BD21F2B006CB06E /* CloseNormal.png in Resources */, B891A61D2BD21F6B006CB06E /* res in Resources */, B891A6162BD21EF3006CB06E /* game_halloween in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, @@ -2321,15 +2309,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = T8P9KW8GWH; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 3; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = T8P9KW8GWH; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; OTHER_CFLAGS = ( "-DNDEBUG", "'-std=gnu99'", @@ -2457,6 +2447,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "wow english"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; @@ -2664,8 +2656,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = T8P9KW8GWH; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 3; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = T8P9KW8GWH; ENABLE_BITCODE = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -2694,7 +2688,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "'-std=gnu99'"; OTHER_CPLUSPLUSFLAGS = "'-std=c++11'"; @@ -2817,6 +2811,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "wow english"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; @@ -2868,15 +2864,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = T8P9KW8GWH; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 3; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = T8P9KW8GWH; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; OTHER_CFLAGS = ( "-DNDEBUG", "'-std=gnu99'", @@ -3004,6 +3002,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "wow english"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 9e625ca..6b0d220 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -13,13 +13,6 @@ import Flutter _ = XSMessageMehtodChannel(message: controller.binaryMessenger); _ = GameMessageChannel(message: controller.binaryMessenger); -// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 6) { -// WowGameCocosManager.shared().runGame(); -// } -// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 15) { -// WowGameCocosManager.shared().runGame(); -// } - return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } diff --git a/ios/Runner/GameMessageChannel.swift b/ios/Runner/GameMessageChannel.swift index a2a3be5..69e03f2 100644 --- a/ios/Runner/GameMessageChannel.swift +++ b/ios/Runner/GameMessageChannel.swift @@ -19,11 +19,11 @@ class GameMessageChannel: NSObject { func handle(_ call: FlutterMethodCall,_ result: @escaping FlutterResult) { if (call.method == "openGamePage") { - print("openGamePage") - WowGameCocosManager.shared().runGame(); + print("openGamePage"); + let dict = call.arguments as! Dictionary + let gameid = dict["gameId"] as! Int + WowGameCocosManager.shared().runGame(gameid); return } - } - } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 1ccf459..c5b3673 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -22,6 +22,19 @@ $(FLUTTER_BUILD_NAME) CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + ishowwoweng + CFBundleURLSchemes + + ishowwoweng + + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) LSApplicationCategoryType diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index 903def2..35dc492 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -4,5 +4,9 @@ aps-environment development + com.apple.developer.associated-domains + + applinks:app-api.wowenglish.com.cn + diff --git a/ios/Runner/Wowgame/Classes/CocosAppDelegate.cpp b/ios/Runner/Wowgame/Classes/CocosAppDelegate.cpp index 1a7530d..39d2f5f 100644 --- a/ios/Runner/Wowgame/Classes/CocosAppDelegate.cpp +++ b/ios/Runner/Wowgame/Classes/CocosAppDelegate.cpp @@ -24,7 +24,15 @@ #include "CocosAppDelegate.h" #include "HelloWorldScene.h" -#include "game_food/ScalingUtils.h" + + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include "NativeAndroid/AndroidUtils_cpp.h" +#endif + + + + // #define USE_AUDIO_ENGINE 1 #if USE_AUDIO_ENGINE @@ -41,11 +49,16 @@ CocosAppDelegate::CocosAppDelegate() { } -CocosAppDelegate::~CocosAppDelegate() +CocosAppDelegate::~CocosAppDelegate() { #if USE_AUDIO_ENGINE AudioEngine::end(); #endif + + SpriteFrameCache::getInstance()->removeSpriteFrames(); + Director::getInstance()->getTextureCache()->removeAllTextures(); + + } // if you want a different context, modify the value of glContextAttrs @@ -58,7 +71,7 @@ void CocosAppDelegate::initGLContextAttrs() GLView::setGLContextAttrs(glContextAttrs); } -// if you want to use the package manager to install more packages, +// if you want to use the package manager to install more packages, // don't modify or remove this function static int register_all_packages() { diff --git a/ios/Runner/Wowgame/Classes/HelloWorldScene.cpp b/ios/Runner/Wowgame/Classes/HelloWorldScene.cpp index 62028d0..fca4d18 100644 --- a/ios/Runner/Wowgame/Classes/HelloWorldScene.cpp +++ b/ios/Runner/Wowgame/Classes/HelloWorldScene.cpp @@ -71,69 +71,24 @@ bool HelloWorld::init() return false; } - auto visibleSize = Director::getInstance()->getVisibleSize(); - Vec2 origin = Director::getInstance()->getVisibleOrigin(); + auto m_eventListener = EventListenerCustom::create("start_gameid", [=](EventCustom* event) { + char* pData = (char*)event->getUserData(); + intptr_t gameid = (intptr_t)pData; + CCLOG("HelloWorld gameid = %d",gameid); + this->startGameById(gameid); + }); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(m_eventListener, 1); - ///////////////////////////// - // 2. add a menu item with "X" image, which is clicked to quit the program - // you may modify it. - - // add a "close" icon to exit the progress. it's an autorelease object - auto closeItem = MenuItemImage::create( "CloseNormal.png","CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - - if (closeItem == nullptr || - closeItem->getContentSize().width <= 0 || - closeItem->getContentSize().height <= 0) - { - problemLoading("'CloseNormal.png' and 'CloseSelected.png'"); - } - else - { - float x = origin.x + visibleSize.width - closeItem->getContentSize().width/2; - float y = origin.y + closeItem->getContentSize().height/2; - closeItem->setPosition(Vec2(x,y)); - } - auto lbl_game1 = Label::createWithTTF("food", "fonts/ComicSansMSBold.ttf", 48); - auto lbl_game2 = Label::createWithTTF("halloween", "fonts/ComicSansMSBold.ttf", 48); - auto lbl_game3 = Label::createWithTTF("toygamerepo", "fonts/ComicSansMSBold.ttf", 48); - auto lbl_game4 = Label::createWithTTF("animal", "fonts/ComicSansMSBold.ttf", 48); - auto lbl_game5 = Label::createWithTTF("exit ", "fonts/ComicSansMSBold.ttf", 48); - auto btn_game1 = MenuItemLabel::create(lbl_game1, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - auto btn_game2 = MenuItemLabel::create(lbl_game2, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - auto btn_game3 = MenuItemLabel::create(lbl_game3, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - auto btn_game4 = MenuItemLabel::create(lbl_game4, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - auto btn_game5 = MenuItemLabel::create(lbl_game5, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - btn_game1->setPosition(visibleSize.width * 0.5, visibleSize.height * 0.5 + 400); - btn_game2->setPosition(visibleSize.width * 0.5, visibleSize.height * 0.5 + 200); - btn_game3->setPosition(visibleSize.width * 0.5, visibleSize.height * 0.5 - 0); - btn_game4->setPosition(visibleSize.width * 0.5, visibleSize.height * 0.5 - 200); - btn_game5->setPosition(visibleSize.width * 0.5, visibleSize.height * 0.5 - 400); - btn_game1->setTag(101); - btn_game2->setTag(102); - btn_game3->setTag(103); - btn_game4->setTag(104); - btn_game5->setTag(105); - - // create menu, it's an autorelease object - auto menu = Menu::create(closeItem, btn_game1, btn_game2, btn_game3, btn_game4,btn_game5, NULL); - menu->setPosition(Vec2::ZERO); - this->addChild(menu, 1); CCLOG("HelloWorld init"); - return true; } -void HelloWorld::menuCloseCallback(Ref* pSender) +void HelloWorld::startGameById(int gameid) { - - - auto node = (Node*)pSender; - int tag = node -> getTag(); - - if (tag == 101)//food + int tag = gameid; + if (tag == 1)//food { - auto searchPaths = cocos2d::FileUtils::getInstance()->getSearchPaths(); searchPaths.push_back("game_food"); if(ScalingUtils::isSmallDevice()){ @@ -152,13 +107,10 @@ void HelloWorld::menuCloseCallback(Ref* pSender) Director::getInstance()->replaceScene(newScene); } - if (tag == 102)//halloween + if (tag == 2)//halloween { - - auto searchPaths = cocos2d::FileUtils::getInstance()->getSearchPaths(); std::string deviceSpecificFolderName; - deviceSpecificFolderName = HResourcesConfig::RES_FOLDER_NAME_XLARGE;//TODO TEMP searchPaths.push_back("game_halloween/" + deviceSpecificFolderName); searchPaths.push_back("game_halloween/common"); @@ -168,14 +120,11 @@ void HelloWorld::menuCloseCallback(Ref* pSender) std::string layoutFilePath = "game_halloween/xlarge/scene_layout.scl"; HGameConfigParser parser(configFilePath); auto gameScene = dynamic_cast(parser.createGameScene(layoutFilePath)); - // run Director::getInstance()->replaceScene(gameScene); } - if (tag == 103)//toygamerepo + if (tag == 3)//toygamerepo { - - auto searchPaths = cocos2d::FileUtils::getInstance()->getSearchPaths(); std::string deviceSpecificFolderName; deviceSpecificFolderName = ToyResourcesConfig::RES_FOLDER_NAME_XLARGE;//TODO TEMP @@ -188,13 +137,10 @@ void HelloWorld::menuCloseCallback(Ref* pSender) // run auto _mainScene = ToyMainMenuScene::create("graphics/main_menu/scene_layout.scl"); Director::getInstance()->replaceScene(_mainScene); - } - if (tag == 104)//animal + if (tag == 4)//animal { - - auto searchPaths = cocos2d::FileUtils::getInstance()->getSearchPaths(); std::string deviceSpecificFolderName; deviceSpecificFolderName = ToyResourcesConfig::RES_FOLDER_NAME_XLARGE;//TODO TEMP @@ -206,13 +152,8 @@ void HelloWorld::menuCloseCallback(Ref* pSender) srand(time(0)); auto _mainScene = AniPickLevelScene::create(""); Director::getInstance()->replaceScene(_mainScene); - } - if (tag == 105)//exit - { - Director::getInstance()->end(); - } @@ -221,7 +162,7 @@ void HelloWorld::menuCloseCallback(Ref* pSender) - + diff --git a/ios/Runner/Wowgame/Classes/HelloWorldScene.h b/ios/Runner/Wowgame/Classes/HelloWorldScene.h index 61a5c0e..e3f6fbd 100644 --- a/ios/Runner/Wowgame/Classes/HelloWorldScene.h +++ b/ios/Runner/Wowgame/Classes/HelloWorldScene.h @@ -39,7 +39,7 @@ public: // virtual void onExit() override; // a selector callback - void menuCloseCallback(cocos2d::Ref* pSender); + void startGameById(int gameid); // implement the "static create()" method manually CREATE_FUNC(HelloWorld); diff --git a/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.h b/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.h index acd581e..d45bbae 100644 --- a/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.h +++ b/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.h @@ -7,4 +7,5 @@ void ratePromptHandler_nativePresentPromptIfApplicable(); +void handler_nativeExitGame(); #endif //RATE_PROMPT_HANDLER_IOS_H diff --git a/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.mm b/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.mm index 63869ef..129f5f6 100644 --- a/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.mm +++ b/ios/Runner/Wowgame/Classes/NativeIOS/RatePromptHandler_ios.mm @@ -11,4 +11,7 @@ void ratePromptHandler_nativePresentPromptIfApplicable(){ } } +void handler_nativeExitGame() { + [[NSNotificationCenter defaultCenter] postNotificationName:@"_kwowgamecocosexitgame" object:nil]; +} diff --git a/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.cpp b/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.cpp index 5f6a1cf..51d11d3 100644 --- a/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.cpp +++ b/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.cpp @@ -12,6 +12,12 @@ #include "AniAlertView.h" #include "AniMiscUtils.h" #include "HelloWorldScene.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "RatePromptHandler_ios.h" +#endif +#include "audio/include/AudioEngine.h" + static const int AniAlertViewTagDefault = 999; static const int AniAlertViewTagCloseConfirm = 998; @@ -46,15 +52,21 @@ bool AniAlertUtils::closeDialogIfNecessary(int tag){ return false; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) void AniAlertUtils::showAppCloseConfirmDialog(std::function onCancelCallback){ showTwoButtonDialog(AniAlertViewTagCloseConfirm, "Are you sure you want to quit?", "Yes, bye!", "No, let's play!", [](){ - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); - - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::Director::getInstance()->end(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + cocos2d::AudioEngine::stopAll(); + cocos2d::Director::getInstance()->pause(); + handler_nativeExitGame(); +#else + cocos2d::Director::getInstance()->end(); +#endif + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); }, onCancelCallback); } @@ -63,4 +75,4 @@ bool AniAlertUtils::closeAppCloseConfirmDialogIfNecessary(){ return closeDialogIfNecessary(AniAlertViewTagCloseConfirm); } -#endif +//#endif diff --git a/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.h b/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.h index 3d2f5f4..fb2e5c0 100644 --- a/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.h +++ b/ios/Runner/Wowgame/Classes/game_animal/AniAlertUtils.h @@ -19,10 +19,10 @@ public: static void showTwoButtonDialog(int tag, std::string text, std::string okButtonText, std::string cancelButtonText, std::function onOKCallback, std::function onCancelCallback = [](){}); static bool closeDialogIfNecessary(int tag); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) static void showAppCloseConfirmDialog(std::function onCancelCallback); static bool closeAppCloseConfirmDialogIfNecessary(); -#endif +//#endif }; #endif /* AniAlertUtils_h */ diff --git a/ios/Runner/Wowgame/Classes/game_animal/AniParentScene.cpp b/ios/Runner/Wowgame/Classes/game_animal/AniParentScene.cpp index 21e4345..3ccefa2 100644 --- a/ios/Runner/Wowgame/Classes/game_animal/AniParentScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_animal/AniParentScene.cpp @@ -186,7 +186,7 @@ bool AniParentScene::touchHandlerForWidget(std::string objectName, cocos2d::ui:: // _AniScenarioHandler->pauseScenario(); // _AniScenarioHandler->stopAllActions(); AniSoundsRepo::stopAllSounds(); - cocos2d::Director::getInstance()->popScene(); + cocos2d::Director::getInstance()->end(); _sceneDismissCallback(); return true; } /*else if(objectName == "backgroundMusicButton" && touchEventType == cocos2d::ui::Widget::TouchEventType::ENDED){ @@ -497,9 +497,9 @@ void AniParentScene::showTOSAcceptPopup(std::function onAccept){ if (n->isShowingParentalGate()) { n->hideParentalGate(); } else { - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); } } } @@ -524,9 +524,9 @@ void AniParentScene::showAniLevelPickerLayer(std::function onLayerDismis [&](cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event *event, cocos2d::Node *n) { if (keyCode == cocos2d::EventKeyboard::KeyCode::KEY_BACK) { if (AniMiscUtils::isNodeVisible(n)) { - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + // auto scene = HelloWorld::createScene(); + // cocos2d::Director::getInstance()->replaceScene(scene); } } }, std::placeholders::_1, std::placeholders::_2, AniLevelPickerLayer); diff --git a/ios/Runner/Wowgame/Classes/game_animal/AniSettingsLayer.cpp b/ios/Runner/Wowgame/Classes/game_animal/AniSettingsLayer.cpp index 9effa09..a853420 100644 --- a/ios/Runner/Wowgame/Classes/game_animal/AniSettingsLayer.cpp +++ b/ios/Runner/Wowgame/Classes/game_animal/AniSettingsLayer.cpp @@ -12,6 +12,7 @@ #include "AniStrings.h" #include "AniSimpleButton.h" #include "AniKKGLinearLayout.h" +#include "AniAlertUtils.h" AniSettingsLayer* AniSettingsLayer::create(float width, float height, std::function onLevelPickedCallback, std::function onTutorialResetPickedCallback){ AniSettingsLayer * view = new (std::nothrow) AniSettingsLayer(); @@ -58,6 +59,7 @@ bool AniSettingsLayer::init(float width, float height, std::function auto webLinkButton = AniSimpleButton::create(); container->addView(webLinkButton); + webLinkButton->setVisible(false); auto buttonTexturePath = "settings_buttons/steve_maggie.png"; webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath); webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ @@ -69,16 +71,38 @@ bool AniSettingsLayer::init(float width, float height, std::function }); }); + + auto replayTutorialButton = AniSimpleButton::create(); addChild(replayTutorialButton); auto repTutButtonTexturePath = "settings_buttons/play_preview_again.png"; replayTutorialButton->loadTextures(repTutButtonTexturePath, repTutButtonTexturePath, repTutButtonTexturePath); replayTutorialButton->setScale(1.5f); replayTutorialButton->setOriginalScale(1.5f); - replayTutorialButton->setPosition(cocos2d::Point(getContentSize().width-paddingTop-replayTutorialButton->getContentSize().width/2*1.5, getContentSize().height - paddingTop - replayTutorialButton->getContentSize().height*1.5/2)); + auto pos_x = getContentSize().width-paddingTop-replayTutorialButton->getContentSize().width/2*1.5; + auto pos_y = getContentSize().height - paddingTop - replayTutorialButton->getContentSize().height*1.5/2; + + replayTutorialButton->setPosition(cocos2d::Point(pos_x - 400 ,pos_y)); replayTutorialButton->setOnTouchEndedCallback([&, replayTutorialButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ _onTutorialReset(); }); + + + auto appExitButton = AniSimpleButton::create(); + addChild(appExitButton); + auto exitButtonTexturePath = "buttons/graphics/button_x.png"; + appExitButton->loadTextures(exitButtonTexturePath, exitButtonTexturePath, exitButtonTexturePath); + appExitButton->setScale(1.5f); + appExitButton->setOriginalScale(1.5f); + appExitButton->setPosition(cocos2d::Point(getContentSize().width-paddingTop-appExitButton->getContentSize().width/2*1.5, pos_y)); + appExitButton->setOnTouchEndedCallback([&, appExitButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ + AniAlertUtils::showAppCloseConfirmDialog([&](){ + }); + }); + + + + auto menuPadding = 30*AniScalingUtils::scaleAspectFillToDesignIpadProSize();//TODO magic number diff --git a/ios/Runner/Wowgame/Classes/game_food/MiscUtils.cpp b/ios/Runner/Wowgame/Classes/game_food/MiscUtils.cpp index 2c65ae7..496624c 100644 --- a/ios/Runner/Wowgame/Classes/game_food/MiscUtils.cpp +++ b/ios/Runner/Wowgame/Classes/game_food/MiscUtils.cpp @@ -11,6 +11,12 @@ #include "GeometryUtils.h" #include "AlertView.h" #include "HelloWorldScene.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "RatePromptHandler_ios.h" +#endif +#include "audio/include/AudioEngine.h" + float MiscUtils::StandardAnimationTime = 0.2; const std::string MiscUtils::WHICH_LEVEL_UD_KEY = "WHICH_LEVEL_UD_KEY"; const std::string MiscUtils::TOS_ACCEPTED_UD_KEY = "TOS_ACCEPTED_UD_KEY"; @@ -180,7 +186,7 @@ std::string MiscUtils::clockMinSecTimeString(int seconds){ return timeString; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) static const int AlertViewTag = 999; @@ -198,10 +204,18 @@ void MiscUtils::showAppCloseConfirmDialog(std::function onCancelCallback auto okColor = cocos2d::Color3B(200, 100, 100); auto alert = AlertView::create(message, okText, cancelText, okColor, cancelColor, []() { - // cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::Director::getInstance()->end(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + cocos2d::AudioEngine::stopAll(); + cocos2d::Director::getInstance()->pause(); + handler_nativeExitGame(); +#else + cocos2d::Director::getInstance()->end(); +#endif + // auto scene = HelloWorld::createScene(); + // cocos2d::Director::getInstance()->replaceScene(scene); }, onCancelCallback); @@ -231,4 +245,4 @@ bool MiscUtils::closeAppCloseConfirmDialogIfNecessary(){ return false; } -#endif +//#endif diff --git a/ios/Runner/Wowgame/Classes/game_food/MiscUtils.h b/ios/Runner/Wowgame/Classes/game_food/MiscUtils.h index c7ad754..70e03f1 100644 --- a/ios/Runner/Wowgame/Classes/game_food/MiscUtils.h +++ b/ios/Runner/Wowgame/Classes/game_food/MiscUtils.h @@ -67,10 +67,10 @@ static void changeAnchorPoint(cocos2d::Node* p_node, cocos2d::Point p_newAnchorP static std::string boolToString(bool value); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) static void showAppCloseConfirmDialog(std::function onCancelCallback); static bool closeAppCloseConfirmDialogIfNecessary(); -#endif +//#endif }; #endif /* MiscUtils_h */ diff --git a/ios/Runner/Wowgame/Classes/game_food/ParentScene.cpp b/ios/Runner/Wowgame/Classes/game_food/ParentScene.cpp index 6a615ce..08bee39 100644 --- a/ios/Runner/Wowgame/Classes/game_food/ParentScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_food/ParentScene.cpp @@ -497,9 +497,9 @@ void ParentScene::showTOSAcceptPopup(std::function onAccept){ if (n->isShowingParentalGate()) { n->hideParentalGate(); } else { - // cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + // auto scene = HelloWorld::createScene(); + // cocos2d::Director::getInstance()->replaceScene(scene); } } } @@ -524,9 +524,9 @@ void ParentScene::showLevelPickerLayer(std::function onLayerDismissed, s [&](cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event *event, cocos2d::Node *n) { if (keyCode == cocos2d::EventKeyboard::KeyCode::KEY_BACK) { if (MiscUtils::isNodeVisible(n)) { - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); } } }, std::placeholders::_1, std::placeholders::_2, levelPickerLayer); diff --git a/ios/Runner/Wowgame/Classes/game_food/SettingsLayer.cpp b/ios/Runner/Wowgame/Classes/game_food/SettingsLayer.cpp index e82a04b..eec1a51 100644 --- a/ios/Runner/Wowgame/Classes/game_food/SettingsLayer.cpp +++ b/ios/Runner/Wowgame/Classes/game_food/SettingsLayer.cpp @@ -73,31 +73,54 @@ bool SettingsLayer::init(float width, float height, std::function onL #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - setupAppLinksView(cocos2d::Point(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingBottom - paddingTop)); - wholeContainer->addChild(m_appLinksView); //TODO messy messy - auto leftAppLinkSprite = cocos2d::Sprite::create("app_links/witch_halloween_app.png"); - leftAppLinkSprite->setAnchorPoint(cocos2d::Vec2(1,1)); - leftAppLinkSprite->setPosition(cocos2d::Vec2(m_appLinksView->getBoundingBox().getMinX(), m_appLinksView->getBoundingBox().getMaxY())); - auto rightAppLinkSprite = cocos2d::Sprite::create("app_links/doll_toy_app.png"); - rightAppLinkSprite->setAnchorPoint(cocos2d::Vec2(0,0)); - rightAppLinkSprite->setPosition(cocos2d::Vec2(m_appLinksView->getBoundingBox().getMaxX(), m_appLinksView->getBoundingBox().getMinY())); - wholeContainer->addChild(leftAppLinkSprite); - wholeContainer->addChild(rightAppLinkSprite); + // setupAppLinksView(cocos2d::Point(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingBottom - paddingTop)); + // wholeContainer->addChild(m_appLinksView); //TODO messy messy + // auto leftAppLinkSprite = cocos2d::Sprite::create("app_links/witch_halloween_app.png"); + // leftAppLinkSprite->setAnchorPoint(cocos2d::Vec2(1,1)); + // leftAppLinkSprite->setPosition(cocos2d::Vec2(m_appLinksView->getBoundingBox().getMinX(), m_appLinksView->getBoundingBox().getMaxY())); + // auto rightAppLinkSprite = cocos2d::Sprite::create("app_links/doll_toy_app.png"); + // rightAppLinkSprite->setAnchorPoint(cocos2d::Vec2(0,0)); + // rightAppLinkSprite->setPosition(cocos2d::Vec2(m_appLinksView->getBoundingBox().getMaxX(), m_appLinksView->getBoundingBox().getMinY())); + // wholeContainer->addChild(leftAppLinkSprite); + // wholeContainer->addChild(rightAppLinkSprite); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - auto webLinkButton = SimpleButton::create(); - wholeContainer->addChild(webLinkButton); - auto buttonTexturePath = "app_links/steve_maggie.png"; - webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath); - webLinkButton->setPosition(cocos2d::Point(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingTop*3 - webLinkButton->getBoundingBox().size.height/2)); - webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ - presentParentalGate([&](){ - hideParentalGate(); - cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded - }, [&](){ - hideParentalGate(); + // auto webLinkButton = SimpleButton::create(); + // wholeContainer->addChild(webLinkButton); + // auto buttonTexturePath = "app_links/steve_maggie.png"; + // webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath); + // webLinkButton->setPosition(cocos2d::Point(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingTop*3 - webLinkButton->getBoundingBox().size.height/2)); + // webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ + // presentParentalGate([&](){ + // hideParentalGate(); + // cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded + // }, [&](){ + // hideParentalGate(); + // }); + // }); +#endif + auto paddingExitButton = 20*ScalingUtils::scaleAspectFillToDesignIpadProSize(); + auto scaleExitButton = 1.0f; + if(ScalingUtils::isSmallDevice()){ + paddingExitButton *= ScalingUtils::getScaleForSmallDevice(); + scaleExitButton = 1.6f; + } + + auto appExitButton = SimpleButton::create(); + addChild(appExitButton); + auto exitButtonTexturePath = "buttons/graphics/button_x.png"; + appExitButton->loadTextures(exitButtonTexturePath, exitButtonTexturePath, exitButtonTexturePath); + appExitButton->setScale(scaleExitButton); + appExitButton->setOriginalScale(scaleExitButton); + appExitButton->setPosition(cocos2d::Point(getContentSize().width - appExitButton->getBoundingBox().size.width/2 - paddingExitButton, getContentSize().height - appExitButton->getBoundingBox().size.height/2 - paddingExitButton)); + appExitButton->setOnTouchEndedCallback([&, appExitButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ + MiscUtils::showAppCloseConfirmDialog([&](){ }); }); -#endif + + + + + auto menuPadding = 30*ScalingUtils::scaleAspectFillToDesignIpadProSize();//TODO magic number @@ -114,9 +137,9 @@ bool SettingsLayer::init(float width, float height, std::function onL lowerStuffContainer->setAnchorPoint(cocos2d::Vec2(0.5, 1)); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - lowerStuffContainer->setPosition(getContentSize().width/2, m_appLinksView->getBoundingBox().getMinY() - paddingBottom); + lowerStuffContainer->setPosition(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingBottom); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - lowerStuffContainer->setPosition(getContentSize().width/2, webLinkButton->getBoundingBox().getMinY() - paddingBottom); + lowerStuffContainer->setPosition(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingBottom); #endif menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2); diff --git a/ios/Runner/Wowgame/Classes/game_food/SubGameScene.cpp b/ios/Runner/Wowgame/Classes/game_food/SubGameScene.cpp index ebcfb7b..c2c9c74 100644 --- a/ios/Runner/Wowgame/Classes/game_food/SubGameScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_food/SubGameScene.cpp @@ -196,7 +196,7 @@ void SubGameScene::presentGameResumeLayer(){ buttonResume->addChild(buttonBg); buttonBg->setPosition(cocos2d::Vec2(buttonResume->getContentSize().width/2,buttonResume->getContentSize().height/2)); resumeLayer->addChild(buttonResume); - buttonResume->setPosition(cocos2d::Vec2(resumeLayer->getContentSize().width/2 -150 , resumeLayer->getContentSize().height/2)); + buttonResume->setPosition(cocos2d::Vec2(resumeLayer->getContentSize().width/2, resumeLayer->getContentSize().height/2)); buttonResume->setOnTouchEndedCallback(std::bind([&](std::string name, cocos2d::ui::Widget::TouchEventType eventType, cocos2d::Node* n){ resumeGame(); MiscUtils::hideAndRemoveView(n, true); @@ -204,29 +204,6 @@ void SubGameScene::presentGameResumeLayer(){ - // add the close button - auto buttonClose = SimpleButton::create(); - buttonClose->setCascadeOpacityEnabled(true); - auto buttonTexturePath2 = "buttons/graphics/button_x.png"; - buttonClose->loadTextures(buttonTexturePath2, buttonTexturePath2, buttonTexturePath2); - - resumeLayer->addChild(buttonClose); - buttonClose->setPosition(cocos2d::Vec2(resumeLayer->getContentSize().width / 2 + 150, resumeLayer->getContentSize().height / 2)); - buttonClose->setOnTouchEndedCallback(std::bind([&](std::string name, cocos2d::ui::Widget::TouchEventType eventType, cocos2d::Node* n) { - - auto scene = HelloWorld::createScene(); - // run - cocos2d::Director::getInstance()->replaceScene(scene); - - - }, std::placeholders::_1, std::placeholders::_2, resumeLayer)); - - - - - - - resumeLayer->setOpacity(0); MiscUtils::showView(resumeLayer, true, 220.f); diff --git a/ios/Runner/Wowgame/Classes/game_halloween/HMiscUtils.cpp b/ios/Runner/Wowgame/Classes/game_halloween/HMiscUtils.cpp index 7ad228e..715caa6 100644 --- a/ios/Runner/Wowgame/Classes/game_halloween/HMiscUtils.cpp +++ b/ios/Runner/Wowgame/Classes/game_halloween/HMiscUtils.cpp @@ -14,6 +14,11 @@ #include "HSoundUtils.h" #include "HelloWorldScene.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "RatePromptHandler_ios.h" +#endif +#include "audio/include/AudioEngine.h" + float HMiscUtils::StandardAnimationTime = 0.2; const std::string HMiscUtils::MAGGIE_TOUCHED_UD_KEY = "MAGGIE_TOUCHED_UD_KEY"; const std::string HMiscUtils::WHICH_LEVEL_UD_KEY = "WHICH_LEVEL_UD_KEY"; @@ -184,12 +189,20 @@ void HMiscUtils::showAppCloseConfirmDialog(std::function onCancelCallbac // HSoundUtils::stopAllSounds(); //todo dedup in other places? // cocoss2d::AudioEngine::end(); - - //cocos2d::Director::getInstance()->end(); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::Director::getInstance()->end(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + cocos2d::AudioEngine::stopAll(); + cocos2d::Director::getInstance()->pause(); + handler_nativeExitGame(); +#else + cocos2d::Director::getInstance()->end(); +#endif + // create a scene. it's an autorelease object - auto scene = HelloWorld::createScene(); + //auto scene = HelloWorld::createScene(); // run - cocos2d::Director::getInstance()->replaceScene(scene); + //cocos2d::Director::getInstance()->replaceScene(scene); diff --git a/ios/Runner/Wowgame/Classes/game_halloween/HSettingsLayer.cpp b/ios/Runner/Wowgame/Classes/game_halloween/HSettingsLayer.cpp index 94f4772..d364ec4 100644 --- a/ios/Runner/Wowgame/Classes/game_halloween/HSettingsLayer.cpp +++ b/ios/Runner/Wowgame/Classes/game_halloween/HSettingsLayer.cpp @@ -63,15 +63,16 @@ bool HSettingsLayer::init(float width, float height, std::function on auto webLinkButton = HalloweenSimpleButton::create(); wholeContainer->addView(webLinkButton); + webLinkButton->setVisible(false); auto buttonTexturePath = "settings_buttons/steve_maggie.png"; webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath); webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ - presentParentalGate([&](){ - hideParentalGate(); - cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded - }, [&](){ - hideParentalGate(); - }); + // presentParentalGate([&](){ + // hideParentalGate(); + // cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded + // }, [&](){ + // hideParentalGate(); + // }); }); auto lowerStuffContainer = cocos2d::Node::create(); diff --git a/ios/Runner/Wowgame/Classes/game_halloween/HSubGameScene.cpp b/ios/Runner/Wowgame/Classes/game_halloween/HSubGameScene.cpp index a487d53..511cdd5 100644 --- a/ios/Runner/Wowgame/Classes/game_halloween/HSubGameScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_halloween/HSubGameScene.cpp @@ -568,10 +568,10 @@ void HSubGameScene::showTOSAcceptPopup(std::function onAccept){ } else { // HSoundUtils::stopAllSounds(); // cocos2d::AudioEngine::end(); - //cocos2d::Director::getInstance()->end(); + cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); } } } @@ -593,10 +593,10 @@ void HSubGameScene::showHLevelPickerLayer(std::function onLayerDismissed if(HMiscUtils::isNodeVisible(n)){ // HSoundUtils::stopAllSounds(); // cocos2d::AudioEngine::end(); - //cocos2d::Director::getInstance()->end(); + cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); diff --git a/ios/Runner/Wowgame/Classes/game_toy/ToyMainMenuScene.cpp b/ios/Runner/Wowgame/Classes/game_toy/ToyMainMenuScene.cpp index bc3d61a..e31f348 100644 --- a/ios/Runner/Wowgame/Classes/game_toy/ToyMainMenuScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_toy/ToyMainMenuScene.cpp @@ -343,9 +343,9 @@ void ToyMainMenuScene::showTOSAcceptPopup(std::function onAccept){ } else { - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); } diff --git a/ios/Runner/Wowgame/Classes/game_toy/ToyMiscUtils.cpp b/ios/Runner/Wowgame/Classes/game_toy/ToyMiscUtils.cpp index 2d8fbd6..a0d323c 100644 --- a/ios/Runner/Wowgame/Classes/game_toy/ToyMiscUtils.cpp +++ b/ios/Runner/Wowgame/Classes/game_toy/ToyMiscUtils.cpp @@ -11,6 +11,14 @@ #include "ToyGeometryUtils.h" #include "ToyAlertView.h" #include "HelloWorldScene.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "RatePromptHandler_ios.h" +#endif + +#include "audio/include/AudioEngine.h" + + float ToyMiscUtils::StandardAnimationTime = 0.2; const std::string ToyMiscUtils::MAGGIE_TOUCHED_UD_KEY = "MAGGIE_TOUCHED_UD_KEY"; const std::string ToyMiscUtils::WHICH_LEVEL_UD_KEY = "WHICH_LEVEL_UD_KEY"; @@ -196,12 +204,18 @@ void ToyMiscUtils::showAppCloseConfirmDialog(std::function onCancelCallb auto alert = ToyAlertView::create(message, okText, cancelText, okColor, cancelColor, []() { - - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); - - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::Director::getInstance()->end(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + cocos2d::AudioEngine::stopAll(); + cocos2d::Director::getInstance()->pause(); + handler_nativeExitGame(); +#else + cocos2d::Director::getInstance()->end(); +#endif + + // auto scene = HelloWorld::createScene(); + // cocos2d::Director::getInstance()->replaceScene(scene); }, onCancelCallback); auto touchListener = cocos2d::EventListenerTouchOneByOne::create(); diff --git a/ios/Runner/Wowgame/Classes/game_toy/ToyParentScene.cpp b/ios/Runner/Wowgame/Classes/game_toy/ToyParentScene.cpp index fdbea09..aa904a7 100644 --- a/ios/Runner/Wowgame/Classes/game_toy/ToyParentScene.cpp +++ b/ios/Runner/Wowgame/Classes/game_toy/ToyParentScene.cpp @@ -497,10 +497,10 @@ void ToyParentScene::showTOSAcceptPopup(std::function onAccept){ if (n->isShowingParentalGate()) { n->hideParentalGate(); } else { - //cocos2d::Director::getInstance()->end(); + cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); } @@ -523,9 +523,9 @@ void ToyParentScene::showToyLevelPickerLayer(std::function onLayerDismis keyboardListener->onKeyReleased = std::bind([&](cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event, cocos2d::Node* n){ if(keyCode == cocos2d::EventKeyboard::KeyCode::KEY_BACK){ if(ToyMiscUtils::isNodeVisible(n)){ - //cocos2d::Director::getInstance()->end(); - auto scene = HelloWorld::createScene(); - cocos2d::Director::getInstance()->replaceScene(scene); + cocos2d::Director::getInstance()->end(); + //auto scene = HelloWorld::createScene(); + //cocos2d::Director::getInstance()->replaceScene(scene); diff --git a/ios/Runner/Wowgame/Classes/game_toy/ToySettingsLayer.cpp b/ios/Runner/Wowgame/Classes/game_toy/ToySettingsLayer.cpp index 559d528..8570ee0 100644 --- a/ios/Runner/Wowgame/Classes/game_toy/ToySettingsLayer.cpp +++ b/ios/Runner/Wowgame/Classes/game_toy/ToySettingsLayer.cpp @@ -76,13 +76,14 @@ bool ToySettingsLayer::init(float width, float height, std::function auto webLinkButton = ToySimpleButton::create(); wholeContainer->addChild(webLinkButton); + webLinkButton->setVisible(false); auto buttonTexturePath = "settings_buttons/steve_maggie.png"; webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath); webLinkButton->setPosition(cocos2d::Point(getContentSize().width/2, upperStuffContainer->getBoundingBox().getMinY() - paddingTop*2 - webLinkButton->getBoundingBox().size.height/2)); webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){ // presentParentalGate([&](){ // hideParentalGate(); - cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded +// cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded // }, [&](){ // hideParentalGate(); // }); diff --git a/ios/Runner/Wowgame/Resources/CloseNormal.png b/ios/Runner/Wowgame/Resources/CloseNormal.png deleted file mode 100644 index b65498c..0000000 --- a/ios/Runner/Wowgame/Resources/CloseNormal.png +++ /dev/null diff --git a/ios/Runner/Wowgame/Resources/CloseSelected.png b/ios/Runner/Wowgame/Resources/CloseSelected.png deleted file mode 100644 index 306749e..0000000 --- a/ios/Runner/Wowgame/Resources/CloseSelected.png +++ /dev/null diff --git a/ios/Runner/Wowgame/Resources/HelloWorld.png b/ios/Runner/Wowgame/Resources/HelloWorld.png deleted file mode 100644 index 21d4326..0000000 --- a/ios/Runner/Wowgame/Resources/HelloWorld.png +++ /dev/null diff --git a/ios/Runner/Wowgame/Resources/game_animal/xlarge/buttons/graphics/button_x.png b/ios/Runner/Wowgame/Resources/game_animal/xlarge/buttons/graphics/button_x.png new file mode 100644 index 0000000..98d50d2 --- /dev/null +++ b/ios/Runner/Wowgame/Resources/game_animal/xlarge/buttons/graphics/button_x.png diff --git a/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.h b/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.h index 81e0e1a..c610d70 100644 --- a/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.h +++ b/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.h @@ -16,7 +16,7 @@ + (instancetype)sharedManager; - (void)detoryCocosEnvironment; -- (void)runGame; +- (void)runGame:(NSInteger)gameid; @end diff --git a/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.mm b/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.mm index a4f14ea..6d9f076 100644 --- a/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.mm +++ b/ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.mm @@ -7,7 +7,8 @@ #import "WowGameCocosManager.h" -#import "cocos2d.h" +#include "cocos2d.h" + #import "CocosAppDelegate.h" @interface WowGameCocosManager () { @@ -41,9 +42,15 @@ static CocosAppDelegate cocosAppDelegate; cocos2d::GLViewImpl::convertAttrs(); _app = app; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitGame) name:@"_kwowgamecocosexitgame" object:nil]; +} + +- (void)exitGame { + [self.gameViewController dismissViewControllerAnimated:YES completion:nil]; } -- (void)runGame { +- (void)runGame:(NSInteger)gameid { UIWindow *window = UIApplication.sharedApplication.delegate.window; UIViewController *rootvc = window.rootViewController; if ([rootvc isKindOfClass:WowGameViewController.class]) { @@ -52,35 +59,38 @@ static CocosAppDelegate cocosAppDelegate; if (!self.gameViewController) { WowGameViewController *cocosvc = [[WowGameViewController alloc] init]; cocosvc.wantsFullScreenLayout = YES; -// self.gameViewController = cocosvc; + self.gameViewController = cocosvc; cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView((__bridge void *)cocosvc.view); cocos2d::Director::getInstance()->setOpenGLView(glview); _app->run(); - [rootvc presentViewController:cocosvc animated:YES completion:nil]; -// return; } else { - [self cocosWillEnterForeground]; + cocos2d::Director::getInstance()->resume(); } -// + [rootvc presentViewController:self.gameViewController animated:YES completion:nil]; -// debug exit game - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self popGame]; -// [self cocosDidEnterBackground]; -// [rootvc dismissViewControllerAnimated:YES completion:nil]; - -// [self cocosDidEnterBackground]; + [self startGameWithID:gameid]; + +//// debug exit game +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ +// [self exitGame]; +// }); +} + +-(void)startGameWithID:(NSInteger)gameid { + cocos2d::Director::getInstance()->getScheduler()->performFunctionInCocosThread([=] { +// CCLOG("start gameid---> %d ", gameid); + cocos2d::EventCustom evtEnter("start_gameid"); + evtEnter.setUserData((void *) gameid); + cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&evtEnter); }); } - (void)popGame { [self.gameViewController dismissViewControllerAnimated:YES completion:nil]; - [self cocosDidEnterBackground]; -// cocos2d::Director::getInstance()->end(); - +// [self cocosDidEnterBackground]; } diff --git a/ios/cocos2d/cocos/base/CCDirector.cpp b/ios/cocos2d/cocos/base/CCDirector.cpp index 5031377..45c5400 100644 --- a/ios/cocos2d/cocos/base/CCDirector.cpp +++ b/ios/cocos2d/cocos/base/CCDirector.cpp @@ -194,7 +194,7 @@ Director::~Director() #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); +// exit(0); #endif } diff --git a/lib/app/app.dart b/lib/app/app.dart index dba3ea1..80b5808 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -3,8 +3,6 @@ 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/responsive_framework.dart'; -// import 'package:responsive_framework/breakpoint.dart'; -// import 'package:responsive_framework/responsive_breakpoints.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/app/splash_page.dart b/lib/app/splash_page.dart index 96d7725..3cf91be 100644 --- a/lib/app/splash_page.dart +++ b/lib/app/splash_page.dart @@ -69,7 +69,7 @@ class _TransitionViewState extends State { } else { pushNamedAndRemoveUntil(AppRouteName.login, (route) => false); }*/ - pushNamedAndRemoveUntil(AppRouteName.home, (route) => false); + pushNamedAndRemoveUntil(AppRouteName.moduleSelect, (route) => false); }); } diff --git a/lib/common/request/apis.dart b/lib/common/request/apis.dart index f994eab..a0e61fb 100644 --- a/lib/common/request/apis.dart +++ b/lib/common/request/apis.dart @@ -82,4 +82,14 @@ class Apis { /// 退出课堂 static const String exitClass = 'course/exit/class'; + + /// 商品列表 + static const String productList = 'order/course/combo/list'; + + /// 创建订单 + static const String createOrder = 'order/create/order'; + + /// 获取阿里支付token + static const String getAliPayToken = 'pay/alipay/token'; + } diff --git a/lib/common/request/dao/shop_dao.dart b/lib/common/request/dao/shop_dao.dart new file mode 100644 index 0000000..73c1850 --- /dev/null +++ b/lib/common/request/dao/shop_dao.dart @@ -0,0 +1,21 @@ +import '../../../models/product_entity.dart'; +import '../request_client.dart'; + +class ShopDao { + ///商品列表 + static Future productList() async { + return await requestClient.get>(Apis.productList); + } + + ///创建订单 + static Future createOrder(ProductEntity productEntity) async { + return await requestClient + .post>(Apis.createOrder, data: {'courseComboId': productEntity.id}); + } + + ///获取ali支付订单信息 + static Future getAliPayToken(String orderNo) async { + return await requestClient + .post>(Apis.getAliPayToken, data: {'orderNo': orderNo}); + } +} 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..b91e1a1 --- /dev/null +++ b/lib/generated/json/product_entity.g.dart @@ -0,0 +1,98 @@ +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 int? id = jsonConvert.convert(json['id']); + if (id != null) { + productEntity.id = id; + } + final String? name = jsonConvert.convert(json['name']); + if (name != null) { + productEntity.name = name; + } + final String? title = jsonConvert.convert(json['title']); + if (title != null) { + productEntity.title = title; + } + final double? price = jsonConvert.convert(json['price']); + if (price != null) { + productEntity.price = price; + } + final String? picUrl = jsonConvert.convert(json['picUrl']); + if (picUrl != null) { + productEntity.picUrl = picUrl; + } + final String? bannerPicUrl = jsonConvert.convert( + json['bannerPicUrl']); + if (bannerPicUrl != null) { + productEntity.bannerPicUrl = bannerPicUrl; + } + final String? detailPicUrl = jsonConvert.convert( + json['detailPicUrl']); + if (detailPicUrl != null) { + productEntity.detailPicUrl = detailPicUrl; + } + final int? saleType = jsonConvert.convert(json['saleType']); + if (saleType != null) { + productEntity.saleType = saleType; + } + final int? status = jsonConvert.convert(json['status']); + if (status != null) { + productEntity.status = status; + } + final int? sortOrder = jsonConvert.convert(json['sortOrder']); + if (sortOrder != null) { + productEntity.sortOrder = sortOrder; + } + final int? validityType = jsonConvert.convert(json['validityType']); + if (validityType != null) { + productEntity.validityType = validityType; + } + return productEntity; +} + +Map $ProductEntityToJson(ProductEntity entity) { + final Map data = {}; + data['id'] = entity.id; + data['name'] = entity.name; + data['title'] = entity.title; + data['price'] = entity.price; + data['picUrl'] = entity.picUrl; + data['bannerPicUrl'] = entity.bannerPicUrl; + data['detailPicUrl'] = entity.detailPicUrl; + data['saleType'] = entity.saleType; + data['status'] = entity.status; + data['sortOrder'] = entity.sortOrder; + data['validityType'] = entity.validityType; + return data; +} + +extension ProductEntityExtension on ProductEntity { + ProductEntity copyWith({ + int? id, + String? name, + String? title, + double? price, + String? picUrl, + String? bannerPicUrl, + String? detailPicUrl, + int? saleType, + int? status, + int? sortOrder, + int? validityType, + }) { + return ProductEntity() + ..id = id ?? this.id + ..name = name ?? this.name + ..title = title ?? this.title + ..price = price ?? this.price + ..picUrl = picUrl ?? this.picUrl + ..bannerPicUrl = bannerPicUrl ?? this.bannerPicUrl + ..detailPicUrl = detailPicUrl ?? this.detailPicUrl + ..saleType = saleType ?? this.saleType + ..status = status ?? this.status + ..sortOrder = sortOrder ?? this.sortOrder + ..validityType = validityType ?? this.validityType; + } +} \ 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..7f18480 --- /dev/null +++ b/lib/models/product_entity.dart @@ -0,0 +1,43 @@ +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 { + + int? id; + + String? name; + + String? title; + + /// 售卖价格 + double? price; + /// 商品图片 + String? picUrl; + /// 商品banner图片 + String? bannerPicUrl; + /// 商品详情图片 + String? detailPicUrl; + /// 销售类型 + int? saleType; + /// 状态 + int? status; + /// 序号 + int? sortOrder; + /// 有效期类型 + int? validityType; + + + 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/games/bloc.dart b/lib/pages/games/bloc.dart new file mode 100644 index 0000000..51952b4 --- /dev/null +++ b/lib/pages/games/bloc.dart @@ -0,0 +1,53 @@ +import 'package:bloc/bloc.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/services.dart'; +import 'package:wow_english/common/extension/string_extension.dart'; + +import 'event.dart'; +import 'game_entity.dart'; +import 'state.dart'; + +class GamesBloc extends Bloc { + + late MethodChannel _methodChannel; + + //手动初始化4个GameEntity对象 + final List _games = [ + GameEntity() + ..id = 1 + ..imageName = 'pic_module_game'.assetPng + ..name = '游戏1', + GameEntity() + ..id = 2 + ..imageName = 'pic_module_game'.assetPng + ..name = '游戏2', + GameEntity() + ..id = 3 + ..imageName = 'pic_module_game'.assetPng + ..name = '游戏3', + GameEntity() + ..id = 4 + ..imageName = 'pic_module_game'.assetPng + ..name = '游戏4' + ]; + + List get listData => _games; + + GamesBloc() : super(GamesState().init()) { + on(_init); + on(_gotoGamePage); + } + + void _init(InitEvent event, Emitter emit) async { + emit(state.clone()); + } + + void _gotoGamePage(GotoGamePageEvent event, Emitter emit) async { + try { + _methodChannel = const MethodChannel('wow_english/game_method_channel'); + await _methodChannel.invokeMethod('openGamePage', { "gameId": event.gameId }); + } on PlatformException catch (e) { + debugPrint("Failed to go to native page: '${e.message}'."); + } + } +} diff --git a/lib/pages/games/event.dart b/lib/pages/games/event.dart new file mode 100644 index 0000000..a93bc66 --- /dev/null +++ b/lib/pages/games/event.dart @@ -0,0 +1,10 @@ +abstract class GamesEvent {} + +class InitEvent extends GamesEvent {} + +///进入游戏页面 +class GotoGamePageEvent extends GamesEvent { + late final int gameId; + + GotoGamePageEvent(this.gameId); +} \ No newline at end of file diff --git a/lib/pages/games/game_entity.dart b/lib/pages/games/game_entity.dart new file mode 100644 index 0000000..ce642bf --- /dev/null +++ b/lib/pages/games/game_entity.dart @@ -0,0 +1,11 @@ + + + +class GameEntity { + + late int id; + + late String imageName; + + late String name; +} \ No newline at end of file diff --git a/lib/pages/games/state.dart b/lib/pages/games/state.dart new file mode 100644 index 0000000..b85f56b --- /dev/null +++ b/lib/pages/games/state.dart @@ -0,0 +1,9 @@ +class GamesState { + GamesState init() { + return GamesState(); + } + + GamesState clone() { + return GamesState(); + } +} diff --git a/lib/pages/games/view.dart b/lib/pages/games/view.dart new file mode 100644 index 0000000..8c3ad75 --- /dev/null +++ b/lib/pages/games/view.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:wow_english/common/widgets/we_app_bar.dart'; +import 'package:wow_english/pages/games/state.dart'; + +import '../games/event.dart'; +import 'bloc.dart'; + + +class GamesPage extends StatelessWidget { + const GamesPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => GamesBloc()..add(InitEvent()), + child: Builder(builder: (context) => _GamesPageView()), + ); + } +} + +class _GamesPageView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BlocListener( + listener: (context, state) {}, + child: Scaffold( + appBar: const WEAppBar( + titleText: '游戏专区', + centerTitle: false, + ), + body: _gamesView(), + ), + ); + } + + Widget _gamesView() => + BlocBuilder(builder: (context, state) { + final bloc = BlocProvider.of(context); + //屏幕中间横着放四张图片一行展示(尺寸120*200),每张图片下方有行文字 + return Container( + margin: EdgeInsets.symmetric(horizontal: 50.0.w), + child: GridView.builder( + padding: EdgeInsets.zero, + // physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + childAspectRatio: 0.6, + ), + itemCount: bloc.listData.length, + itemBuilder: (BuildContext context, int index) { + final gameEntity = bloc.listData[index]; + return GestureDetector( + onTap: () { + bloc.add(GotoGamePageEvent(gameEntity.id)); + }, + child: Column( + children: [ + Image.asset(gameEntity.imageName, + width: 120, height: 200), + Text(gameEntity.name, + style: TextStyle( + fontSize: 14.sp, + color: const Color(0xFF140C10))) + ], + ), + ); + })); + }); +} diff --git a/lib/pages/home/widgets/home_tab_header_widget.dart b/lib/pages/home/widgets/home_tab_header_widget.dart index 1b9a63b..d77785a 100644 --- a/lib/pages/home/widgets/home_tab_header_widget.dart +++ b/lib/pages/home/widgets/home_tab_header_widget.dart @@ -104,14 +104,14 @@ class HomeTabHeaderWidget extends StatelessWidget { } }, icon: Image.asset('listen'.assetPng)), - // IconButton( - // onPressed: (){ - // if(actionTap != null) { - // actionTap!(HeaderActionType.shop); - // } - // }, - // icon: Image.asset('shop'.assetPng) - // ), + IconButton( + onPressed: (){ + if(actionTap != null) { + actionTap!(HeaderActionType.shop); + } + }, + icon: Image.asset('shop'.assetPng) + ), ScreenUtil().bottomBarHeight.horizontalSpace, ], ) diff --git a/lib/pages/moduleSelect/bloc.dart b/lib/pages/moduleSelect/bloc.dart new file mode 100644 index 0000000..e4bd5f8 --- /dev/null +++ b/lib/pages/moduleSelect/bloc.dart @@ -0,0 +1,16 @@ +import 'package:bloc/bloc.dart'; + +import 'event.dart'; +import 'state.dart'; + + +class ModuleSelectBloc extends Bloc { + + ModuleSelectBloc() : super(ModuleSelectState().init()) { + on(_init); + } + + void _init(InitEvent event, Emitter emit) async { + emit(state.clone()); + } +} diff --git a/lib/pages/moduleSelect/event.dart b/lib/pages/moduleSelect/event.dart new file mode 100644 index 0000000..5695068 --- /dev/null +++ b/lib/pages/moduleSelect/event.dart @@ -0,0 +1,3 @@ +abstract class ModuleSelectEvent {} + +class InitEvent extends ModuleSelectEvent {} \ No newline at end of file diff --git a/lib/pages/moduleSelect/state.dart b/lib/pages/moduleSelect/state.dart new file mode 100644 index 0000000..8a51120 --- /dev/null +++ b/lib/pages/moduleSelect/state.dart @@ -0,0 +1,9 @@ +class ModuleSelectState { + ModuleSelectState init() { + return ModuleSelectState(); + } + + ModuleSelectState clone() { + return ModuleSelectState(); + } +} diff --git a/lib/pages/moduleSelect/view.dart b/lib/pages/moduleSelect/view.dart new file mode 100644 index 0000000..463fbd5 --- /dev/null +++ b/lib/pages/moduleSelect/view.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:wow_english/common/extension/string_extension.dart'; +import 'package:wow_english/pages/moduleSelect/state.dart'; +import 'package:wow_english/pages/moduleSelect/widgets/BaseHomeHeaderWidget.dart'; + +import 'bloc.dart'; +import 'event.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:wow_english/route/route.dart'; + +class ModuleSelectPage extends StatelessWidget { + const ModuleSelectPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => ModuleSelectBloc()..add(InitEvent()), + child: Builder(builder: (context) => _HomePageView()), + ); + } +} + +class _HomePageView extends StatelessWidget { + @override + Widget build(BuildContext context) { + final bloc = BlocProvider.of(context); + return BlocListener( + listener: (context, state) {}, + child: _homeView(), + ); + } + + Widget _homeView() => BlocBuilder( + builder: (context, state) { + final bloc = BlocProvider.of(context); + return Scaffold( + body: Container( + color: Colors.white, + child: Column( + children: [ + const BaseHomeHeaderWidget(), + Expanded( + child: Center( + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () { + pushNamed(AppRouteName.home); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + alignment: AlignmentDirectional.center, + children: [ + Image.asset('bg_frame_module'.assetPng, + width: 162.5.w, height: 203.5.h), + Center( + child: Image.asset( + 'pic_module_study'.assetPng, + width: 140.5.w, + height: 172.h), + ) + ]), + 10.verticalSpace, + Image.asset('label_module_study'.assetPng, + width: 124.w, height: 34.h), + ], + ), + ), + ), + Expanded( + child: GestureDetector( + onTap: () { + pushNamed(AppRouteName.games); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + alignment: AlignmentDirectional.center, + children: [ + Image.asset('bg_frame_module'.assetPng, + width: 162.5.w, height: 203.5.h), + Image.asset('pic_module_game'.assetPng, + width: 140.5.w, height: 172.h) + ]), + 10.verticalSpace, + Image.asset('label_module_game'.assetPng, + width: 124.w, height: 34.h), + ], + )), + ), + ], + ), + ), + ) + ], + ), + ), + ); + }); +} diff --git a/lib/pages/moduleSelect/widgets/BaseHomeHeaderWidget.dart b/lib/pages/moduleSelect/widgets/BaseHomeHeaderWidget.dart new file mode 100644 index 0000000..5560345 --- /dev/null +++ b/lib/pages/moduleSelect/widgets/BaseHomeHeaderWidget.dart @@ -0,0 +1,104 @@ +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/user_util.dart'; +import '../../../models/course_entity.dart'; +import '../../../route/route.dart'; +import '../../../utils/image_util.dart'; +import '../../user/bloc/user_bloc.dart'; + +class BaseHomeHeaderWidget extends StatelessWidget { + const BaseHomeHeaderWidget({super.key, this.entity}); + + final CourseEntity? entity; + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return Container( + height: 45, + width: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('bg_header_sliver'.assetPng), + fit: BoxFit.cover, + ), + ), + padding: EdgeInsets.symmetric(horizontal: 9.5.w), + child: Row( + children: [ + ScreenUtil().bottomBarHeight.horizontalSpace, + GestureDetector( + onTap: () => {onUserClick()}, + child: Container( + decoration: BoxDecoration( + border: Border.all( + width: 1.0, + color: const Color(0xFF140C10), + ), + borderRadius: BorderRadius.circular(21), + ), + child: CircleAvatar( + radius: 21, + backgroundImage: ImageUtil.getImageProviderOnDefault( + UserUtil.getUser()?.avatarUrl), + ), + ), + ), + GestureDetector( + onTap: () { + onUserClick(); + }, + child: Container( + margin: const EdgeInsets.only(left: 7), + padding: const EdgeInsets.all(4.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(2), + border: Border.all( + width: 1.0, + color: const Color(0xFF140C10), + style: BorderStyle.solid), + ), + child: Text( + UserUtil.getUser()?.name ?? '未登录', + style: TextStyle( + color: const Color(0xFF333333), fontSize: 16.sp), + ), + ), + ), + 20.horizontalSpace, + const Expanded( + child: Text( + "WOW ENGLISH", + textAlign: TextAlign.left, + style: TextStyle(color: Colors.white, fontSize: 30.0), + )), + Row(children: [ + Image( + width: 20.0.w, + height: 20.0.h, + image: AssetImage('ic_countdown'.assetPng)), + // 替换为你的图片资源路径 + const SizedBox(width: 10.0), + // 图片和文本之间的间隔 + const Text('还剩29天'), + ]), + ScreenUtil().bottomBarHeight.horizontalSpace, + ], + )); + }, + ); + } +} + +void onUserClick() { + if (UserUtil.token.isEmpty) { + pushNamed(AppRouteName.login); + } else { + pushNamed(AppRouteName.user); + } +} diff --git a/lib/pages/shop/home/bloc/shop_home_bloc.dart b/lib/pages/shop/home/bloc/shop_home_bloc.dart index cac863c..6a97c42 100644 --- a/lib/pages/shop/home/bloc/shop_home_bloc.dart +++ b/lib/pages/shop/home/bloc/shop_home_bloc.dart @@ -1,14 +1,39 @@ import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; +import 'package:wow_english/common/request/dao/shop_dao.dart'; +import 'package:wow_english/models/product_entity.dart'; + +import '../../../../common/request/exception.dart'; +import '../../../../utils/loading.dart'; +import '../../../../utils/toast_util.dart'; part 'shop_home_event.dart'; part 'shop_home_state.dart'; class ShopHomeBloc extends Bloc { + + List _productDatas = []; + + List get productDatas => _productDatas; + ShopHomeBloc() : super(ShopHomeInitial()) { on((event, emit) { // TODO: implement event handler }); + on(_requestData); + } + + void _requestData(RequestDataEvent event, Emitter emitter) async { + try { + await loading(() async { + _productDatas = await ShopDao.productList() ?? []; + emitter(RequestListenDataState()); + }); + } catch (e) { + if (e is ApiException) { + showToast(e.message ?? '请求失败,请检查网络连接'); + } + } } } diff --git a/lib/pages/shop/home/bloc/shop_home_event.dart b/lib/pages/shop/home/bloc/shop_home_event.dart index f35f8fd..06185bb 100644 --- a/lib/pages/shop/home/bloc/shop_home_event.dart +++ b/lib/pages/shop/home/bloc/shop_home_event.dart @@ -2,3 +2,5 @@ part of 'shop_home_bloc.dart'; @immutable abstract class ShopHomeEvent {} + +class RequestDataEvent extends ShopHomeEvent {} diff --git a/lib/pages/shop/home/bloc/shop_home_state.dart b/lib/pages/shop/home/bloc/shop_home_state.dart index d0b3c17..09081e1 100644 --- a/lib/pages/shop/home/bloc/shop_home_state.dart +++ b/lib/pages/shop/home/bloc/shop_home_state.dart @@ -4,3 +4,5 @@ part of 'shop_home_bloc.dart'; abstract class ShopHomeState {} class ShopHomeInitial extends ShopHomeState {} + +class RequestListenDataState extends ShopHomeState {} \ 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..4c2789e 100644 --- a/lib/pages/shop/home/shop_home_page.dart +++ b/lib/pages/shop/home/shop_home_page.dart @@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/common/widgets/we_app_bar.dart'; -import 'package:wow_english/pages/shop/home/widgets/lesson_card_item.dart'; +import 'package:wow_english/pages/shop/home/widgets/product_item.dart'; import 'package:wow_english/route/route.dart'; import 'package:wow_english/utils/toast_util.dart'; @@ -15,7 +15,7 @@ class ShopHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => ShopHomeBloc(), + create: (context) => ShopHomeBloc()..add(RequestDataEvent()), child: _ShopHomeView(), ); } @@ -30,7 +30,9 @@ class _ShopHomeView extends StatelessWidget { ); } - Widget _shopHomeWidget() => BlocBuilder(builder: (context, state) { + Widget _shopHomeWidget() => + BlocBuilder(builder: (context, state) { + final bloc = BlocProvider.of(context); return Scaffold( appBar: WEAppBar( actions: [ @@ -62,7 +64,7 @@ class _ShopHomeView extends StatelessWidget { child: Padding( padding: EdgeInsets.symmetric(vertical: 25.h, horizontal: 25.w), child: GridView.builder( - itemCount: 4, + itemCount: bloc.productDatas.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 2, @@ -70,9 +72,10 @@ class _ShopHomeView extends StatelessWidget { crossAxisSpacing: 4.5.w, ), itemBuilder: (BuildContext context, int index) { - return LessonCardItem(onTap: () { - showToast('购买'); - }); + final productEntity = bloc.productDatas[index]; + return ProductItem(onTap: () { + pushNamed(AppRouteName.pay, arguments: productEntity); + }, entity: productEntity); }), ), ), diff --git a/lib/pages/shop/home/widgets/lesson_card_item.dart b/lib/pages/shop/home/widgets/product_item.dart index 8e42403..cab0371 100644 --- a/lib/pages/shop/home/widgets/lesson_card_item.dart +++ b/lib/pages/shop/home/widgets/product_item.dart @@ -1,8 +1,13 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:wow_english/models/product_entity.dart'; -class LessonCardItem extends StatelessWidget { - const LessonCardItem({super.key, required this.onTap}); +class ProductItem extends StatelessWidget { + const ProductItem({super.key, + required this.onTap, this.entity}); + + final ProductEntity? entity; final Function() onTap; @@ -11,7 +16,6 @@ class LessonCardItem extends StatelessWidget { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.r), - color: Colors.blue, border: Border.all( width: 1.0, color: Colors.black @@ -34,12 +38,29 @@ class LessonCardItem extends StatelessWidget { width: 1.0, color: const Color(0xFF333333), ), - image: const DecorationImage( - fit: BoxFit.fill, - image: NetworkImage('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Faa1c2213-820a-4223-8757-5f8cee318a28%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1688713226&t=192b18a613683bcdc5bd76f65c9ff032'), + image: DecorationImage( + image: NetworkImage(entity?.picUrl ?? ''), ) ), ), + // CachedNetworkImage( + // imageUrl: entity?.picUrl ?? '', + // fit: BoxFit.fill, + // imageBuilder: (context, imageProvider) => + // Container( + // decoration: BoxDecoration( + // border: Border.all( + // width: 1.0, + // color: const Color(0xFF333333), + // ), + // borderRadius: BorderRadius.circular(5.0), + // ), + // ), + // placeholder: (context, url) => const CircularProgressIndicator(), + // // errorWidget: (context, url, error) => const Icon(Icons.error), + // height: 124.h, + // width: 124.w, + // ), 21.5.horizontalSpace, Expanded( child: Column( @@ -47,7 +68,7 @@ class LessonCardItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - 'Wow English 课程年卡', + entity?.name ?? '', softWrap: true, textAlign: TextAlign.left, style: TextStyle( @@ -66,7 +87,7 @@ class LessonCardItem extends StatelessWidget { ) ), TextSpan( - text: '998', + text: entity?.price?.toString() ?? '', style: TextStyle( fontSize: 40.sp, color: const Color(0xFFF51A1A), diff --git a/lib/pages/shopping/bloc.dart b/lib/pages/shopping/bloc.dart new file mode 100644 index 0000000..c929830 --- /dev/null +++ b/lib/pages/shopping/bloc.dart @@ -0,0 +1,123 @@ +import 'package:bloc/bloc.dart'; +import 'package:fluwx/fluwx.dart'; +import 'package:tobias/tobias.dart'; +import 'package:wow_english/generated/json/base/json_convert_content.dart'; +import 'package:wow_english/models/product_entity.dart'; + +import '../../common/request/dao/shop_dao.dart'; +import '../../common/request/exception.dart'; +import '../../utils/loading.dart'; +import '../../utils/log_util.dart'; +import '../../utils/toast_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(this._productData) : super(ShoppingState().init()) { + //页面初始化时刻 + on(_init); + on(_changePaymentChannel); + on(_startPay); + } + + 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 _startPay(DoPayEvent event, + Emitter emitter) async { + Log.d("开始支付 ${event.productEntity} ${event.paymentChannel}"); + //如果event.productEntity为空,中断流程并toast提示 + if (event.productEntity == null) { + showToast("商品信息为空"); + return; + } + final productEntitySafely = event.productEntity!; + try { + await loading(() async { + final Map orderInfo = await ShopDao.createOrder(productEntitySafely); + Log.d("orderInfo $orderInfo"); + final String? orderNo = orderInfo.getOrNull("orderNo"); + if (orderNo == null) { + showToast("订单创建失败"); + return; + } + Log.d("orderNo $orderNo"); + + if (event.paymentChannel == PaymentChannel.wechatPay) { + Fluwx fluwx = Fluwx(); + fluwx.registerApi(appId: "wxd930ea5d5a228f5f", + universalLink: "https://app-api.wowenglish.com.cn/.well-known/apple-app-site-association"); + // fluwx.pay( + // which: Payment( + // appId: _orderInfo['appid'].toString(), + // partnerId: _orderInfo['partnerid'].toString(), + // prepayId: _orderInfo['prepayid'].toString(), + // packageValue: _orderInfo['package'].toString(), + // nonceStr: _orderInfo['noncestr'].toString(), + // timestamp: _orderInfo['timestamp'], + // sign: _orderInfo['sign'].toString(), + // )); + } else { + final Map aliPayOrderInfo = await ShopDao.getAliPayToken(orderNo); + Log.d("aliPayOrderInfo=$aliPayOrderInfo type=${aliPayOrderInfo.runtimeType}"); + final String? aliPayInfo = aliPayOrderInfo.getOrNull("token"); + if (aliPayInfo == null) { + showToast("支付宝订单创建失败"); + return; + } + Log.d("aliPayInfo=$aliPayInfo"); + ///打印aliPayOrderInfo的type + Tobias tobias = Tobias(); + final Map aliPayResult = await tobias.pay(aliPayInfo); + Log.d("aliPayResult=$aliPayResult"); + // 判断resultStatus 为9000则代表支付成功 + if (aliPayResult.getOrNull("resultStatus") == "9000") { + showToast("支付成功"); + emit(PaySuccessState()); + } else { + showToast("支付失败"); + } + } + }); + } catch (e) { + if (e is ApiException) { + showToast(e.message ?? '请求失败,请检查网络连接'); + } + } + } +} + +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..62b0db0 --- /dev/null +++ b/lib/pages/shopping/event.dart @@ -0,0 +1,22 @@ +import 'package:wow_english/models/product_entity.dart'; + +import 'bloc.dart'; + +abstract class ShoppingEvent {} + +class InitEvent extends ShoppingEvent {} + +class ChangePaymentChannelEvent extends ShoppingEvent { + final PaymentChannel paymentChannel; + + ChangePaymentChannelEvent(this.paymentChannel); +} + +class DoPayEvent extends ShoppingEvent { + + final ProductEntity? productEntity; + + final PaymentChannel paymentChannel; + + DoPayEvent(this.productEntity, 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..28f9de1 --- /dev/null +++ b/lib/pages/shopping/state.dart @@ -0,0 +1,13 @@ +class ShoppingState { + ShoppingState init() { + return ShoppingState(); + } + + ShoppingState clone() { + return ShoppingState(); + } +} + +class PaymentChannelChangeState extends ShoppingState {} + +class PaySuccessState 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..32cdcfe --- /dev/null +++ b/lib/pages/shopping/view.dart @@ -0,0 +1,180 @@ +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 'package:wow_english/models/product_entity.dart'; + +import '../../common/core/assets_const.dart'; +import '../../common/widgets/we_app_bar.dart'; +import '../../utils/image_util.dart'; +import '../../utils/log_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, this.productEntity}); + + final ProductEntity? productEntity; + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => + ShoppingBloc(productEntity) + ..add(InitEvent()), + child: _ShoppingView(), + ); + } +} + +class _ShoppingView extends StatelessWidget { + + @override + Widget build(BuildContext context) { + final bloc = BlocProvider.of(context); + // var title1 = bloc.productData?.name ?? ''; + return BlocListener( + listener: (context, state) { + Log.d("wqf state=$state"); + if (state is PaySuccessState) { + Navigator.pop(context); + } + }, + 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?.detailPicUrl ?? '', + 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 ?? ''}', + 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: () { + Log.d('点击支付按钮 ${bloc.productData}'); + bloc.add(DoPayEvent(bloc.productData, bloc.curPaymentChannel)); + }, + child: Image( + width: 125.w, + height: 45.h, + image: AssetImage('btn_pay'.assetPng), + ), + ), + ], + ); + }, + ); diff --git a/lib/pages/user/user_page.dart b/lib/pages/user/user_page.dart index ca83994..2a470ab 100644 --- a/lib/pages/user/user_page.dart +++ b/lib/pages/user/user_page.dart @@ -142,18 +142,18 @@ class _UserView extends StatelessWidget { ], ), 30.verticalSpace, - // todo xiaoyu delete 打开游戏界面 - OutlinedButton( + // 打开游戏界面 供审核用 + ((UserUtil.getUser()?.phoneNum == '17730280759' || UserUtil.getUser()?.phoneNum == '17718485544') ? OutlinedButton( onPressed: () { - methodChannel.invokeMethod('openGamePage', {}); + methodChannel.invokeMethod('openGamePage', { "gameId": 1 }); }, style: normalButtonStyle, child: Text( - "打开游戏界面", + "进入游戏", style: textStyle21sp, ), - ), - 12.verticalSpace, + ) : 1.verticalSpace), + ((UserUtil.getUser()?.phoneNum == '17730280759' || UserUtil.getUser()?.phoneNum == '17718485544') ? 12.verticalSpace : 1.verticalSpace), OutlinedButton( onPressed: () => pushNamed(AppRouteName.fogPwd), style: normalButtonStyle, diff --git a/lib/route/route.dart b/lib/route/route.dart index 375b738..e6b5a20 100644 --- a/lib/route/route.dart +++ b/lib/route/route.dart @@ -2,12 +2,15 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:wow_english/app/splash_page.dart'; import 'package:wow_english/common/pages/wow_web_page.dart'; +import 'package:wow_english/models/product_entity.dart'; +import 'package:wow_english/pages/games/view.dart'; import 'package:wow_english/pages/home/home_page.dart'; import 'package:wow_english/pages/lessons/lesson_page.dart'; import 'package:wow_english/pages/listen/listen_page.dart'; import 'package:wow_english/pages/login/forgetpwd/forget_password_home_page.dart'; import 'package:wow_english/pages/login/loginpage/login_page.dart'; import 'package:wow_english/pages/login/setpwd/set_pwd_page.dart'; +import 'package:wow_english/pages/moduleSelect/view.dart'; import 'package:wow_english/pages/practice/topic_picture_page.dart'; import 'package:wow_english/pages/repeatafter/repeat_after_page.dart'; import 'package:wow_english/pages/repeataftercontent/repeat_after_content_page.dart'; @@ -23,12 +26,16 @@ 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'; +import '../utils/log_util.dart'; class AppRouteName { static const String splash = 'splash'; static const String login = 'login'; + static const String moduleSelect = 'moduleSelect'; + static const String games = 'games'; static const String home = 'home'; static const String fogPwd = 'fogPwd'; @@ -43,6 +50,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'; @@ -84,6 +92,10 @@ class AppRouter { transitionsBuilder: (_, __, ___, child) => child); case AppRouteName.login: return CupertinoPageRoute(builder: (_) => const LoginPage()); + case AppRouteName.moduleSelect: + return CupertinoPageRoute(builder: (_) => const ModuleSelectPage()); + case AppRouteName.games: + return CupertinoPageRoute(builder: (_) => const GamesPage()); case AppRouteName.home: var moduleId = ''; if (settings.arguments != null) { @@ -101,6 +113,12 @@ class AppRouter { return CupertinoPageRoute(builder: (_) => const ListenPage()); case AppRouteName.shop: return CupertinoPageRoute(builder: (_) => const ShopHomePage()); + case AppRouteName.pay: + var productEntity = ProductEntity(); + if (settings.arguments != null && settings.arguments is ProductEntity) { + productEntity = settings.arguments as ProductEntity; + } + return CupertinoPageRoute(builder: (_) => ShoppingPage(productEntity: productEntity)); case AppRouteName.exLesson: return CupertinoPageRoute(builder: (_) => const ExchangeLessonPage()); case AppRouteName.exList: diff --git a/pubspec.yaml b/pubspec.yaml index 9dc0754..0fb08c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.2+1 +version: 1.0.3+2 environment: sdk: '>=3.0.0 <4.0.0' @@ -66,15 +66,17 @@ 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.3.2 # 微信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 decimal: ^2.3.2 # 网络图片缓存 https://pub.flutter-io.cn/packages/cached_network_image - cached_network_image: ^3.2.3 + cached_network_image: ^3.3.1 +# # 网络图片缓存 https://pub.dev/packages/extended_image +# extended_image: ^4.0.0 # 常用工具类(时间轴,倒计时等) https://pub.flutter-io.cn/packages/common_utils common_utils: ^2.1.0 # 获取设备信息 https://pub.flutter-io.cn/packages/device_info_plus @@ -135,3 +137,8 @@ flutter: - family: HannotateSC fonts: - asset: assets/fonts/HannotateSC-W5.ttf + +tobias: + url_scheme: ishowwoweng + ios: + ignore_security: true