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 5de5f855
authored
2025-12-25 11:21:12 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ios手势测试
1 parent
5c38bf5a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
32 deletions
lib/bloc/link_cubit.dart
lib/bloc/web_cubit.dart
lib/main.dart
lib/ui/pages/link_page.dart
lib/ui/pages/web_page.dart
lib/bloc/link_cubit.dart
View file @
5de5f85
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
(
...
...
lib/bloc/web_cubit.dart
View file @
5de5f85
...
...
@@ -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
((
_
)
{
...
...
lib/main.dart
View file @
5de5f85
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()}
"
);
});
}
}
lib/ui/pages/link_page.dart
View file @
5de5f85
...
...
@@ -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
);
},
...
...
lib/ui/pages/web_page.dart
View file @
5de5f85
...
...
@@ -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
();
},
...
...
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