Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
F
flutter_clx_base
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
flutter_clx_base
Commits
e0d939ab
提交
e0d939ab
authored
7月 21, 2023
作者:
shixiaochen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、优化MyScrollView(适配iOS软键盘隐藏);
上级
911eb6be
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
64 行增加
和
33 行删除
+64
-33
sample.dart
example/lib/sample.dart
+5
-0
scroll_view.dart
example/lib/sample/scroll_view.dart
+36
-0
keyboard_utils.dart
lib/utils/keyboard_utils.dart
+5
-3
my_scroll_view.dart
lib/widget/my_scroll_view.dart
+18
-30
没有找到文件。
example/lib/sample.dart
浏览文件 @
e0d939ab
...
...
@@ -4,6 +4,7 @@ import 'package:flutter_clx_base/utils/device_utils.dart';
import
'package:flutter_clx_base/widget/normal_dialog.dart'
;
import
'package:flutter_clx_base_example/sample/base_list_widget_test.dart'
;
import
'package:flutter_clx_base_example/sample/dio_widget_test.dart'
;
import
'package:flutter_clx_base_example/sample/scroll_view.dart'
;
class
Sample
extends
StatelessWidget
{
const
Sample
({
super
.
key
});
...
...
@@ -48,6 +49,10 @@ class Sample extends StatelessWidget {
" deviceSerial =
$deviceSerial
"
);
},
text:
'获取设备信息'
),
GFButton
(
fullWidthButton:
true
,
onPressed:
()
=>
Get
.
to
(
const
ScrollViewPage
()),
text:
'scrollView'
),
],
);
}
...
...
example/lib/sample/scroll_view.dart
0 → 100644
浏览文件 @
e0d939ab
import
'package:flutter/material.dart'
;
import
'package:flutter_clx_base/flutter_clx_base.dart'
;
class
ScrollViewPage
extends
StatefulWidget
{
const
ScrollViewPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
ScrollViewPage
>
createState
()
=>
_ScrollViewPageState
();
}
class
_ScrollViewPageState
extends
State
<
ScrollViewPage
>
{
var
focusNode1
=
FocusNode
();
var
focusNode2
=
FocusNode
();
@override
Widget
build
(
BuildContext
context
)
{
return
MyScaffold
(
title:
"scrollView"
,
body:
MyScrollView
(
keyboardConfig:
KeyBoardUtils
.
getKeyboardActionsConfig
(
context
,
<
FocusNode
>[
focusNode1
,
focusNode2
]),
children:
[
TextField
(
focusNode:
focusNode1
),
GFButton
(
fullWidthButton:
true
,
onPressed:
()
{
ToastUtil
.
showToast
(
"点击按钮"
);
},
text:
'点击按钮'
),
SizedBox
(
height:
500
),
TextField
(
focusNode:
focusNode2
),
],
),
);
}
}
lib/utils/keyboard_utils.dart
浏览文件 @
e0d939ab
...
...
@@ -3,13 +3,17 @@ import 'package:keyboard_actions/keyboard_actions.dart';
class
KeyBoardUtils
{
static
KeyboardActionsConfig
getKeyboardActionsConfig
(
BuildContext
context
,
List
<
FocusNode
>
list
)
{
BuildContext
context
,
List
<
FocusNode
>
list
,
{
bool
displayActionBar
=
false
,
// 是否展示actionBar
})
{
return
KeyboardActionsConfig
(
keyboardBarColor:
Colors
.
grey
[
200
],
nextFocus:
true
,
actions:
List
.
generate
(
list
.
length
,
(
i
)
=>
KeyboardActionsItem
(
displayActionBar:
displayActionBar
,
focusNode:
list
[
i
],
toolbarButtons:
[
(
node
)
{
...
...
@@ -31,5 +35,3 @@ class KeyBoardUtils {
FocusManager
.
instance
.
primaryFocus
?.
unfocus
();
}
}
lib/widget/my_scroll_view.dart
浏览文件 @
e0d939ab
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:keyboard_actions/keyboard_actions.dart'
;
...
...
@@ -37,45 +36,34 @@ class MyScrollView extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
Widget
contents
=
SizedBox
(
width:
double
.
infinity
,
child:
Column
(
crossAxisAlignment:
crossAxisAlignment
,
children:
children
,
Widget
contents
=
SingleChildScrollView
(
padding:
padding
,
physics:
physics
,
controller:
controller
,
child:
SizedBox
(
width:
double
.
infinity
,
child:
Column
(
crossAxisAlignment:
crossAxisAlignment
,
children:
children
,
),
),
);
if
(
defaultTargetPlatform
==
TargetPlatform
.
iOS
&&
keyboardConfig
!=
null
)
{
/// iOS 键盘处理
if
(
padding
!=
null
)
{
contents
=
Padding
(
padding:
padding
!,
child:
contents
);
}
// 软键盘处理
if
(
keyboardConfig
!=
null
)
{
contents
=
KeyboardActions
(
isDialog:
bottomButton
!=
null
,
overscroll:
overScroll
,
config:
keyboardConfig
!,
tapOutsideBehavior:
TapOutsideBehavior
.
opaqueDismiss
,
child:
contents
);
}
else
{
contents
=
SingleChildScrollView
(
padding:
padding
,
physics:
physics
,
controller:
controller
,
isDialog:
bottomButton
!=
null
,
overscroll:
overScroll
,
config:
keyboardConfig
!,
tapOutsideBehavior:
TapOutsideBehavior
.
opaqueDismiss
,
child:
contents
,
);
}
// 设置底部按钮
if
(
bottomButton
!=
null
)
{
contents
=
Column
(
children:
<
Widget
>[
Expanded
(
child:
contents
),
bottomButton
!
],
children:
<
Widget
>[
Expanded
(
child:
contents
),
bottomButton
!],
);
}
return
contents
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论