import 'package:flutter/material.dart';
import 'app_localizations_de.dart';
import 'app_localizations_en.dart';
import 'app_localizations_es.dart';
import 'app_localizations_fr.dart';
import 'app_localizations_pl.dart';
import 'app_localizations_ru.dart';
import 'app_localizations_tr.dart';
import 'app_localizations_et.dart';
import 'app_localizations_lv.dart';
import 'app_localizations_lt.dart';

/// Supported language codes
const List<String> supportedLanguageCodes = [
  'de',
  'en',
  'es',
  'fr',
  'pl',
  'ru',
  'tr',
  'et',
  'lv',
  'lt',
];

/// AppLocalizations provides localized strings for the app
abstract class AppLocalizations {
  static AppLocalizations of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations) ??
        AppLocalizationsDe();
  }

  static const LocalizationsDelegate<AppLocalizations> delegate =
      _AppLocalizationsDelegate();

  /// Language name
  String get languageName;

  /// Flag emoji
  String get flagEmoji;

  // ==================== GENERAL ====================
  String get appTitle;
  String get ok;
  String get cancel;
  String get save;
  String get delete;
  String get close;
  String get confirm;
  String get error;
  String get success;
  String get loading;
  String get refresh;
  String get version;
  String get unknown;
  String get yesterday;

  // ==================== NAVIGATION ====================
  String get jobs;
  String get availableJobs;
  String get chats;
  String get settings;
  String get logout;
  String get logoutConfirm;
  String get logoutConfirmMessage;
  String get openChat;
  String get chatInfo;
  String get routePlan;

  // ==================== LOGIN ====================
  String get welcomeBack;
  String get loginSubtitle;
  String get email;
  String get emailAddress;
  String get emailAddressHint;
  String get emailAddressRequired;
  String get emailAddressInvalid;
  String get password;
  String get passwordHint;
  String get passwordRequired;
  String get passwordMinLength;
  String get login;
  String get loggingIn;
  String get forgotPassword;
  String get forgotPasswordMessage;
  String get loginSuccess;
  String get loginFailed;
  String get connectionFailed;
  String get connectionTimeout;
  String get connecting;
  String get connectionError;
  String get loginError;

  // ==================== JOBS ====================
  String get noJobsAssigned;
  String get noJobsMessage;
  String get pullToRefresh;
  String get newLabel;
  String get tasksToComplete;
  String get pickup;
  String get delivery;
  String get created;
  String get status;
  String get priority;
  String get dueDate;
  String get location;
  String get description;
  String get cargo;
  String get quantity;
  String get weight;
  String get dimensions;
  String get jobDeleted;
  String get jobDeleteError;
  String get jobCompleted;
  String get from;
  String get to;
  String get jobsUpdated;
  String get connectionRestored;
  String get connectionLost;
  String get offline;
  String get deleteJob;
  String get jobRemoved;
  String get newJobReceived;
  String get jobDetails;
  String get jobTasks;
  String get deliveryStations;
  String deliveryStationsCount(int count);
  String get noDeliveryStations;
  String get noDeliveryStationsMessage;
  String get phone;
  String get unnamedStation;
  String stationNumber(int number);

  // ==================== TASKS ====================
  String get tasks;
  String get noTasks;
  String get noTasksMessage;
  String get taskOrder;
  String get confirmationRequired;
  String get confirmationDescription;
  String get checklist;
  String get checklistDescription;
  String get completeTask;
  String get completeTaskConfirm;
  String get completeTaskNote;
  String get taskCompleted;
  String get comment;
  String get commentRequired;
  String get enterComment;
  String get commentDescription;
  String get finish;
  String get signature;
  String get signatureCapture;
  String get signatureRequired;
  String get clear;
  String get signatureError;
  String get signatureInstruction;
  String get photoCapture;
  String get requiredPhotos;
  String get photosTaken;
  String get photos;
  String get takePhoto;
  String get selectFromLibrary;
  String get retakePhoto;
  String get photoRequired;
  String get minPhotos;
  String get maxPhotos;
  String get photoError;
  String get deletePhoto;
  String get deletePhotoConfirm;
  String get barcode;
  String get barcodeScan;
  String get scanBarcode;
  String get barcodeRequired;
  String get minBarcodes;
  String get maxBarcodes;
  String get scanned;
  String get scannedBarcodes;
  String get barcodesRequired;
  String get enterBarcode;
  String get barcodeEnterDescription;
  String barcodeNumberRequired(int number);
  String barcodeNumberOptional(int number);
  String get barcodeError;
  String get cameraError;
  String get cameraNotReady;
  String get cameraNotAvailable;
  String get cameraNotSupportedMessage;
  String get cameraNotSupportedOnPlatform;
  String get maxPhotosReached;
  String get cameraReadyNoPreview;
  String get cameraLoading;
  String get cameraInitializing;
  String get cameraLoadingMessage;
  String get addPhotos;
  String get addPhotosInstruction;
  String get photoOf;

  // ==================== CHAT ====================
  String get typeMessage;
  String get send;
  String get noSender;
  String get noSenderMessage;
  String get noRecipient;
  String get noRecipientMessage;
  String get messageSendError;
  String get photoSendError;
  String get photoProcessError;
  String get imageSendError;
  String get chatTypeJob;
  String get chatTypeGeneral;
  String get jobNumber;
  String get messages;
  String get generalMessages;
  String get noMessagesYet;
  String get noChatsAvailable;
  String get selectPhoto;
  String get unreadMessages;

  // ==================== CARGO ====================
  String get cargoDetails;
  String get itemName;
  String get itemNumber;
  String get item;
  String get weightUnit;
  String get dimensionUnit;
  String get noCargoItems;
  String get noCargoItemsMessage;
  String get article;

  // ==================== TASK TYPES ====================
  String get takePhotos;
  String get photosCount;
  String get checklistPoints;
  String get signatureRequiredText;
  String get scanBarcodes;
  String get barcodeCount;
  String get commentOptional;
  String get genericTask;
  String get complete;
  String get abort;
  String get optional;
  String get skipTask;

  // ==================== SETTINGS ====================
  String get language;
  String get languageChanged;
  String get appInfo;

  // ==================== STATUS ====================
  String get statusCreated;
  String get statusPending;
  String get statusAssigned;
  String get statusInProgress;
  String get statusCompleted;
  String get statusCancelled;
  String get statusFailed;
  String get priorityLow;
  String get priorityMedium;
  String get priorityHigh;
  String get priorityUrgent;
}

class _AppLocalizationsDelegate
    extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) {
    return supportedLanguageCodes.contains(locale.languageCode);
  }

  @override
  Future<AppLocalizations> load(Locale locale) async {
    switch (locale.languageCode) {
      case 'de':
        return AppLocalizationsDe();
      case 'en':
        return AppLocalizationsEn();
      case 'es':
        return AppLocalizationsEs();
      case 'fr':
        return AppLocalizationsFr();
      case 'pl':
        return AppLocalizationsPl();
      case 'ru':
        return AppLocalizationsRu();
      case 'tr':
        return AppLocalizationsTr();
      case 'et':
        return AppLocalizationsEt();
      case 'lv':
        return AppLocalizationsLv();
      case 'lt':
        return AppLocalizationsLt();
      default:
        return AppLocalizationsDe();
    }
  }

  @override
  bool shouldReload(LocalizationsDelegate<AppLocalizations> old) => false;
}
