import 'package:cpt_auth/modules/select_estate/select_estate_view_model.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_text_field.dart';
import 'package:widgets/widget_export.dart';

//输入框的布局，单独抽取为了做Attach弹窗
class AttachInputWidget extends HookConsumerWidget {
  final void Function(BuildContext context, String value) onChanged;

  AttachInputWidget({
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final state = ref.watch(selectEstateViewModelProvider);

    return IgnoreKeyboardDismiss(
      child: MyTextField(
        "estate",
        key: key,
        fillBackgroundColor: context.appColors.authFiledBG,
        "",
        hintText: state.formData['estate']!['hintText'],
        hintStyle: TextStyle(
          color: context.appColors.authFiledHint,
          fontSize: 16.0,
          fontWeight: FontWeight.w500,
        ),
        controller: state.formData['estate']!['controller'],
        focusNode: state.formData['estate']!['focusNode'],
        margin: const EdgeInsets.only(top: 0),
        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
        showDivider: false,
        height: 44,
        style: TextStyle(
          color: context.appColors.authFiledText,
          fontSize: 16.0,
          fontWeight: FontWeight.w500,
        ),
        inputType: TextInputType.text,
        textInputAction: TextInputAction.done,
        onChanged: (k, v) {
          onChanged.call(context, v);
        },
        changeActionType: ClickType.debounce,
        changeActionMilliseconds: 500,
        cursorColor: context.appColors.authFiledText,
        obscureText: false,
        errorText: null,
        showLeftIcon: true,
        showRightIcon: false,
        rightWidget: null,
      ),
    );
  }
}
