diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index b02b223..6cf4ac9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + B852C1352BCABB5E00A53FC4 /* GameMessageChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */; }; F5FCE34FB9E028C20A7850DE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A3DBEAB6142776646A34D9C /* Pods_RunnerTests.framework */; }; FB8AFCB0A8C34B5508A68F45 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DEBBC1D861BE053F3ECE0B9 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ @@ -67,6 +68,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameMessageChannel.swift; sourceTree = ""; }; D63F3847140160A2204489BA /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; D8C046A1A9C279FDBB5C174E /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; F04D1DAE6591EAD461CBBE9A /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; @@ -158,6 +160,7 @@ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 52450AF02A4C415B007B3E4B /* XSMessageMehtodChannel.swift */, 525E17192A4BD03900104CDF /* VoiceXSMessageChannel.swift */, + B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */, 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, ); path = Runner; @@ -405,6 +408,7 @@ 52450AF12A4C415B007B3E4B /* XSMessageMehtodChannel.swift in Sources */, 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + B852C1352BCABB5E00A53FC4 /* GameMessageChannel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index d8f2483..8918ed4 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -11,6 +11,7 @@ import Flutter let controller : FlutterViewController = window?.rootViewController as! FlutterViewController _ = VoiceXSMessageChannel(messager: controller.binaryMessenger) _ = XSMessageMehtodChannel(message: controller.binaryMessenger); + _ = GameMessageChannel(message: controller.binaryMessenger); return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } diff --git a/ios/Runner/GameMessageChannel.swift b/ios/Runner/GameMessageChannel.swift new file mode 100644 index 0000000..9577417 --- /dev/null +++ b/ios/Runner/GameMessageChannel.swift @@ -0,0 +1,28 @@ +// +// GameMessageChannel.swift +// Runner +// +// Created by xiaoyu on 2024/4/13. +// +import UIKit + +class GameMessageChannel: NSObject { + var messageChannel:FlutterMethodChannel? + init(message:FlutterBinaryMessenger) { + super.init() + + messageChannel = FlutterMethodChannel.init(name: "wow_english/game_method_channel", binaryMessenger: message) + messageChannel!.setMethodCallHandler { call, result in + self.handle(call, result) + } + } + + func handle(_ call: FlutterMethodCall,_ result: @escaping FlutterResult) { + if (call.method == "openGamePage") { + print("openGamePage") + return + } + + } + +} diff --git a/lib/pages/user/user_page.dart b/lib/pages/user/user_page.dart index 69b6533..ca83994 100644 --- a/lib/pages/user/user_page.dart +++ b/lib/pages/user/user_page.dart @@ -1,3 +1,6 @@ +import 'dart:io'; +import 'dart:async'; +import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -23,6 +26,9 @@ class UserPage extends StatelessWidget { class _UserView extends StatelessWidget { final String bannerUrl = ''; + /// 方法 + final MethodChannel methodChannel = const MethodChannel('wow_english/game_method_channel'); + @override Widget build(BuildContext context) { return _pageWidget(); @@ -136,6 +142,18 @@ class _UserView extends StatelessWidget { ], ), 30.verticalSpace, + // todo xiaoyu delete 打开游戏界面 + OutlinedButton( + onPressed: () { + methodChannel.invokeMethod('openGamePage', {}); + }, + style: normalButtonStyle, + child: Text( + "打开游戏界面", + style: textStyle21sp, + ), + ), + 12.verticalSpace, OutlinedButton( onPressed: () => pushNamed(AppRouteName.fogPwd), style: normalButtonStyle,