Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 6ef6cce1
authored
2025-12-25 16:17:17 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
iso手势测试
1 parent
4ab8f4b2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
15 deletions
lib/bloc/web_cubit.dart
lib/main.dart
lib/ui/widgets/ios_edge_swipe_detector.dart
lib/bloc/web_cubit.dart
View file @
6ef6cce
...
...
@@ -12,6 +12,7 @@ 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'
;
...
...
@@ -197,7 +198,7 @@ class WebState extends Equatable {
];
}
class
WebCubit
extends
Cubit
<
WebState
>
with
WidgetsBindingObserver
{
class
WebCubit
extends
Cubit
<
WebState
>
with
WidgetsBindingObserver
,
RouteAware
{
late
final
MessageDispatcher
_dispatcher
;
late
final
WebViewController
_controller
;
late
final
Fluwx
_fluwx
;
...
...
@@ -282,6 +283,9 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
// 登录IM
_loginIM
();
await
IosEdgeSwipeDetector
.
init
();
IosEdgeSwipeDetector
.
onEdgeSwipe
(
handleBack
);
}
Future
<
Map
<
String
,
String
>>
_getVersionConfig
()
async
{
...
...
@@ -1220,6 +1224,18 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
}
@override
void
didPush
()
{
debugPrint
(
'didPush------------------
${DateTime.now().toString()}
'
);
IosEdgeSwipeDetector
.
dispose
();
}
@override
void
didPop
()
{
debugPrint
(
'didPop------------------
${DateTime.now().toString()}
'
);
IosEdgeSwipeDetector
.
onEdgeSwipe
(
handleBack
);
}
@override
Future
<
void
>
close
()
async
{
_server
?.
close
();
// _fluwx.removeSubscriber(_responseListener);
...
...
@@ -1227,6 +1243,10 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
await
_playerService
?.
close
();
await
_recorderService
?.
close
();
if
(
Platform
.
isIOS
)
{
IosEdgeSwipeDetector
.
dispose
();
}
// 移除观察者
WidgetsBinding
.
instance
.
removeObserver
(
this
);
...
...
lib/main.dart
View file @
6ef6cce
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'
;
...
...
@@ -19,7 +17,6 @@ void main() async {
await
setupLocator
();
await
_initH5Version
();
await
_initImSdk
();
await
_initIosEdgeSwipe
();
runApp
(
const
App
());
}
...
...
@@ -63,14 +60,3 @@ 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()}
"
);
});
}
}
lib/ui/widgets/ios_edge_swipe_detector.dart
View file @
6ef6cce
...
...
@@ -26,4 +26,10 @@ class IosEdgeSwipeDetector {
}
});
}
/// 清理边缘滑动监听器
/// 在组件销毁时调用,防止内存泄漏
static
void
dispose
()
{
_channel
.
setMethodCallHandler
(
null
);
}
}
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment