import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/description.dart';
import 'package:aitrainer_app/util/app_language.dart';

import 'package:flutter/material.dart';

class DescriptionRepository {
  List<Description>? descriptions;

  DescriptionRepository() {
    this.descriptions = Cache().getDescriptions();
  }

  String getDescriptionByName(String name) {
    String descriptionText = "";
    if (descriptions != null) {
      this.descriptions!.forEach((element) {
        if (element.name == name) {
          if (AppLanguage().appLocal == Locale('en')) {
            descriptionText = element.description;
          } else {
            descriptionText = element.descriptionTranslation != null ? element.descriptionTranslation! : element.description;
          }
        }
      });
    }
    return descriptionText;
  }
}
