Commit 5de5f855 by tanghuan

ios手势测试

1 parent 5c38bf5a
import 'dart:io';
import 'package:appframe/config/routes.dart';
import 'package:appframe/ui/widgets/ios_edge_swipe_detector.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -28,17 +27,6 @@ class LinkCubit extends Cubit<LinkState> {
WebViewController get controller => _controller;
LinkCubit(super.initialState) {
// 初始化 iOS 边缘滑动监听
if (Platform.isIOS) {
IosEdgeSwipeDetector.init();
IosEdgeSwipeDetector.onEdgeSwipe(() {
debugPrint("");
debugPrint("link page 检测到左边缘滑动,Flutter 收到通知");
debugPrint("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
debugPrint("");
});
}
_controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
......
......@@ -12,7 +12,6 @@ import 'package:appframe/services/im_service.dart';
import 'package:appframe/services/local_server_service.dart';
import 'package:appframe/services/player_service.dart';
import 'package:appframe/services/recorder_service.dart';
import 'package:appframe/ui/widgets/ios_edge_swipe_detector.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
......@@ -212,17 +211,6 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
// 添加生命周期观察者
WidgetsBinding.instance.addObserver(this);
// 初始化 iOS 边缘滑动监听
if (Platform.isIOS) {
IosEdgeSwipeDetector.init();
IosEdgeSwipeDetector.onEdgeSwipe(() {
debugPrint("");
debugPrint("web page 检测到左边缘滑动,Flutter 收到通知");
debugPrint("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
debugPrint("");
});
}
// 没有登录数据,跳转到登录页面
if (state.sessionCode == null || state.sessionCode == '') {
WidgetsBinding.instance.addPostFrameCallback((_) {
......
import 'dart:convert';
import 'dart:io';
import 'package:appframe/config/constant.dart';
import 'package:appframe/config/env_config.dart';
import 'package:appframe/config/locator.dart';
import 'package:appframe/services/im_service.dart';
import 'package:appframe/ui/widgets/ios_edge_swipe_detector.dart';
import 'package:archive/archive.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
......@@ -17,6 +19,7 @@ void main() async {
await setupLocator();
await _initH5Version();
await _initImSdk();
await _initIosEdgeSwipe();
runApp(const App());
}
......@@ -60,3 +63,14 @@ Future<void> _initImSdk() async {
await getIt.get<ImService>().initSdk();
}
}
/// 初始化 iOS 边缘滑动监听
/// 应用级别初始化,所有页面共享同一个监听器
Future<void> _initIosEdgeSwipe() async {
if (Platform.isIOS) {
await IosEdgeSwipeDetector.init();
IosEdgeSwipeDetector.onEdgeSwipe(() {
debugPrint("iOS 边缘滑动被触发 ---------------------- ${DateTime.now()}");
});
}
}
......@@ -36,16 +36,16 @@ class LinkPage extends StatelessWidget {
: const Center(child: CircularProgressIndicator(color: Color(0xFF7691fa))),
);
if (Platform.isIOS) {
return scaffold;
}
// if (Platform.isIOS) {
// return scaffold;
// }
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, result) async {
// if (didPop) return;
debugPrint("");
debugPrint("^^^^^^^^^^^^^^ Link page PopScope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
debugPrint("^^^^^^^^^^^^^^ Link page PopScope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ${DateTime.now().toString()}");
debugPrint("");
await ctx.read<LinkCubit>().handleBack(ctx);
},
......
......@@ -102,16 +102,16 @@ class WebPage extends StatelessWidget {
: const SizedBox.shrink(),
);
if(Platform.isIOS) {
return scaffold;
}
// if(Platform.isIOS) {
// return scaffold;
// }
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, result) async {
//if (didPop) return;
debugPrint("");
debugPrint("^^^^^^^^^^^^^^ Web page PopScope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
debugPrint("^^^^^^^^^^^^^^ Web page PopScope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ${DateTime.now().toString()} ");
debugPrint("");
await ctx.read<WebCubit>().handleBack();
},
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!