custom_widgets.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:taskservice/Common/JXColors.dart';
  5. class MyScaffold extends StatelessWidget {
  6. final Widget body;
  7. final String title;
  8. MyScaffold({@required this.title, @required this.body});
  9. @override
  10. Widget build(BuildContext context) {
  11. return Scaffold(
  12. appBar: AppBar(
  13. centerTitle: true,
  14. title: Text(title),
  15. backgroundColor: JXColors.k101E40,
  16. ),
  17. body: SafeArea(
  18. child: body,
  19. ),
  20. );
  21. }
  22. }
  23. class SearchBar extends StatefulWidget {
  24. final Function(String value) onTextChanged;
  25. final String hint;
  26. final FocusNode focusNode;
  27. final Function() onBtnClear;
  28. final TextEditingController searchController;
  29. SearchBar({this.onTextChanged, this.hint, this.focusNode, this.onBtnClear, this.searchController});
  30. @override
  31. _SearchBarState createState() => _SearchBarState();
  32. }
  33. class _SearchBarState extends State<SearchBar> {
  34. @override
  35. Widget build(BuildContext context) {
  36. return Container(
  37. color: JXColors.kF0F0F0,
  38. padding: EdgeInsets.fromLTRB(12.0, 8, 12.0, 8),
  39. child: Container(
  40. alignment: Alignment.center,
  41. decoration: BoxDecoration(
  42. color: JXColors.kE6E6E6,
  43. borderRadius: BorderRadius.circular(12.0),
  44. border: Border.all(color: JXColors.kE6E6E6, width: 1),
  45. ),
  46. height: 44.0,
  47. child: Row(children: <Widget>[
  48. SizedBox(
  49. width: 12,
  50. ),
  51. Icon(
  52. Icons.search,
  53. size: 24.0,
  54. ),
  55. SizedBox(
  56. width: 6,
  57. ),
  58. Expanded(
  59. child: TextField(
  60. controller: widget.searchController,
  61. maxLines: 1,
  62. focusNode: widget.focusNode,
  63. obscureText: false,
  64. cursorColor: JXColors.k1F2529,
  65. decoration: InputDecoration(
  66. border: InputBorder.none,
  67. hintText: '快速筛选',
  68. labelStyle: TextStyle(
  69. color: JXColors.k2E3032,
  70. fontSize: 24.0,
  71. ),
  72. ),
  73. onChanged: widget.onTextChanged,
  74. ),
  75. ),
  76. CupertinoButton(
  77. onPressed: widget.onBtnClear,
  78. padding: EdgeInsets.all(0),
  79. child: Icon(
  80. Icons.cancel,
  81. color: JXColors.k747A7E,
  82. size: 24.0,
  83. ),
  84. ),
  85. ]),
  86. ),
  87. );
  88. }
  89. }