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 fc562c9a
authored
2025-12-26 11:04:44 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ios手势测试
1 parent
f88ffc93
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
26 deletions
lib/bloc/web_cubit.dart
lib/config/routes.dart
lib/ui/pages/link_page.dart
lib/ui/pages/web_page.dart
lib/bloc/web_cubit.dart
View file @
fc562c9
...
...
@@ -198,7 +198,7 @@ class WebState extends Equatable {
];
}
class
WebCubit
extends
Cubit
<
WebState
>
with
WidgetsBindingObserver
,
RouteAware
{
class
WebCubit
extends
Cubit
<
WebState
>
with
WidgetsBindingObserver
{
late
final
MessageDispatcher
_dispatcher
;
late
final
WebViewController
_controller
;
late
final
Fluwx
_fluwx
;
...
...
@@ -284,8 +284,10 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver, RouteAware {
// 登录IM
_loginIM
();
await
IosEdgeSwipeDetector
.
init
();
IosEdgeSwipeDetector
.
onEdgeSwipe
(
handleBack
);
if
(
Platform
.
isIOS
)
{
await
IosEdgeSwipeDetector
.
init
();
IosEdgeSwipeDetector
.
onEdgeSwipe
(
handleBack
);
}
}
Future
<
Map
<
String
,
String
>>
_getVersionConfig
()
async
{
...
...
@@ -1224,18 +1226,6 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver, RouteAware {
}
@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);
...
...
@@ -1245,6 +1235,7 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver, RouteAware {
if
(
Platform
.
isIOS
)
{
IosEdgeSwipeDetector
.
dispose
();
WebCubitHolder
.
unregister
();
}
// 移除观察者
...
...
@@ -1252,4 +1243,8 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver, RouteAware {
return
super
.
close
();
}
void
test
(){
debugPrint
(
'test==================================='
);
}
}
lib/config/routes.dart
View file @
fc562c9
import
'dart:io'
;
import
'package:appframe/bloc/web_cubit.dart'
;
import
'package:appframe/ui/pages/adv_page.dart'
;
import
'package:appframe/ui/pages/im_page.dart'
;
import
'package:appframe/ui/pages/link_page.dart'
;
...
...
@@ -6,12 +9,16 @@ import 'package:appframe/ui/pages/login_phone_page.dart';
import
'package:appframe/ui/pages/login_qr_page.dart'
;
import
'package:appframe/ui/pages/reload_page.dart'
;
import
'package:appframe/ui/pages/scan_code_page.dart'
;
import
'package:appframe/ui/pages/setting/account_page.dart'
;
import
'package:appframe/ui/pages/setting/account_phone_page.dart'
;
import
'package:appframe/ui/pages/web_page.dart'
;
import
'package:appframe/ui/widgets/ios_edge_swipe_detector.dart'
;
import
'package:flutter/material.dart'
;
import
'package:go_router/go_router.dart'
;
final
GoRouter
router
=
GoRouter
(
initialLocation:
'/web'
,
observers:
Platform
.
isIOS
?
[
AppRouteObserver
()]
:
[],
routes:
<
RouteBase
>[
GoRoute
(
path:
'/web'
,
...
...
@@ -50,6 +57,18 @@ final GoRouter router = GoRouter(
},
),
GoRoute
(
path:
'/account'
,
builder:
(
BuildContext
context
,
GoRouterState
state
)
{
return
const
AccountPage
();
},
),
GoRoute
(
path:
'/account/phone'
,
builder:
(
BuildContext
context
,
GoRouterState
state
)
{
return
const
AccountPhonePage
();
},
),
GoRoute
(
path:
'/adv'
,
builder:
(
BuildContext
context
,
GoRouterState
state
)
{
return
const
AdvPage
();
...
...
@@ -69,3 +88,57 @@ final GoRouter router = GoRouter(
),
],
);
///
/// 只针对iOS使用
///
class
AppRouteObserver
extends
NavigatorObserver
{
@override
void
didPush
(
Route
route
,
Route
?
previousRoute
)
{
super
.
didPush
(
route
,
previousRoute
);
debugPrint
(
"前一个路由:
${previousRoute?.settings.name}
新路由:
${route.settings.name}
"
);
debugPrint
(
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
);
if
(
previousRoute
?.
settings
.
name
==
'/web'
)
{
// 前一个路由是web,代表是从web路由中push到此路由
// 清空手势监听回调
debugPrint
(
"取消监听--------"
);
IosEdgeSwipeDetector
.
dispose
();
}
}
@override
void
didPop
(
Route
route
,
Route
?
previousRoute
)
{
super
.
didPop
(
route
,
previousRoute
);
debugPrint
(
"前一个路由:
${previousRoute?.settings.name}
新路由:
${route.settings.name}
"
);
debugPrint
(
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
);
if
(
previousRoute
?.
settings
.
name
==
'/web'
)
{
// 前一个路由是web,代表会到web
WebCubitHolder
.
instance
?.
test
();
if
(
WebCubitHolder
.
instance
!=
null
)
{
// 设置手势监听回调
debugPrint
(
"设置监听--------"
);
IosEdgeSwipeDetector
.
onEdgeSwipe
(
WebCubitHolder
.
instance
!.
handleBack
);
}
}
}
}
///
/// 只针对iOS使用
///
class
WebCubitHolder
{
static
WebCubit
?
instance
;
static
void
register
(
WebCubit
cubit
)
{
instance
=
cubit
;
}
static
void
unregister
()
{
instance
=
null
;
}
}
lib/ui/pages/link_page.dart
View file @
fc562c9
...
...
@@ -43,7 +43,7 @@ class LinkPage extends StatelessWidget {
return
PopScope
(
canPop:
false
,
onPopInvokedWithResult:
(
didPop
,
result
)
async
{
//
if (didPop) return;
if
(
didPop
)
return
;
debugPrint
(
""
);
debugPrint
(
"^^^^^^^^^^^^^^ Link page PopScope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
${DateTime.now().toString()}
"
);
debugPrint
(
""
);
...
...
lib/ui/pages/web_page.dart
View file @
fc562c9
...
...
@@ -39,16 +39,22 @@ class WebPage extends StatelessWidget {
}
return
BlocProvider
(
create:
(
context
)
=>
WebCubit
(
WebState
(
loginOpFlag:
loginOpFlag
,
sessionCode:
sessionCode
,
userCode:
userCode
,
classCode:
classCode
,
userType:
userType
,
stuId:
stuId
,
),
),
create:
(
context
)
{
final
cubit
=
WebCubit
(
WebState
(
loginOpFlag:
loginOpFlag
,
sessionCode:
sessionCode
,
userCode:
userCode
,
classCode:
classCode
,
userType:
userType
,
stuId:
stuId
,
),
);
if
(
Platform
.
isIOS
)
{
WebCubitHolder
.
register
(
cubit
);
}
return
cubit
;
},
child:
BlocConsumer
<
WebCubit
,
WebState
>(
builder:
(
ctx
,
state
)
{
final
scaffold
=
Scaffold
(
...
...
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