

import 'package:flutter/material.dart';
import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';

class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
  final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
  Future<ApiCallResponse> visitHistory({
    String? uniqueQueryKey,
    bool? overrideCache,
    required Future<ApiCallResponse> Function() requestFn,
  }) =>
      _visitHistoryManager.performRequest(
        uniqueQueryKey: uniqueQueryKey,
        overrideCache: overrideCache,
        requestFn: requestFn,
      );
  void clearVisitHistoryCache() => _visitHistoryManager.clear();
  void clearVisitHistoryCacheKey(String? uniqueKey) =>
      _visitHistoryManager.clearRequest(uniqueKey);

  ///  Local state fields for this page.

  List<dynamic> visitorJsonList = [];
  void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item);
  void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item);
  void removeAtIndexFromVisitorJsonList(int index) =>
      visitorJsonList.removeAt(index);
  void insertAtIndexInVisitorJsonList(int index, dynamic item) =>
      visitorJsonList.insert(index, item);
  void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) =>
      visitorJsonList[index] = updateFn(visitorJsonList[index]);

  String visitorStrList = '0';

  ///  State fields for stateful widgets in this page.

  final unfocusNode = FocusNode();
  // State field(s) for TabBar widget.
  TabController? tabBarController;
  int get tabBarCurrentIndex =>
      tabBarController != null ? tabBarController!.index : 0;

  // State field(s) for TextField widget.
  FocusNode? textFieldFocusNode1;
  TextEditingController? textController1;
  String? Function(BuildContext, String?)? textController1Validator;
  DateTime? datePicked1;
  // State field(s) for TextField widget.
  FocusNode? textFieldFocusNode2;
  TextEditingController? textController2;
  String? Function(BuildContext, String?)? textController2Validator;
  DateTime? datePicked2;
  // State field(s) for DropDown widget.
  String? dropDownValue1;
  FormFieldController<String>? dropDownValueController1;
  // State field(s) for DropDown widget.
  String? dropDownValue2;
  FormFieldController<String>? dropDownValueController2;
  // State field(s) for Switch widget.
  bool? switchValue;
  // State field(s) for TextField widget.
  FocusNode? textFieldFocusNode3;
  TextEditingController? textController3;
  String? Function(BuildContext, String?)? textController3Validator;

  @override
  void initState(BuildContext context) {}

  @override
  void dispose() {
    unfocusNode.dispose();
    tabBarController?.dispose();
    textFieldFocusNode1?.dispose();
    textController1?.dispose();

    textFieldFocusNode2?.dispose();
    textController2?.dispose();

    textFieldFocusNode3?.dispose();
    textController3?.dispose();

    clearVisitHistoryCache();
  }

  /// Action blocks.
  Future getVisitorsActionPage(
    BuildContext context, {
    List<dynamic>? visitorsJsonList,
  }) async {
    visitorJsonList = visitorsJsonList!.toList().cast<dynamic>();
  }

  Future<bool> toggleCurrentSelectionHeader(
    BuildContext context, {
    required bool? toggleIndexValue,
  }) async {
    if (toggleIndexValue == true) {
      return true;
    }

    return false;
  }
}