/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2021-04-15 10:07:25
 * @LastEditTime : 2023-05-25 15:42:56
 * @FilePath     : /wisdom-huiguanjia-app/search_package/lib/src/components/search_input.dart
 * @Description  : Do not edit
 */

import 'package:flutter/material.dart';
import 'package:search_package/src/view_models/search_index_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

class SearchInput extends StatefulWidget {
  SearchInput({
    Key? key,
    this.onInput,
    this.onCancel,
    this.placeholder,
    this.title,
  }) : super(key: key);
  final String? placeholder;
  final String? title;
  final Function(dynamic v)? onInput;
  final Function()? onCancel;

  @override
  _SearchInputState createState() => _SearchInputState();
}

class _SearchInputState extends State<SearchInput> {
  SearchIndexStore get store => Provider.of(context, listen: false);

  @override
  Widget build(BuildContext context) {
    return Wisdom.row(
      color: Colors.white,
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        /// 输入框
        Expanded(
          child: WSearch(
            isControlOutside: true,
            initValue: widget.title ?? '',
            hintText: widget.placeholder ?? '请输入姓名/手机号',
            onSubmitted: (v) => widget.onInput!(v),
            onCancel: () => widget.onCancel!(),
            moonlight: false,
            padding: EdgeInsets.symmetric(vertical: 10.pt),
            isDark: true,
          ),
        ),
      ],
    );
    // Wisdom.row(
    //   margin: EdgeInsets.fromLTRB(16.pt, 8.pt, 16.pt, 8.pt),
    //   mainAxisAlignment: MainAxisAlignment.center,
    //   children: <Widget>[
    //     /// 输入框
    //     Expanded(
    //       child: Wisdom(
    //         height: 40.pt,
    //         color: Colors.white,
    //         padding: EdgeInsets.symmetric(horizontal: 15.pt),
    //         borderRadius: BorderRadius.horizontal(
    //           left: Radius.circular(10.pt),
    //         ),
    //         child: TextField(
    //           onChanged: (v) => widget.onInput(v),
    //           decoration: InputDecoration(
    //             fillColor: Colors.transparent,
    //             hintText: widget?.placeholder ?? '请输入姓名/手机号',
    //             icon: Icon(
    //               FaIcons.search,
    //               size: 15.pt,
    //               color: Color(0x33000000),
    //             ),
    //           ),
    //         ),
    //       ),
    //     ),

    //     /// 搜索按钮
    //     Wisdom.row(
    //       onTap: () => widget.onSearch(),
    //       mainAxisAlignment: MainAxisAlignment.center,
    //       height: 40.pt,
    //       width: 51.pt,
    //       borderRadius: BorderRadius.horizontal(
    //         right: new Radius.circular(10.pt),
    //       ),
    //       color: Color(0xFF2D8CF0),
    //       children: <Widget>[
    //         WisText(
    //           '搜索',
    //           color: Colors.white,
    //           size: 14.pt,
    //         )
    //       ],
    //     )
    //   ],
    // );
  }
}
