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 7918cd84
authored
2026-04-29 15:48:03 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
getDeviceInfo, openLink, setTitlebar
1 parent
54b39c5d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
7 deletions
lib/bloc/web_cubit.dart
lib/data/repositories/message/device_info_handler.dart
lib/data/repositories/message/open_link_handler.dart
lib/data/repositories/message/title_bar_handler.dart
lib/ui/pages/web_page.dart
lib/bloc/web_cubit.dart
View file @
7918cd8
...
@@ -39,6 +39,7 @@ class WebState extends Equatable {
...
@@ -39,6 +39,7 @@ class WebState extends Equatable {
final
int
titleColor
;
final
int
titleColor
;
final
int
bgColor
;
final
int
bgColor
;
final
String
opIcon
;
final
String
opIcon
;
final
bool
showAppBar
;
final
bool
showBottomNavBar
;
final
bool
showBottomNavBar
;
// 是否通过登录操作进入
// 是否通过登录操作进入
...
@@ -79,6 +80,7 @@ class WebState extends Equatable {
...
@@ -79,6 +80,7 @@ class WebState extends Equatable {
this
.
titleColor
=
0xFFFFFFFF
,
this
.
titleColor
=
0xFFFFFFFF
,
this
.
bgColor
=
0xFF7691FA
,
this
.
bgColor
=
0xFF7691FA
,
this
.
opIcon
=
'none'
,
this
.
opIcon
=
'none'
,
this
.
showAppBar
=
true
,
this
.
showBottomNavBar
=
false
,
this
.
showBottomNavBar
=
false
,
this
.
loginOpFlag
=
false
,
this
.
loginOpFlag
=
false
,
this
.
sessionCode
,
this
.
sessionCode
,
...
@@ -106,7 +108,7 @@ class WebState extends Equatable {
...
@@ -106,7 +108,7 @@ class WebState extends Equatable {
int
?
titleColor
,
int
?
titleColor
,
int
?
bgColor
,
int
?
bgColor
,
String
?
opIcon
,
String
?
opIcon
,
bool
?
show
Nav
Bar
,
bool
?
show
App
Bar
,
bool
?
showBottomNavBar
,
bool
?
showBottomNavBar
,
bool
?
loginOpFlag
,
bool
?
loginOpFlag
,
String
?
sessionCode
,
String
?
sessionCode
,
...
@@ -133,6 +135,7 @@ class WebState extends Equatable {
...
@@ -133,6 +135,7 @@ class WebState extends Equatable {
titleColor:
titleColor
??
this
.
titleColor
,
titleColor:
titleColor
??
this
.
titleColor
,
bgColor:
bgColor
??
this
.
bgColor
,
bgColor:
bgColor
??
this
.
bgColor
,
opIcon:
opIcon
??
this
.
opIcon
,
opIcon:
opIcon
??
this
.
opIcon
,
showAppBar:
showAppBar
??
this
.
showAppBar
,
showBottomNavBar:
showBottomNavBar
??
this
.
showBottomNavBar
,
showBottomNavBar:
showBottomNavBar
??
this
.
showBottomNavBar
,
loginOpFlag:
loginOpFlag
??
this
.
loginOpFlag
,
loginOpFlag:
loginOpFlag
??
this
.
loginOpFlag
,
sessionCode:
sessionCode
??
this
.
sessionCode
,
sessionCode:
sessionCode
??
this
.
sessionCode
,
...
@@ -162,6 +165,7 @@ class WebState extends Equatable {
...
@@ -162,6 +165,7 @@ class WebState extends Equatable {
titleColor
,
titleColor
,
bgColor
,
bgColor
,
opIcon
,
opIcon
,
showAppBar
,
showBottomNavBar
,
showBottomNavBar
,
sessionCode
,
sessionCode
,
userCode
,
userCode
,
...
@@ -561,11 +565,11 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
...
@@ -561,11 +565,11 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
_sendResponse
(
resp
);
_sendResponse
(
resp
);
}
}
bool
setTitleBar
(
String
title
,
String
color
,
String
bgColor
,
String
icon
)
{
bool
setTitleBar
(
bool
hidden
,
String
title
,
String
color
,
String
bgColor
,
String
icon
)
{
int
parsedTitleColor
=
_hexStringToInt
(
color
);
int
parsedTitleColor
=
_hexStringToInt
(
color
);
int
parsedBgColor
=
_hexStringToInt
(
bgColor
);
int
parsedBgColor
=
_hexStringToInt
(
bgColor
);
emit
(
state
.
copyWith
(
title:
title
,
titleColor:
parsedTitleColor
,
bgColor:
parsedBgColor
,
opIcon:
icon
));
emit
(
state
.
copyWith
(
showAppBar:
!
hidden
,
title:
title
,
titleColor:
parsedTitleColor
,
bgColor:
parsedBgColor
,
opIcon:
icon
));
return
true
;
return
true
;
}
}
...
...
lib/data/repositories/message/device_info_handler.dart
View file @
7918cd8
...
@@ -3,6 +3,7 @@ import 'dart:ui';
...
@@ -3,6 +3,7 @@ import 'dart:ui';
import
'package:appframe/services/dispatcher.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:device_info_plus/device_info_plus.dart'
;
import
'package:device_info_plus/device_info_plus.dart'
;
import
'package:flutter/material.dart'
;
class
DeviceInfoHandler
extends
MessageHandler
{
class
DeviceInfoHandler
extends
MessageHandler
{
@override
@override
...
@@ -24,7 +25,8 @@ class DeviceInfoHandler extends MessageHandler {
...
@@ -24,7 +25,8 @@ class DeviceInfoHandler extends MessageHandler {
'platform'
:
'Android'
,
'platform'
:
'Android'
,
'cpuType'
:
androidInfo
.
hardware
,
'cpuType'
:
androidInfo
.
hardware
,
'memorySize'
:
_getAndroidMemorySize
(
androidInfo
),
'memorySize'
:
_getAndroidMemorySize
(
androidInfo
),
'statusBarHeight'
:
statusBarHeight
,
'statusbarHeight'
:
statusBarHeight
,
'titlebarHeight'
:
kToolbarHeight
,
};
};
}
else
if
(
Platform
.
isIOS
)
{
}
else
if
(
Platform
.
isIOS
)
{
IosDeviceInfo
iosInfo
=
await
deviceInfoPlugin
.
iosInfo
;
IosDeviceInfo
iosInfo
=
await
deviceInfoPlugin
.
iosInfo
;
...
@@ -38,7 +40,8 @@ class DeviceInfoHandler extends MessageHandler {
...
@@ -38,7 +40,8 @@ class DeviceInfoHandler extends MessageHandler {
'platform'
:
'iOS'
,
'platform'
:
'iOS'
,
'cpuType'
:
''
,
'cpuType'
:
''
,
'memorySize'
:
(
iosInfo
.
physicalRamSize
~/
(
1024
*
1024
)).
toString
(),
'memorySize'
:
(
iosInfo
.
physicalRamSize
~/
(
1024
*
1024
)).
toString
(),
'statusBarHeight'
:
statusBarHeight
,
'statusbarHeight'
:
statusBarHeight
,
'titlebarHeight'
:
kToolbarHeight
,
};
};
}
else
{
}
else
{
return
{};
return
{};
...
...
lib/data/repositories/message/open_link_handler.dart
View file @
7918cd8
import
'package:appframe/config/routes.dart'
;
import
'package:appframe/config/routes.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
class
OpenLinkHandler
extends
MessageHandler
{
class
OpenLinkHandler
extends
MessageHandler
{
@override
@override
...
@@ -14,7 +15,18 @@ class OpenLinkHandler extends MessageHandler {
...
@@ -14,7 +15,18 @@ class OpenLinkHandler extends MessageHandler {
}
}
int
screenType
=
params
[
'screenType'
]
??
1
;
int
screenType
=
params
[
'screenType'
]
??
1
;
final
bool
isBrowser
=
params
[
'isBrowser'
]
as
bool
?
??
false
;
if
(
isBrowser
)
{
final
uri
=
Uri
.
parse
(
url
);
if
(
await
canLaunchUrl
(
uri
))
{
await
launchUrl
(
uri
,
mode:
LaunchMode
.
externalApplication
);
}
else
{
return
false
;
}
}
else
{
router
.
push
(
'/link'
,
extra:
{
'url'
:
url
,
'screenType'
:
screenType
});
router
.
push
(
'/link'
,
extra:
{
'url'
:
url
,
'screenType'
:
screenType
});
}
return
true
;
return
true
;
}
}
...
...
lib/data/repositories/message/title_bar_handler.dart
View file @
7918cd8
...
@@ -20,12 +20,13 @@ class TitleBarHandler extends MessageHandler {
...
@@ -20,12 +20,13 @@ class TitleBarHandler extends MessageHandler {
throw
Exception
(
'参数错误'
);
throw
Exception
(
'参数错误'
);
}
}
final
bool
hidden
=
params
[
'hidden'
]
as
bool
?
??
false
;
final
String
title
=
params
[
'title'
]
as
String
;
final
String
title
=
params
[
'title'
]
as
String
;
final
String
color
=
params
[
'color'
]
as
String
;
final
String
color
=
params
[
'color'
]
as
String
;
final
String
bgColor
=
params
[
'bgColor'
]
as
String
;
final
String
bgColor
=
params
[
'bgColor'
]
as
String
;
final
String
icon
=
params
[
'icon'
]
as
String
;
final
String
icon
=
params
[
'icon'
]
as
String
;
return
_webCubit
!.
setTitleBar
(
title
,
color
,
bgColor
,
icon
);
return
_webCubit
!.
setTitleBar
(
hidden
,
title
,
color
,
bgColor
,
icon
);
}
finally
{
}
finally
{
_unfollowCubit
();
_unfollowCubit
();
}
}
...
...
lib/ui/pages/web_page.dart
View file @
7918cd8
...
@@ -53,7 +53,7 @@ class WebPage extends StatelessWidget {
...
@@ -53,7 +53,7 @@ class WebPage extends StatelessWidget {
child:
BlocConsumer
<
WebCubit
,
WebState
>(
child:
BlocConsumer
<
WebCubit
,
WebState
>(
builder:
(
ctx
,
state
)
{
builder:
(
ctx
,
state
)
{
final
scaffold
=
Scaffold
(
final
scaffold
=
Scaffold
(
appBar:
_buildAppBar
(
ctx
,
state
)
,
appBar:
state
.
showAppBar
?
_buildAppBar
(
ctx
,
state
)
:
null
,
body:
Stack
(
body:
Stack
(
children:
[
children:
[
state
.
loaded
state
.
loaded
...
...
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