import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mitra_corporate/provider/menu_provider.dart';
import 'package:mitra_corporate/screen/registrasi/dialog_pendaftaran_pasien.dart';

import 'package:mitra_corporate/screen/registrasi/table_pasien.dart';
import 'package:mitra_corporate/widgets/header.dart';

import '../../app/constant.dart';
import '../../provider/registrasi_provider.dart';
import '../../widgets/custom_text_field.dart';

class RegistrasiPasienScreen extends HookConsumerWidget {
  const RegistrasiPasienScreen({super.key});

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

    final keywordCtr =
        useTextEditingController(text: ref.read(keywordProvider));
    return Scaffold(
      // backgroundColor: Constant.grey_200,
      // backgroundColor: Color(0xffF9FAFB),
      body: Column(
        children: [
          Header(),
          Padding(
            // padding: const EdgeInsets.all(0),
            padding: const EdgeInsets.all(32.0),
            child: Column(
              children: [
                Container(
                  alignment: Alignment.centerLeft,
                  // width: Constant.getActualX(context: context, x: 1079),
                  // height: Constant.getActualY(context: context, y: 40),
                  child: Text('Registrasi Pasien',
                      style: Constant.h3_400(context: context)
                          .copyWith(color: Constant.textBlack)),
                ),
                SizedBox(
                  height: Constant.getActualY(context: context, y: 40),
                ),
                Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(12)),
                  padding: EdgeInsets.symmetric(
                    horizontal: Constant.getActualX(context: context, x: 24),
                    vertical: Constant.getActualY(context: context, y: 32),
                  ),
                  child: Column(
                    children: [
                      Row(
                        children: [
                          Expanded(
                            // height: Constant.getActualY(context: context, y: 56),
                            child: CustomTextField(
                              controller: keywordCtr,
                              onChange: (value) {
                                ref.read(keywordProvider.notifier).state =
                                    value;
                              },
                              isPassword: false,
                              hintText: "Cari Nama, NIK, dan Nomor HP",
                              labelText: "Cari Nama, NIK, dan Nomor HP",
                              suffixIcon: Icon(EvaIcons.search),
                            ),
                          ),
                          SizedBox(
                              width:
                                  Constant.getActualX(context: context, x: 24)),
                          SizedBox(
                            width:
                                Constant.getActualX(context: context, x: 171),
                            height:
                                Constant.getActualY(context: context, y: 56),
                            // decoration: BoxDecoration(
                            //     borderRadius: BorderRadius.circular(8),
                            //     color: Constant.primaryRed),
                            child: ElevatedButton.icon(
                              label: Text('Pasien Baru',
                                  style: Constant.button_large(context: context)
                                      .copyWith(color: Constant.textWhite)),
                              icon: Icon(EvaIcons.plus,
                                  color: Colors.white, size: 20.0),
                              onPressed: () {
                                ref
                                    .read(dialogOrderActionProvider.notifier)
                                    .state = 'new';
                                showDialog(
                                    context: context,
                                    barrierDismissible: false,
                                    builder: ((context) =>
                                        DialogPendaftaranPasien()));
                              },
                            ),
                          ),
                        ],
                      ),
                      SizedBox(
                          height: Constant.getActualY(context: context, y: 24)),
                      TablePasien()
                    ],
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
