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 ZtNumberInput extends StatelessWidget {
  final TextEditingController textController;
  final VoidCallback? onTap;
  final bool isRequired;
  final String labelText;
  final String? hint;
  ZtNumberInput(
      {super.key,
      required this.textController,
      this.onTap,
      this.hint,
      this.isRequired = false,
      this.labelText = ''});
  @override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: textController,
      onTapOutside: (event) {
        FocusScope.of(context).unfocus();
      },
      onTap: onTap ?? () {},
      keyboardType: TextInputType.number,
      decoration: InputDecoration(
        floatingLabelBehavior: FloatingLabelBehavior.always,
        label: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: [
              if (isRequired)
                const Text(
                  "*",
                  style: TextStyle(color: Colors.red),
                ),
              Text(
                labelText,
              ),
            ]),
        focusedBorder: OutlineInputBorder(
            borderSide:
                const BorderSide(color: AppTheme.primaryColorLight, width: 2),
            borderRadius: BorderRadius.circular(ScreenAdaper.sp(15))),
        hintText: hint ?? '请输入',
      ),
    );
  }
}
