

import 'package:flutter/material.dart';
import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_widget.dart';
import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
import 'package:hub/pages/liberation_history/liberation_history_model.dart';

class AcessHistoryPageModel extends FlutterFlowModel<AcessHistoryPageWidget> {
  final unfocusNode = FocusNode();
  final _accessHistoryManager = StreamRequestManager<ApiCallResponse>();
  Stream<ApiCallResponse> accessHistory({
    String? uniqueQueryKey,
    bool? overrideCache,
    required Stream<ApiCallResponse> Function() requestFn,
  }) =>
      _accessHistoryManager.performRequest(
        uniqueQueryKey: uniqueQueryKey,
        overrideCache: overrideCache,
        requestFn: requestFn,
      );
  void clearAccessHistoryCache() => _accessHistoryManager.clear();
  void clearAccessHistoryCacheKey(String? uniqueKey) =>
      _accessHistoryManager.clearRequest(uniqueKey);

  @override
  void initState(BuildContext context) {}

  @override
  void dispose() {
    unfocusNode.dispose();

    /// Dispose query cache managers for this widget.

    clearAccessHistoryCache();
  }

  Future toggleOptionsAction(BuildContext context) async {
    await showModalBottomSheet(
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
      useSafeArea: true,
      context: context,
      builder: (context) {
        return GestureDetector(
          onTap: () => unfocusNode.canRequestFocus
              ? FocusScope.of(context).requestFocus(unfocusNode)
              : FocusScope.of(context).unfocus(),
          child: Padding(
            padding: MediaQuery.viewInsetsOf(context),
            child: const OptModalWidget(),
          ),
        );
      },
    );
  }
}