mirrored_repositories/Expenses_Tracker_App/lib/utils
import 'package:expense_repository/expense_repository.dart';
import 'package:flutter/material.dart';

class EHelperFunctions {
// Ekranlar arasında gezinmeyi sağlayan fonksiyon
  static void navigateToScreen(BuildContext context, Widget screen) {
    Navigator.push(
      context,
      MaterialPageRoute(builder: (_) => screen),
    );
  }

// Tema modunun dark mı yoksa light mı olduğunu kontrol eden fonksiyon
  static bool isDarkMode(BuildContext context) {
    return Theme.of(context).brightness == Brightness.dark;
  }

  static double calculateTotalBalance(double totalIncome, double totalExpense) {
    return totalIncome - totalExpense;
  }

  static double calculateTotal1(
      List<Expense> expenses, String type, String currency) {
    double total = 0;
    for (var expense in expenses) {
      if (expense.howExpense == type && expense.currency == currency) {
        total += double.parse(expense.amount.toString());
      }
    }
    return total;
  }

  static double calculateTotalIncomeByCurrency(
      List<Expense> expenses, String currency) {
    return calculateTotal1(expenses, "Income", currency);
  }

  static double calculateTotalExpenseByCurrency(
      List<Expense> expenses, String currency) {
    return calculateTotal1(expenses, "Expense", currency);
  }

  static double screenHeight(BuildContext context) {
    return MediaQuery.of(context).size.height;
  }

  static double screenWidth(BuildContext context) {
    return MediaQuery.of(context).size.width;
  }
}
