import 'package:flutter/widgets.dart';

import 'package:pweb/models/state/visibility.dart';


class PaymentPageUiController extends ChangeNotifier {
  final TextEditingController searchController = TextEditingController();
  final FocusNode searchFocusNode = FocusNode();

  String _query = '';
  VisibilityState _paymentDetailsVisibility = VisibilityState.hidden;

  String get query => _query;
  VisibilityState get paymentDetailsVisibility => _paymentDetailsVisibility;

  void setQuery(String query) {
    if (_query == query) return;
    _query = query;
    notifyListeners();
  }

  void clearSearch() {
    if (searchController.text.isNotEmpty) {
      searchController.clear();
    }
    searchFocusNode.unfocus();
    setQuery('');
  }

  void togglePaymentDetails() {
    _paymentDetailsVisibility = _paymentDetailsVisibility == VisibilityState.visible
        ? VisibilityState.hidden
        : VisibilityState.visible;
    notifyListeners();
  }

  @override
  void dispose() {
    searchController.dispose();
    searchFocusNode.dispose();
    super.dispose();
  }
}
