import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';

/// 手机端选择器
class FTimeValue extends FStatelessWidget {
  FTimeValue({
    Key? key,
    this.icon,
    this.onClick,
    this.hintText,
    this.value = '',
    this.borderText = '',
    this.suffixIcon,
    this.onChange,
    this.isCustomMade = false,
    this.tipTitle = '',
    this.inkWellTitle = '',
  }) : super(key: key);

  ///图标
  final FWidget? icon;

  ///尾部图标
  final FWidget? suffixIcon;

  ///提示文字
  final String? hintText;

  ///点击事件
  final Function? onClick;

  ///值
  final String? value;

  ///边框文字
  final String? borderText;

  /// 下拉选中的值
  final ValueCallback? onChange;

  /// 是否定制
  final bool? isCustomMade;

  /// 未选择的时候提示
  final String? tipTitle;

  /// 当前数据为空的提示
  final String? inkWellTitle;

  ///区域文本内容
  FWidget _buildTextContent() {
    if (value == null)
      return FText(
        hintText!,
        style: TextStyle(
          fontSize: 14,
          color: Color.fromRGBO(155, 155, 155, 1),
        ),
      );
    else
      return FText(
        value!,
        style: TextStyle(
          fontSize: 14,
          color: Colors.black,
        ),
        textAlign: TextAlign.right,
        overflow: TextOverflow.ellipsis,
        maxLines: 1,
      );
  }

  @override
  FWidget build(BuildContext context) {
    return FContainer(
      padding: EdgeInsets.symmetric(vertical: 15),
      child: FColumn(
        children: [
          FContainer(
            child: FRow(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              mainAxisSize: MainAxisSize.max,
              children: [
                FContainer(
                  alignment: Alignment.centerRight,
                  child: _buildTextContent(),
                ),
                suffixIcon ??
                    FIcon(
                      Icons.chevron_right,
                      color: Color.fromRGBO(164, 164, 164, 1),
                    ),
              ],
            ),
          ),
          FContainer(
            decoration: BoxDecoration(
              border: Border(
                bottom: BorderSide(
                  color: Color.fromRGBO(245, 245, 245, 1),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
