Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
d9bb1748
提交
d9bb1748
authored
12月 21, 2023
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用 ReadController 管理状态
上级
05b39a7a
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
146 行增加
和
15 行删除
+146
-15
Podfile.lock
ios/Podfile.lock
+1
-1
main.dart
lib/main.dart
+9
-6
index.dart
lib/pages/home/index.dart
+4
-0
view.dart
lib/pages/home/view.dart
+14
-3
view.dart
lib/pages/main/view.dart
+1
-1
controller.dart
lib/pages/web/controller.dart
+42
-0
index.dart
lib/pages/web/index.dart
+4
-0
view.dart
lib/pages/web/view.dart
+59
-3
index.dart
lib/routes/index.dart
+1
-0
routes.dart
lib/routes/routes.dart
+10
-0
pubspec.yaml
pubspec.yaml
+1
-1
没有找到文件。
ios/Podfile.lock
浏览文件 @
d9bb1748
...
@@ -70,6 +70,6 @@ SPEC CHECKSUMS:
...
@@ -70,6 +70,6 @@ SPEC CHECKSUMS:
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
PODFILE CHECKSUM:
0ad3cbdbfc252b10d3b4db129d4d399f42000f4b
PODFILE CHECKSUM:
d88b567994d32cfdf2f8417e66666d472921c85e
COCOAPODS: 1.11.2
COCOAPODS: 1.11.2
lib/main.dart
浏览文件 @
d9bb1748
...
@@ -51,12 +51,15 @@ class MyApp extends StatelessWidget {
...
@@ -51,12 +51,15 @@ class MyApp extends StatelessWidget {
);
);
},
},
),
),
// localizationsDelegates: const [
supportedLocales:
const
[
// GlobalMaterialLocalizations.delegate,
Locale
(
'zh'
,
'CN'
),
// Chinese
// GlobalWidgetsLocalizations.delegate,
],
// GlobalCupertinoLocalizations.delegate,
localizationsDelegates:
const
[
// // S.delegate,
GlobalMaterialLocalizations
.
delegate
,
// ],
GlobalWidgetsLocalizations
.
delegate
,
GlobalCupertinoLocalizations
.
delegate
,
// S.delegate,
],
// locale: config.locale,
// locale: config.locale,
// supportedLocales: S.delegate.supportedLocales,
// supportedLocales: S.delegate.supportedLocales,
),
),
...
...
lib/pages/home/index.dart
浏览文件 @
d9bb1748
...
@@ -2,6 +2,9 @@ library home;
...
@@ -2,6 +2,9 @@ library home;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:go_router/go_router.dart'
;
import
'../../routes/index.dart'
;
part
'view.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/home/view.dart
浏览文件 @
d9bb1748
...
@@ -12,9 +12,20 @@ class _HomePageState extends State<HomePage> {
...
@@ -12,9 +12,20 @@ class _HomePageState extends State<HomePage> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setSystemUIOverlayStyle
(
SystemUiOverlayStyle
.
light
);
SystemChrome
.
setSystemUIOverlayStyle
(
SystemUiOverlayStyle
.
light
);
return
Scaffold
(
return
Scaffold
(
body:
Container
(
appBar:
AppBar
(
title:
const
Text
(
'首页'
),),
color:
Colors
.
cyan
,
body:
Column
(
),
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
ElevatedButton
(
onPressed:
(){
context
.
pushNamed
(
Routes
.
web
);
},
child:
const
Text
(
'web'
),
)
],
)
);
);
}
}
}
}
lib/pages/main/view.dart
浏览文件 @
d9bb1748
...
@@ -39,7 +39,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver{
...
@@ -39,7 +39,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver{
controller:
controller
.
pageController
,
controller:
controller
.
pageController
,
onPageChanged:
controller
.
onPageChanged
,
onPageChanged:
controller
.
onPageChanged
,
children:
const
[
children:
const
[
Web
Page
(),
Home
Page
(),
LibraryPage
(),
LibraryPage
(),
TestTTSPage
(),
TestTTSPage
(),
RecordPage
(),
RecordPage
(),
...
...
lib/pages/web/controller.dart
0 → 100644
浏览文件 @
d9bb1748
part of
web
;
class
ReadController
extends
GetxController
with
GetSingleTickerProviderStateMixin
{
late
AnimationController
_controller
;
bool
_show
=
false
;
bool
get
show
=>
_show
;
void
setShow
(
bool
value
)
{
_show
=
!
value
;
if
(
_show
)
{
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
edgeToEdge
);
_controller
.
forward
();
}
else
{
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersiveSticky
);
_controller
.
reverse
();
}
update
();
}
AnimationController
get
controller
=>
_controller
;
@override
void
onInit
()
{
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersiveSticky
);
_controller
=
AnimationController
(
vsync:
this
,
duration:
const
Duration
(
milliseconds:
100
),
);
super
.
onInit
();
}
@override
void
onClose
()
{
_controller
.
dispose
();
super
.
onClose
();
}
}
\ No newline at end of file
lib/pages/web/index.dart
浏览文件 @
d9bb1748
...
@@ -2,7 +2,10 @@ library web;
...
@@ -2,7 +2,10 @@ library web;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_inappwebview/flutter_inappwebview.dart'
;
import
'package:flutter_inappwebview/flutter_inappwebview.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:get/get.dart'
;
part
'view.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/web/view.dart
浏览文件 @
d9bb1748
...
@@ -8,10 +8,20 @@ class WebPage extends StatefulWidget {
...
@@ -8,10 +8,20 @@ class WebPage extends StatefulWidget {
}
}
class
_WebPageState
extends
State
<
WebPage
>
{
class
_WebPageState
extends
State
<
WebPage
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
GetBuilder
<
ReadController
>(
body:
InAppWebView
(
init:
ReadController
(),
builder:
(
readController
)
=>
Scaffold
(
body:
Stack
(
children:
[
InAppWebView
(
initialUrlRequest:
URLRequest
(
initialUrlRequest:
URLRequest
(
url:
Uri
.
parse
(
'http://192.168.11.39:5500/'
),
url:
Uri
.
parse
(
'http://192.168.11.39:5500/'
),
),
),
...
@@ -23,9 +33,14 @@ class _WebPageState extends State<WebPage> {
...
@@ -23,9 +33,14 @@ class _WebPageState extends State<WebPage> {
ContextMenuItem
(
title:
'划线'
,
androidId:
1
,
iosId:
'1'
),
ContextMenuItem
(
title:
'划线'
,
androidId:
1
,
iosId:
'1'
),
ContextMenuItem
(
title:
'提问'
,
androidId:
2
,
iosId:
'2'
),
ContextMenuItem
(
title:
'提问'
,
androidId:
2
,
iosId:
'2'
),
ContextMenuItem
(
title:
'笔记'
,
androidId:
3
,
iosId:
'3'
),
ContextMenuItem
(
title:
'笔记'
,
androidId:
3
,
iosId:
'3'
),
ContextMenuItem
(
title:
'划线1'
,
androidId:
1
,
iosId:
'1'
),
ContextMenuItem
(
title:
'划线2'
,
androidId:
1
,
iosId:
'1'
),
ContextMenuItem
(
title:
'划线3'
,
androidId:
1
,
iosId:
'1'
),
ContextMenuItem
(
title:
'划线4'
,
androidId:
1
,
iosId:
'1'
),
],
],
options:
ContextMenuOptions
(
options:
ContextMenuOptions
(
hideDefaultSystemContextMenuItems:
tru
e
,
hideDefaultSystemContextMenuItems:
fals
e
,
),
),
onContextMenuActionItemClicked:
(
ContextMenuItem
item
)
async
{
onContextMenuActionItemClicked:
(
ContextMenuItem
item
)
async
{
switch
(
item
.
title
){
switch
(
item
.
title
){
...
@@ -43,6 +58,47 @@ class _WebPageState extends State<WebPage> {
...
@@ -43,6 +58,47 @@ class _WebPageState extends State<WebPage> {
}
}
),
),
onLoadStop:
(
controller
,
url
)
{
controller
.
addJavaScriptHandler
(
handlerName:
'onTap'
,
callback:
(
args
){
readController
.
setShow
(
readController
.
show
);
});
controller
.
evaluateJavascript
(
source
:
'''
document.addEventListener('
click
', function() {
window.flutter_inappwebview.callHandler('
onTap
');
});
'''
);
},
),
AnimatedPositioned
(
duration:
readController
.
controller
.
duration
!,
curve:
Curves
.
easeInOut
,
top:
readController
.
show
?
0
:
-
100
,
// 负值隐藏,0 显示
left:
0
,
right:
0
,
height:
100
,
child:
Container
(
color:
Colors
.
limeAccent
,
alignment:
Alignment
.
center
,
child:
Text
(
'top View'
),
),
),
AnimatedPositioned
(
duration:
readController
.
controller
.
duration
!,
curve:
Curves
.
easeInOut
,
bottom:
readController
.
show
?
0
:
-
100
,
// 负值隐藏,0 显示
left:
0
,
right:
0
,
height:
100
,
child:
Container
(
color:
Colors
.
limeAccent
,
alignment:
Alignment
.
center
,
child:
Text
(
'Bottom View'
),
),
),
],
),
),
),
);
);
...
...
lib/routes/index.dart
浏览文件 @
d9bb1748
...
@@ -6,6 +6,7 @@ import 'package:flutter_book/pages/ad/index.dart';
...
@@ -6,6 +6,7 @@ import 'package:flutter_book/pages/ad/index.dart';
import
'package:flutter_book/pages/login/index.dart'
;
import
'package:flutter_book/pages/login/index.dart'
;
import
'package:flutter_book/pages/main/index.dart'
;
import
'package:flutter_book/pages/main/index.dart'
;
import
'package:flutter_book/pages/splash/index.dart'
;
import
'package:flutter_book/pages/splash/index.dart'
;
import
'package:flutter_book/pages/web/index.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:go_router/go_router.dart'
;
...
...
lib/routes/routes.dart
浏览文件 @
d9bb1748
...
@@ -8,6 +8,7 @@ abstract class Routes {
...
@@ -8,6 +8,7 @@ abstract class Routes {
static
const
main
=
'main'
;
static
const
main
=
'main'
;
static
const
ad
=
'ad'
;
static
const
ad
=
'ad'
;
static
const
login
=
'login'
;
static
const
login
=
'login'
;
static
const
web
=
'web'
;
static
final
GoRouter
config
=
GoRouter
(
static
final
GoRouter
config
=
GoRouter
(
// initialLocation: '/$splash',
// initialLocation: '/$splash',
...
@@ -49,6 +50,15 @@ abstract class Routes {
...
@@ -49,6 +50,15 @@ abstract class Routes {
key:
state
.
pageKey
,
key:
state
.
pageKey
,
child:
const
LoginPage
()
child:
const
LoginPage
()
)
)
),
GoRoute
(
path:
'/
$web
'
,
name:
web
,
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
child:
const
WebPage
()
)
)
)
]
]
);
);
...
...
pubspec.yaml
浏览文件 @
d9bb1748
...
@@ -50,7 +50,7 @@ dependencies:
...
@@ -50,7 +50,7 @@ dependencies:
crypto
:
3.0.3
crypto
:
3.0.3
convert
:
3.0.1
convert
:
3.0.1
flutter_tts
:
3.8.5
flutter_tts
:
3.8.5
flutter_inappwebview
:
^5.
6
.0
flutter_inappwebview
:
^5.
8
.0
intl
:
0.18.0
intl
:
0.18.0
flutter_sound
:
^9.2.13
flutter_sound
:
^9.2.13
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论