import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:geolocator/geolocator.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:intl/intl.dart';
import '/models/detail_history_model.dart';
import '/screen/detail_history_screen/detail_history_provider.dart';
import '/widget/chip_type.dart';
import '/widget/patient_card.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:maps_launcher/maps_launcher.dart';

import '../../app/constant.dart';
import '../../widget/snackbar_widget.dart';

class DetailHistoryProp {
  final String tipeId;
  final String kurirId;
  final String deliveryId;

  DetailHistoryProp(this.tipeId, this.kurirId, this.deliveryId);
}

class DetailHistoryScreen extends HookConsumerWidget {
  const DetailHistoryScreen(
      {super.key, required this.data, required this.prop});
  final Map<String, dynamic> data;
  final DetailHistoryProp prop;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final detailLoading = useState(false);
    final detailData = useState<DetailHistoryModel>(DetailHistoryModel());
    var formattedDate = useState('');

    final pengambilanAwalLoc = useState<Map<String, String>>(
        {"long": "110.7104622", "lat": "-7.5031631"});
    final pengambilanAkhirLoc = useState<Map<String, String>>(
        {"long": "110.7104622", "lat": "-7.5031631"});
    final pengantaranAwalLoc = useState<Map<String, String>>(
        {"long": "110.7104622", "lat": "-7.5031631"});
    final pengantaranAkhirLoc = useState<Map<String, String>>(
        {"long": "110.7104622", "lat": "-7.5031631"});
    final petugasPengambilan = useState("Liliana Ruby");
    final petugasPengantaran = useState("Liliana Ruby");
    final catatanPengambilan = useState("Lengkap");
    final catatanPengantaran = useState("Lengkap");

    List<Map<String, String>> listPasien = [
      {"id": "1", "name": "Sabrina Dewi", "no_lab": "112035"},
      {"id": "2", "name": "Lisa Andriani", "no_lab": "113040"},
      {"id": "3", "name": "Leo Rolly", "no_lab": "112987"},
    ];
    fetchData() {
      ref.read(DetailHistoryProvider.notifier).getData(
          id: prop.kurirId, tipeId: prop.tipeId, deliveryId: prop.deliveryId);
    }

