Browse Source

1、新增input搜索组件

bakamaka.guan 2 years ago
parent
commit
4582ecc867
2 changed files with 90 additions and 1 deletions
  1. 89 0
      lib/components/search_input.dart
  2. 1 1
      pubspec.yaml

+ 89 - 0
lib/components/search_input.dart

@@ -0,0 +1,89 @@
+import 'package:fis_ui/index.dart';
+import 'package:fis_ui/base_define/page.dart';
+import 'package:flutter/material.dart';
+
+///搜索组件
+class FSearchInput extends FStatefulWidget {
+  FSearchInput({
+    Key? key,
+    this.onChanged,
+    this.serchOnPressed,
+    this.hintText,
+    this.controller,
+    required this.businessParent,
+  }) : super(key: key);
+
+  ///父级节点
+  final FPage businessParent;
+
+  ///查询文本编辑Controller
+  final TextEditingController? controller;
+
+  ///查找事件回调
+  final VoidCallback? serchOnPressed;
+
+  ///文本改变回调
+  final ValueChanged? onChanged;
+
+  ///提示文字
+  final String? hintText;
+
+  @override
+  FState<FSearchInput> createState() => _FSearchInputState();
+}
+
+class _FSearchInputState extends FState<FSearchInput> {
+  @override
+  FWidget build(BuildContext context) {
+    return FContainer(
+      margin: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
+      color: Colors.white,
+      child: FRow(
+        children: [
+          FExpanded(
+            child: _buildSearchInput(),
+          ),
+        ],
+      ),
+    );
+  }
+
+  FWidget _buildSearchInput() {
+    return FContainer(
+      height: 36,
+      child: FRow(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: [
+          FBorderInput(
+            hintSize: 16,
+            contentSize: 16,
+            controller: widget.controller ?? TextEditingController(),
+            borderColor: Color.fromRGBO(211, 211, 211, 1),
+            suffixIcon: FMaterial(
+              color: Colors.transparent,
+              child: FIconButton(
+                name: "search",
+                businessParent: widget.businessParent,
+                onPressed: () {
+                  widget.serchOnPressed!.call();
+                },
+                icon: FIcon(
+                  Icons.search,
+                ),
+              ),
+            ),
+            height: 36,
+            hintText: widget.hintText,
+            onChanged: (value) {
+              widget.onChanged!.call(value);
+            },
+            textInputAction: TextInputAction.search,
+            onSubmitted: (value) {
+              widget.serchOnPressed!.call();
+            },
+          ),
+        ],
+      ),
+    );
+  }
+}

+ 1 - 1
pubspec.yaml

@@ -54,7 +54,7 @@ dependency_overrides:
   fis_ui:
     git:
       url: http://git.ius.plus:88/Project-Wing/fis_lib_ui.git
-      ref: adf8a2d
+      ref: e03c886
       # path: ../fis_lib_ui
 # For information on the generic Dart part of this file, see the
 # following page: https://dart.dev/tools/pub/pubspec