import 'package:flutter/material.dart';
import 'package:flutter_custom_clippers/flutter_custom_clippers.dart';
import 'package:get/get.dart';
import 'package:uco_mobile_poc/app/core/constants/translation_keys.dart';
import 'package:uco_mobile_poc/app/core/utils/logs_utils.dart';
import 'package:uco_mobile_poc/app/custom_widgets/Fields/input_field.dart';
import 'package:uco_mobile_poc/app/custom_widgets/custom_button.dart';
import 'package:uco_mobile_poc/app/custom_widgets/custom_dialog.dart';
import 'package:uco_mobile_poc/app/custom_widgets/date_picker.dart';
import 'package:uco_mobile_poc/app/res/app_colors.dart';
import 'package:uco_mobile_poc/app/res/app_dimensions.dart';
import 'package:uco_mobile_poc/app/routes/app_pages.dart';

import '../../../core/utils/SessionCache.dart';
import '../../../custom_widgets/custom_dropdown.dart';
import '../../../models/DepositAccountResponse.dart';

class NotificationsController extends GetxController {
  RxString selectedAccountNumber = '123456789'.obs;
  RxBool isExpanded = false.obs;
  bool isCredit = false;

  RxList<DropDown> allDepositAccounts = RxList.empty();

  Rx<DepositAccount> selectedDepositAccount = DepositAccount.empty().obs;

  List<String> accountNumberList = ["123456789"];

  List<NotificationDetails> notificationList = [
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
    NotificationDetails(
        description:
            "Rs. 1320.0 sent to SHAHZAD AHMED with easypaisa account....",
        dateTime: "12 Apr 2023  07:57:28 am"),
  ];

  late InputField depositAccountField;

  @override
  void onInit() {
    //

    for (int i = 0; i < SessionCache.instance.depositAccountList.length; i++) {
      DepositAccount depositAccount =
          SessionCache.instance.depositAccountList.elementAt(i);

      allDepositAccounts.add(
        DropDown(
            i.toString(),
            "${depositAccount.mbmBkmstitle} - ${depositAccount.mbmBkmsnumber}",
            depositAccount),
      );
    }

    selectedDepositAccount.value = allDepositAccounts.first.data;

    super.onInit();
  }

  void updateSelectedDeposit(DropDown item) {
    selectedDepositAccount.value = item.data as DepositAccount;
  }

  void showDialogFunction(BuildContext context) {
    CustomDialog.showInfoDialog(
        title: TranslationKeys.makeTranslation(
            TranslationKeys.textNotificationDetails),
        description: TranslationKeys.makeTranslation(
            TranslationKeys.textNotificationDetailsContent),
        onTapPositive: () {
          Navigator.of(context, rootNavigator: true).pop();
        });
  }

  void showDateRangePicker() async {
    var date = await DatePicker.showRangeDatePicker();
    dp("Date is ", date);
  }
}

class NotificationDetails {
  String description;
  String dateTime;

  NotificationDetails({required this.description, required this.dateTime});
}