    useEffect(() {
      WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
        fetchData();
      });
      return () {};
    }, []);
    ref.listen(
      DetailHistoryProvider,
      (previous, next) {
        if (next is DetailHistoryStateLoading) {
          detailLoading.value = true;
        } else if (next is DetailHistoryStateError) {
          // print(next.message);
          detailLoading.value = false;
          SanckbarWidget(
              context, next.message.substring(0, 30), snackbarType.error);
        } else if (next is DetailHistoryStateDone) {
          // print(next.model);
          detailData.value = next.model;
          String originalDateString = next.model.cdate.toString();
          DateTime originalDate =
              DateFormat('dd-MM-yyyy HH:mm:ss').parse(originalDateString);
          // String formattedDate = DateFormat.yMMMMd('id').format(originalDate);
          formattedDate.value = DateFormat('d MMM HH:mm').format(originalDate);
          // print("data from json");
          // print(next.model.tipeid);
          pengambilanAwalLoc.value = {
            "long": next.model.lngPengambilanAwal ?? "0",
            "lat": next.model.latPengambilanAwal ?? "0"
          };
          pengambilanAkhirLoc.value = {
            "long": next.model.lngPengambilanAkhir ?? "0",
            "lat": next.model.latPengambilanAkhir ?? "0"
          };

          pengantaranAwalLoc.value = {
            "long": next.model.lngPengantaranAwal ?? "0",
            "lat": next.model.latPengantaranAwal ?? "0"
          };
          pengantaranAkhirLoc.value = {
            "long": next.model.lngPengantaranAkhir ?? "0",
            "lat": next.model.latPengantaranAkhir ?? "0"
          };
          petugasPengambilan.value = next.model.petugasPenyerahan ?? " ";
          petugasPengantaran.value = next.model.penerima ?? " ";
          catatanPengantaran.value = next.model.notePenerimaan ?? " ";
          catatanPengambilan.value = next.model.notePenyerahan ?? " ";

          detailLoading.value = false;
        }
      },
    );

    return detailLoading.value
        ? SizedBox(
            height: Constant.designHeight * 0.9,
            child: Center(
              child: LoadingAnimationWidget.fourRotatingDots(
                  color: Constant.primaryBlue, size: 50),
            ),
          )
        : SingleChildScrollView(
            child: Column(children: [
              SizedBox(
                height: Constant.getActualY(context: context, y: 24),
              ),
              Container(
                padding: EdgeInsets.symmetric(
                    horizontal: Constant.getActualX(context: context, x: 20)),
                height: Constant.getActualY(context: context, y: 40),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Image.asset(
                      "assets/icon_detail_riwayat_motor.png",
                      width: Constant.getActualX(context: context, x: 64),
                      height: Constant.getActualX(context: context, x: 64),
                    ),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          formattedDate.value,
                          style: Constant.body1(context: context)
                              .copyWith(fontWeight: FontWeight.w500),
                        ),
                        ChipType(
                          name: detailData.value.tipe.toString(),
                          tipe: int.parse(prop.tipeId),
                          isDetailHistory: true,
                        )
                      ],
                    )
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.symmetric(
                    horizontal: Constant.getActualX(context: context, x: 35)),
                // color: Colors.red,
                height: Constant.getActualY(context: context, y: 737),
                child: SingleChildScrollView(
                  // reverse: MediaQuery.of(context).viewInsets.bottom != 0
                  //     ? true
                  //     : false,
                  child: Padding(
                    padding: EdgeInsets.only(
                        bottom: MediaQuery.of(context).viewInsets.bottom),
                    child: Column(
                      // shrinkWrap: true,

                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        displayDetailText(context, "No. Surat Jalan",
                            detailData.value.noSuratJalan.toString()),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        displayDetailText(
                            context, "Nama", detailData.value.nama.toString()),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        if (int.parse(prop.tipeId) == 1)
                          Container(
                            margin: EdgeInsets.only(
                              bottom:
                                  Constant.getActualY(context: context, y: 12),
                            ),
                            child: displayDetailText(context, "Catatan FO",
                                detailData.value.foNote ?? ""),
                          ),
                        if (int.parse(prop.tipeId) == 1 ||
                            int.parse(prop.tipeId) == 2 ||
                            int.parse(prop.tipeId) == 3 ||
                            int.parse(prop.tipeId) == 4 ||
                            int.parse(prop.tipeId) == 5)
                          displayDetailText(context, "Catatan Admin",
                              detailData.value.adminNote ?? ""),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        if (int.parse(prop.tipeId) == 1 ||
                            int.parse(prop.tipeId) == 2 ||
                            int.parse(prop.tipeId) == 3)
                          Text(
                            "Pengambilan Hasil",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        if (int.parse(prop.tipeId) == 5)
                          Text(
                            "Pengambilan Bahan",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        if (int.parse(prop.tipeId) == 4)
                          Text(
                            "Pengirim",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Expanded(
                              child: Text(
                                "Alamat Pengambilan",
                                style: Constant.body1(context: context)
                                    .copyWith(
                                        fontWeight: FontWeight.w400,
                                        color: Constant.textPrimary),
                              ),
                            ),
                            Expanded(
                              child: Text(
                                ": ${detailData.value.alamatPengambilan}",
                                maxLines: 2,
                                overflow: TextOverflow.ellipsis,
                                style: Constant.body1(context: context)
                                    .copyWith(
                                        fontWeight: FontWeight.w400,
                                        color: Constant.textPrimary),
                              ),
                            )
                          ],
                        ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                if (pengambilanAwalLoc.value["lat"] == "" ||
                                    pengambilanAwalLoc.value['long'] == "")
                                  Icon(Icons.location_on,
                                      color: Constant.primaryBlue),
                                if (pengambilanAwalLoc.value["lat"] == "" ||
                                    pengambilanAwalLoc.value['long'] == "")
                                  SizedBox(
                                    width: Constant.getActualX(
                                        context: context, x: 4),
                                  ),
                                Text(
                                  "Lokasi Awal",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                )
                              ],
                            ),
                            if (pengambilanAwalLoc.value["lat"] != "" ||
                                pengambilanAwalLoc.value['long'] != "")
                              InkWell(
                                onTap: () {
                                  MapsLauncher.launchCoordinates(
                                      double.parse(
                                          pengambilanAwalLoc.value["lat"]!),
                                      double.parse(
                                          pengambilanAwalLoc.value["long"]!));
                                },
                                child: Row(
                                  children: [
                                    Text(
                                      "Sudah ditandai",
                                      style: Constant.body1(context: context)
                                          .copyWith(
                                              fontWeight: FontWeight.w600,
                                              color: Constant.primaryBlue),
                                    ),
                                    SizedBox(
                                      width: Constant.getActualX(
                                          context: context, x: 4),
                                    ),
                                    Icon(
                                      Icons.map_outlined,
                                      color: Constant.primaryBlue,
                                    ),
                                  ],
                                ),
                              ),
                          ],
                        ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                if (pengambilanAkhirLoc.value["lat"] == "" ||
                                    pengambilanAkhirLoc.value['long'] == "")
                                  Icon(
                                    Icons.location_on,
                                    color: Constant.primaryBlue,
                                  ),
                                if (pengambilanAkhirLoc.value["lat"] == "" ||
                                    pengambilanAkhirLoc.value['long'] == "")
                                  SizedBox(
                                    width: Constant.getActualX(
                                        context: context, x: 4),
                                  ),
                                Text(
                                  "Lokasi Akhir",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                )
                              ],
                            ),
                            if (pengambilanAkhirLoc.value["lat"] != "" ||
                                pengambilanAkhirLoc.value['long'] != "")
                              InkWell(
                                onTap: () {
                                  MapsLauncher.launchCoordinates(
                                      double.parse(
                                          pengambilanAkhirLoc.value["lat"]!),
                                      double.parse(
                                          pengambilanAkhirLoc.value["long"]!));
                                },
                                child: Row(
                                  children: [
                                    Text(
                                      "Sudah ditandai",
                                      style: Constant.body1(context: context)
                                          .copyWith(
                                              fontWeight: FontWeight.w600,
                                              color: Constant.primaryBlue),
                                    ),
                                    SizedBox(
                                      width: Constant.getActualX(
                                          context: context, x: 4),
                                    ),
                                    Icon(
                                      Icons.map_outlined,
                                      color: Constant.primaryBlue,
                                    ),
                                  ],
                                ),
                              ),
                          ],
                        ),
                        if (petugasPengambilan.value.isNotEmpty ||
                            catatanPengambilan.value.isNotEmpty)
                          SizedBox(
                            height:
                                Constant.getActualY(context: context, y: 12),
                          ),
                        if (petugasPengambilan.value.isNotEmpty ||
                            catatanPengambilan.value.isNotEmpty)
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Expanded(
                                child: Text(
                                  "Petugas Penyerahan",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              ),
                              Expanded(
                                child: Text(
                                  " : ${petugasPengambilan.value}",
                                  maxLines: 2,
                                  overflow: TextOverflow.ellipsis,
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              )
                            ],
                          ),
                        if (petugasPengambilan.value.isNotEmpty ||
                            catatanPengambilan.value.isNotEmpty)
                          SizedBox(
                            height:
                                Constant.getActualY(context: context, y: 12),
                          ),
                        if (petugasPengambilan.value.isNotEmpty ||
                            catatanPengambilan.value.isNotEmpty)
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Expanded(
                                child: Text(
                                  "Catatan",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              ),
                              Expanded(
                                child: Text(
                                  " : ${catatanPengambilan.value} ",
                                  overflow: TextOverflow.visible,
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              )
                            ],
                          ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        if (int.parse(prop.tipeId) == 1 ||
                            int.parse(prop.tipeId) == 2 ||
                            int.parse(prop.tipeId) == 3)
                          Text(
                            "Pengantaran Hasil",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        if (int.parse(prop.tipeId) == 5)
                          Text(
                            "Pengantaran Bahan",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        if (int.parse(prop.tipeId) == 4)
                          Text(
                            "Penerima",
                            // maxLines: 5,
                            overflow: TextOverflow.visible,
                            style: Constant.body1(context: context).copyWith(
                                fontWeight: FontWeight.w600,
                                color: Constant.textPrimary),
                          ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Expanded(
                              child: Text(
                                "Alamat Pengantaran",
                                style: Constant.body1(context: context)
                                    .copyWith(
                                        fontWeight: FontWeight.w400,
                                        color: Constant.textPrimary),
                              ),
                            ),
                            Expanded(
                              child: Text(
                                ": ${detailData.value.alamatPengantaran}",
                                maxLines: 2,
                                overflow: TextOverflow.ellipsis,
                                style: Constant.body1(context: context)
                                    .copyWith(
                                        fontWeight: FontWeight.w400,
                                        color: Constant.textPrimary),
                              ),
                            )
                          ],
                        ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                if (pengantaranAwalLoc.value["lat"] == "" ||
                                    pengantaranAwalLoc.value['long'] == "")
                                  Icon(
                                    Icons.location_on,
                                    color: Constant.primaryBlue,
                                  ),
                                if (pengantaranAwalLoc.value["lat"] == "" ||
                                    pengantaranAwalLoc.value['long'] == "")
                                  SizedBox(
                                    width: Constant.getActualX(
                                        context: context, x: 4),
                                  ),
                                Text(
                                  "Lokasi Awal",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                )
                              ],
                            ),
                            if (pengantaranAwalLoc.value["lat"] != "" ||
                                pengantaranAwalLoc.value['long'] != "")
                              InkWell(
                                onTap: () {
                                  MapsLauncher.launchCoordinates(
                                      double.parse(
                                          pengantaranAwalLoc.value["lat"]!),
                                      double.parse(
                                          pengantaranAwalLoc.value["long"]!));
                                },
                                child: Row(
                                  children: [
                                    Text(
                                      "Sudah ditandai",
                                      style: Constant.body1(context: context)
                                          .copyWith(
                                              fontWeight: FontWeight.w600,
                                              color: Constant.primaryBlue),
                                    ),
                                    SizedBox(
                                      width: Constant.getActualX(
                                          context: context, x: 4),
                                    ),
                                    Icon(
                                      Icons.map_outlined,
                                      color: Constant.primaryBlue,
                                    ),
                                  ],
                                ),
                              ),
                          ],
                        ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 12),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                if (pengantaranAkhirLoc.value["lat"] == "" ||
                                    pengantaranAkhirLoc.value['long'] == "")
                                  Icon(
                                    Icons.location_on,
                                    color: Constant.primaryBlue,
                                  ),
                                if (pengantaranAkhirLoc.value["lat"] == "" ||
                                    pengantaranAkhirLoc.value['long'] == "")
                                  SizedBox(
                                    width: Constant.getActualX(
                                        context: context, x: 4),
                                  ),
                                Text(
                                  "Lokasi Akhir",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                )
                              ],
                            ),
                            if (pengantaranAkhirLoc.value["lat"] != "" ||
                                pengantaranAkhirLoc.value['long'] != "")
                              InkWell(
                                onTap: () {
                                  MapsLauncher.launchCoordinates(
                                      double.parse(
                                          pengantaranAkhirLoc.value["lat"]!),
                                      double.parse(
                                          pengantaranAkhirLoc.value["long"]!));
                                },
                                child: Row(
                                  children: [
                                    Text(
                                      "Sudah ditandai",
                                      style: Constant.body1(context: context)
                                          .copyWith(
                                              fontWeight: FontWeight.w600,
                                              color: Constant.primaryBlue),
                                    ),
                                    SizedBox(
                                      width: Constant.getActualX(
                                          context: context, x: 4),
                                    ),
                                    Icon(
                                      Icons.map_outlined,
                                      color: Constant.primaryBlue,
                                    ),
                                  ],
                                ),
                              ),
                          ],
                        ),
                        if (petugasPengantaran.value.isNotEmpty ||
                            catatanPengantaran.value.isNotEmpty)
                          SizedBox(
                            height:
                                Constant.getActualY(context: context, y: 12),
                          ),
                        if (petugasPengantaran.value.isNotEmpty ||
                            catatanPengantaran.value.isNotEmpty)
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Expanded(
                                child: Text(
                                  "Penerima",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              ),
                              Expanded(
                                child: Text(
                                  " : ${petugasPengantaran.value}",
                                  maxLines: 2,
                                  overflow: TextOverflow.ellipsis,
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              )
                            ],
                          ),
                        if (petugasPengantaran.value.isNotEmpty ||
                            catatanPengantaran.value.isNotEmpty)
                          SizedBox(
                            height:
                                Constant.getActualY(context: context, y: 12),
                          ),
                        if (petugasPengantaran.value.isNotEmpty ||
                            catatanPengantaran.value.isNotEmpty)
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Expanded(
                                child: Text(
                                  "Catatan",
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              ),
                              Expanded(
                                child: Text(
                                  " : ${catatanPengantaran.value} ",
                                  overflow: TextOverflow.visible,
                                  style: Constant.body1(context: context)
                                      .copyWith(
                                          fontWeight: FontWeight.w400,
                                          color: Constant.textPrimary),
                                ),
                              )
                            ],
                          ),
                        SizedBox(
                          height: Constant.getActualY(context: context, y: 14),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              "Total Jarak",
                              style: Constant.heading4(context: context)
                                  .copyWith(
                                      fontWeight: FontWeight.w600,
                                      color: Constant.textPrimary),
                            ),
                            Text(
                              " ${detailData.value.distance ?? ''} KM",
                              overflow: TextOverflow.visible,
                              style: Constant.heading3(context: context)
                                  .copyWith(
                                      fontWeight: FontWeight.w600,
                                      color: Constant.textPrimary),
                            )
                          ],
                        ),
                        if (detailData.value.patients != null)
                          ExpansionTile(
                            tilePadding: EdgeInsets.symmetric(horizontal: 0),
                            title: Text(
                              "List (${detailData.value.patients?.length} pasien)",
                              style: Constant.body1(context: context)
                                  .copyWith(fontWeight: FontWeight.w400),
                            ),
                            children: detailData.value.patients!
                                .map((e) => PatientCard(
                                      name: e.pasien.toString(),
                                      noLab: e.tOrderHeaderLabNumber.toString(),
                                      note: e.courierConfirmNote ?? "",
                                    ))
                                .toList(),
                          ),
                      ],
                    ),
                  ),
                ),
              )
            ]),
          );
  }

  Widget displayDetailText(BuildContext context, String teks, String value) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Expanded(
          child: Text(
            teks,
            style: Constant.heading4(context: context).copyWith(
                fontWeight: FontWeight.w600, color: Constant.textPrimary),
          ),
        ),
        Expanded(
          child: Text(
            " : ${value}",
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
            style: Constant.heading4(context: context).copyWith(
                fontWeight: FontWeight.w600, color: Constant.textPrimary),
          ),
        )
      ],
    );
  }

  Widget headerCard(
      BuildContext context, Color bgColor, String teks, Color textColor) {
    return Container(
      height: Constant.getActualY(context: context, y: 44),
      decoration:
          BoxDecoration(color: bgColor, borderRadius: BorderRadius.circular(8)),
      child: Align(
        child: Text(
          "${teks}",
          style: Constant.heading4(context: context)
              .copyWith(fontWeight: FontWeight.w600, color: textColor),
        ),
      ),
    );
  }
}
