提交 b2a216cc authored 作者: shixiaochen's avatar shixiaochen

1、SearchAppBar:①增加属性,leftWidget(搜索框左侧自定义widget) ②修改右侧搜索按钮展示隐藏判断

上级 e826adc3
......@@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
import 'package:flutter/material.dart';
import 'package:flutter_clx_base/common/gaps.dart';
import 'package:flutter_clx_base/utils/keyboard_utils.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base/utils/string_util.dart';
import 'package:flutter_clx_base/utils/toast_util.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
class SearchAppBar extends StatefulWidget implements PreferredSizeWidget {
......@@ -21,6 +19,7 @@ class SearchAppBar extends StatefulWidget implements PreferredSizeWidget {
final Function? onFocusListener;
final String? rightText;
final Function? onRightBtnCallback;
final Widget? leftWidget;
const SearchAppBar({
Key? key,
......@@ -39,6 +38,7 @@ class SearchAppBar extends StatefulWidget implements PreferredSizeWidget {
this.onRightBtnCallback,
this.searchIconColor,
this.searchIconSize,
this.leftWidget,
}) : super(key: key);
@override
......@@ -86,11 +86,12 @@ class _SearchAppBarState extends State<SearchAppBar> {
child: Row(
children: <Widget>[
hGap10,
Icon(
Icons.search,
color: widget.searchIconColor ?? Colors.grey.shade300,
size: widget.searchIconSize,
),
widget.leftWidget ??
Icon(
Icons.search,
color: widget.searchIconColor ?? Colors.grey.shade300,
size: widget.searchIconSize,
),
hGap5,
Expanded(
child: TextField(
......@@ -122,21 +123,25 @@ class _SearchAppBarState extends State<SearchAppBar> {
),
),
),
InkWell(
onTap: () {
widget.onRightBtnCallback != null
? widget.onRightBtnCallback?.call()
: _search();
},
child: Container(
width: 60.0,
height: 50.0,
alignment: Alignment.center,
child: Text(
widget.rightText ?? "搜索",
style: TextStyle(
color: widget.searchTextColor ?? const Color(0xFFFFFFFF),
fontSize: 14.0),
Offstage(
offstage: widget.rightText.isNullOrEmpty(),
child: InkWell(
onTap: () {
widget.onRightBtnCallback != null
? widget.onRightBtnCallback?.call()
: _search();
},
child: Container(
width: 60.0,
height: 50.0,
alignment: Alignment.center,
child: Text(
widget.rightText ?? "搜索",
style: TextStyle(
color:
widget.searchTextColor ?? const Color(0xFFFFFFFF),
fontSize: 14.0),
),
),
),
)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论