Commit 8b5ef002154f65590765bc3c918fc54acc25d2c9

Authored by xiaoyu
1 parent 3f5799f3

添加打开游戏的测试代码

ios/Runner.xcodeproj/project.pbxproj
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 16 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
17 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 17 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
18 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 18 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
  19 + B852C1352BCABB5E00A53FC4 /* GameMessageChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */; };
19 F5FCE34FB9E028C20A7850DE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A3DBEAB6142776646A34D9C /* Pods_RunnerTests.framework */; }; 20 F5FCE34FB9E028C20A7850DE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A3DBEAB6142776646A34D9C /* Pods_RunnerTests.framework */; };
20 FB8AFCB0A8C34B5508A68F45 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DEBBC1D861BE053F3ECE0B9 /* Pods_Runner.framework */; }; 21 FB8AFCB0A8C34B5508A68F45 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DEBBC1D861BE053F3ECE0B9 /* Pods_Runner.framework */; };
21 /* End PBXBuildFile section */ 22 /* End PBXBuildFile section */
@@ -67,6 +68,7 @@ @@ -67,6 +68,7 @@
67 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 68 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
68 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 69 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
69 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 70 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  71 + B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameMessageChannel.swift; sourceTree = "<group>"; };
70 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 = "<group>"; }; 72 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 = "<group>"; };
71 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 = "<group>"; }; 73 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 = "<group>"; };
72 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 = "<group>"; }; 74 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 = "<group>"; };
@@ -158,6 +160,7 @@ @@ -158,6 +160,7 @@
158 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 160 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
159 52450AF02A4C415B007B3E4B /* XSMessageMehtodChannel.swift */, 161 52450AF02A4C415B007B3E4B /* XSMessageMehtodChannel.swift */,
160 525E17192A4BD03900104CDF /* VoiceXSMessageChannel.swift */, 162 525E17192A4BD03900104CDF /* VoiceXSMessageChannel.swift */,
  163 + B852C1342BCABB5E00A53FC4 /* GameMessageChannel.swift */,
161 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 164 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
162 ); 165 );
163 path = Runner; 166 path = Runner;
@@ -405,6 +408,7 @@ @@ -405,6 +408,7 @@
405 52450AF12A4C415B007B3E4B /* XSMessageMehtodChannel.swift in Sources */, 408 52450AF12A4C415B007B3E4B /* XSMessageMehtodChannel.swift in Sources */,
406 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 409 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
407 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 410 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
  411 + B852C1352BCABB5E00A53FC4 /* GameMessageChannel.swift in Sources */,
408 ); 412 );
409 runOnlyForDeploymentPostprocessing = 0; 413 runOnlyForDeploymentPostprocessing = 0;
410 }; 414 };
ios/Runner/AppDelegate.swift
@@ -11,6 +11,7 @@ import Flutter @@ -11,6 +11,7 @@ import Flutter
11 let controller : FlutterViewController = window?.rootViewController as! FlutterViewController 11 let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
12 _ = VoiceXSMessageChannel(messager: controller.binaryMessenger) 12 _ = VoiceXSMessageChannel(messager: controller.binaryMessenger)
13 _ = XSMessageMehtodChannel(message: controller.binaryMessenger); 13 _ = XSMessageMehtodChannel(message: controller.binaryMessenger);
  14 + _ = GameMessageChannel(message: controller.binaryMessenger);
14 return super.application(application, didFinishLaunchingWithOptions: launchOptions) 15 return super.application(application, didFinishLaunchingWithOptions: launchOptions)
15 } 16 }
16 } 17 }
ios/Runner/GameMessageChannel.swift 0 → 100644
  1 +//
  2 +// GameMessageChannel.swift
  3 +// Runner
  4 +//
  5 +// Created by xiaoyu on 2024/4/13.
  6 +//
  7 +import UIKit
  8 +
  9 +class GameMessageChannel: NSObject {
  10 + var messageChannel:FlutterMethodChannel?
  11 + init(message:FlutterBinaryMessenger) {
  12 + super.init()
  13 +
  14 + messageChannel = FlutterMethodChannel.init(name: "wow_english/game_method_channel", binaryMessenger: message)
  15 + messageChannel!.setMethodCallHandler { call, result in
  16 + self.handle(call, result)
  17 + }
  18 + }
  19 +
  20 + func handle(_ call: FlutterMethodCall,_ result: @escaping FlutterResult) {
  21 + if (call.method == "openGamePage") {
  22 + print("openGamePage")
  23 + return
  24 + }
  25 +
  26 + }
  27 +
  28 +}
lib/pages/user/user_page.dart
  1 +import 'dart:io';
  2 +import 'dart:async';
  3 +import 'package:flutter/services.dart';
1 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
2 import 'package:flutter_bloc/flutter_bloc.dart'; 5 import 'package:flutter_bloc/flutter_bloc.dart';
3 import 'package:flutter_screenutil/flutter_screenutil.dart'; 6 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -23,6 +26,9 @@ class UserPage extends StatelessWidget { @@ -23,6 +26,9 @@ class UserPage extends StatelessWidget {
23 class _UserView extends StatelessWidget { 26 class _UserView extends StatelessWidget {
24 final String bannerUrl = ''; 27 final String bannerUrl = '';
25 28
  29 + /// 方法
  30 + final MethodChannel methodChannel = const MethodChannel('wow_english/game_method_channel');
  31 +
26 @override 32 @override
27 Widget build(BuildContext context) { 33 Widget build(BuildContext context) {
28 return _pageWidget(); 34 return _pageWidget();
@@ -136,6 +142,18 @@ class _UserView extends StatelessWidget { @@ -136,6 +142,18 @@ class _UserView extends StatelessWidget {
136 ], 142 ],
137 ), 143 ),
138 30.verticalSpace, 144 30.verticalSpace,
  145 + // todo xiaoyu delete 打开游戏界面
  146 + OutlinedButton(
  147 + onPressed: () {
  148 + methodChannel.invokeMethod('openGamePage', {});
  149 + },
  150 + style: normalButtonStyle,
  151 + child: Text(
  152 + "打开游戏界面",
  153 + style: textStyle21sp,
  154 + ),
  155 + ),
  156 + 12.verticalSpace,
139 OutlinedButton( 157 OutlinedButton(
140 onPressed: () => pushNamed(AppRouteName.fogPwd), 158 onPressed: () => pushNamed(AppRouteName.fogPwd),
141 style: normalButtonStyle, 159 style: normalButtonStyle,