search_input.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:fis_ui/index.dart';
  2. import 'package:fis_ui/base_define/page.dart';
  3. import 'package:flutter/material.dart';
  4. ///搜索组件
  5. class FSearchInput extends FStatefulWidget {
  6. FSearchInput({
  7. Key? key,
  8. this.onChanged,
  9. this.serchOnPressed,
  10. this.hintText,
  11. this.controller,
  12. required this.businessParent,
  13. }) : super(key: key);
  14. ///父级节点
  15. final FPage businessParent;
  16. ///查询文本编辑Controller
  17. final TextEditingController? controller;
  18. ///查找事件回调
  19. final VoidCallback? serchOnPressed;
  20. ///文本改变回调
  21. final ValueChanged? onChanged;
  22. ///提示文字
  23. final String? hintText;
  24. @override
  25. FState<FSearchInput> createState() => _FSearchInputState();
  26. }
  27. class _FSearchInputState extends FState<FSearchInput> {
  28. @override
  29. FWidget build(BuildContext context) {
  30. return FContainer(
  31. margin: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
  32. color: Colors.white,
  33. child: FRow(
  34. children: [
  35. FExpanded(
  36. child: _buildSearchInput(),
  37. ),
  38. ],
  39. ),
  40. );
  41. }
  42. FWidget _buildSearchInput() {
  43. return FContainer(
  44. height: 36,
  45. child: FRow(
  46. crossAxisAlignment: CrossAxisAlignment.center,
  47. children: [
  48. FBorderInput(
  49. hintSize: 16,
  50. contentSize: 16,
  51. controller: widget.controller ?? TextEditingController(),
  52. borderColor: Color.fromRGBO(211, 211, 211, 1),
  53. suffixIcon: FMaterial(
  54. color: Colors.transparent,
  55. child: FIconButton(
  56. name: "search",
  57. businessParent: widget.businessParent,
  58. onPressed: () {
  59. widget.serchOnPressed!.call();
  60. },
  61. icon: FIcon(
  62. Icons.search,
  63. ),
  64. ),
  65. ),
  66. height: 36,
  67. hintText: widget.hintText,
  68. onChanged: (value) {
  69. widget.onChanged!.call(value);
  70. },
  71. textInputAction: TextInputAction.search,
  72. onSubmitted: (value) {
  73. widget.serchOnPressed!.call();
  74. },
  75. ),
  76. ],
  77. ),
  78. );
  79. }
  80. }