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 62e5f10a
authored
2025-12-24 18:44:20 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ios手势测试
1 parent
4903540f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
8 deletions
lib/ui/pages/link_page.dart
lib/ui/widgets/ios_edge_swipe_detector.dart
lib/ui/pages/link_page.dart
View file @
62e5f10
import
'dart:io'
;
import
'package:appframe/bloc/link_cubit.dart'
;
import
'package:appframe/ui/widgets/ios_edge_swipe_detector.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:go_router/go_router.dart'
;
...
...
@@ -13,6 +16,20 @@ class LinkPage extends StatelessWidget {
final
String
?
url
=
extraData
?[
'url'
];
final
String
?
title
=
extraData
?[
'title'
];
if
(
Platform
.
isIOS
)
{
// 初始化 iOS 边缘滑动监听
IosEdgeSwipeDetector
.
init
();
// 设置滑动回调
IosEdgeSwipeDetector
.
onEdgeSwipe
(()
{
debugPrint
(
""
);
debugPrint
(
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
);
debugPrint
(
"检测到左边缘滑动,Flutter 收到通知"
);
debugPrint
(
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
);
debugPrint
(
""
);
});
}
return
BlocProvider
(
create:
(
context
)
=>
LinkCubit
(
LinkState
(
loaded:
false
,
url:
url
!)),
child:
BlocConsumer
<
LinkCubit
,
LinkState
>(
...
...
@@ -35,14 +52,16 @@ class LinkPage extends StatelessWidget {
);
// 为所有平台添加PopScope支持
return
PopScope
(
canPop:
false
,
onPopInvokedWithResult:
(
didPop
,
result
)
async
{
// if (didPop) return;
await
ctx
.
read
<
LinkCubit
>().
handleBack
(
ctx
);
},
child:
scaffold
,
);
// return PopScope(
// canPop: false,
// onPopInvokedWithResult: (didPop, result) async {
// // if (didPop) return;
// await ctx.read<LinkCubit>().handleBack(ctx);
// },
// child: scaffold,
// );
return
scaffold
;
},
listener:
(
context
,
state
)
{},
),
...
...
lib/ui/widgets/ios_edge_swipe_detector.dart
0 → 100644
View file @
62e5f10
import
'package:flutter/services.dart'
;
class
IosEdgeSwipeDetector
{
static
const
MethodChannel
_channel
=
MethodChannel
(
'ios_edge_swipe'
);
/// 初始化监听器(调用 iOS 注册边缘滑动监听)
static
Future
<
void
>
init
()
async
{
try
{
await
_channel
.
invokeMethod
(
'initSwipeListener'
);
}
catch
(
_
)
{}
}
/// 注册 Flutter 层监听器
static
void
onEdgeSwipe
(
VoidCallback
onSwipeDetected
)
{
_channel
.
setMethodCallHandler
((
call
)
async
{
if
(
call
.
method
==
'onEdgeSwipe'
)
{
onSwipeDetected
();
}
});
}
}
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