import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/constants/bg_color.dart';
import 'package:sk_base_mobile/screens/new_inventory_inout/new_inventory_inout_controller.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';

class ZtTextInput extends StatelessWidget {
  final TextEditingController textController;
  final VoidCallback? onTap;
  final bool isRequired;
  final String labelText;
  final String? hint;
  final bool isTextArea;
  const ZtTextInput({
    super.key,
    required this.textController,
    this.onTap,
    this.hint,
    this.isRequired = false,
    this.labelText = '',
    this.isTextArea = false,
  });
  @override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: textController,
      onTapOutside: (event) {
        FocusScope.of(context).unfocus();
      },
      maxLines: isTextArea ? 2 : 1, // 添加这行代码
      onTap: onTap ?? () {},
      decoration: InputDecoration(
        floatingLabelBehavior: FloatingLabelBehavior.always,
        label: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: [
              if (isRequired)
                Text(
                  "*",
                  style: TextStyle(
                      color: Colors.red, fontSize: ScreenAdaper.sp(30)),
                ),
              Text(
                labelText,
                style: TextStyle(fontSize: ScreenAdaper.sp(30)),
              ),
            ]),
        focusedBorder: OutlineInputBorder(
            borderSide:
                const BorderSide(color: AppTheme.primaryColorLight, width: 2),
            borderRadius: BorderRadius.circular(ScreenAdaper.sp(15))),
        hintText: hint ?? '请输入',
      ),
    );
  }
}
