

import 'package:flutter/material.dart';

class UtilsHAW {
  static String dayToMonthString(double value) {
    switch (value.toInt()) {
      case 0:
        return 'Lu';
      case 1:
        return 'Ma';
      case 2:
        return 'Mi';
      case 3:
        return 'Ju';
      case 4:
        return 'Vi';
      case 5:
        return 'Sá';
      case 6:
        return 'Do';
      default:
        return '';
    }
  }

  static ImageProvider<dynamic> creditCardImage(String lowerCasedBrand) {
    try {
      if(lowerCasedBrand=="unknown") return AssetImage("assets/credit-cards/unknown.png");
      else return AssetImage("assets/credit-cards/$lowerCasedBrand.jpg");
    } on Exception catch(e) {
      return AssetImage("assets/credit-cards/unknown.png");
    }
  }

  static final STRIPE_SCA_URL = "stripesdk://3ds.stripesdkhaw.io"; //ha de ser la mateixa al gradle i al Info.plist


  static String daysToStringPeriod(int days) {
    switch(days) {
      case 15:
        return "Quinzenal";
        break;
      case 30: 
        return "Mensual";
        break;
      case 60:
        return "Bimensual";
        break;
      case 90: 
        return "Trimestral";
        break;
      case 180:
        return "Semestral";
        break;
      case 365:
        return "Anual";
        break;
    }

    if(days<30) return "$days días";
    else return "${(days/30).toInt()} meses";
  }

  static String paymentTypeSlugToString(String slug)  {
    switch(slug) {
      case 'cash':
        return "Efectivo";
        break;
      case 'stripe':
        return "Tarjeta";
        break;
      default:
        return 'No identificado';
        break;
    }
  }
  
  static String dateToCronoTime(DateTime date) {
    return ((date.hour<10 ? "0"+date.hour.toString() : date.hour.toString()) +  ":" + (date.minute<10 ? "0"+date.minute.toString() : date.minute.toString()) +  ":" + (date.second<10 ? "0"+date.second.toString() : date.second.toString()));
  }
}
