import 'package:flutter/material.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
import 'package:sk_base_mobile/widgets/form_item/sk_base_field.dart';

class SkFormItem extends StatelessWidget {
  final Widget child;
  final bool customLabel;
  final bool isRequired;
  final String? labelText;
  final SkBaseFieldController controller;
  const SkFormItem(
      {super.key,
      required this.child,
      required this.customLabel,
      required this.controller,
      this.labelText,
      this.isRequired = false});

  @override
  Widget build(BuildContext context) {
    if (customLabel) {
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: [
                if (isRequired)
                  Text(
                    "*",
                    style: TextStyle(
                        color: Colors.red, fontSize: ScreenAdaper.height(25)),
                  ),
                SizedBox(
                  width: ScreenAdaper.width(5),
                ),
                Obx(() => Text(
                      labelText ?? '',
                      style: TextStyle(
                          fontSize: ScreenAdaper.height(25),
                          fontWeight: FontWeight.w600,
                          color: controller.isFocus.value
                              ? AppTheme.primaryColor
                              : AppTheme.nearlyBlack),
                    )),
              ]),
          SizedBox(
            height: ScreenAdaper.height(8),
          ),
          child
        ],
      );
    } else {
      return child;
    }
  }
}
