import 'package:flutter/material.dart';
import '../../router/app_routes.dart';
import '../entity/name/name_entity.dart';
import '../models/name.dart';

class Functions {
  static String getTranslatedItem(NameEntity? name, BuildContext context) {
    var local = Localizations.localeOf(context);
    switch (local.languageCode) {
      case 'uz':
        {
          return name?.uz ?? " ";
        }
      case "ru":
        {
          return name?.ru ?? " ";
        }
      case "zh":
        {
          return name?.zh ?? " ";
        }
      default:
        {
          return name?.uz ?? " ";
        }
    }
  }

  static String getTranslatedNameModel(Name? name, BuildContext context) {
    var local = Localizations.localeOf(context);
    switch (local.languageCode) {
      case 'uz':
        {
          return name?.uz ?? " ";
        }
      case "ru":
        {
          return name?.ru ?? " ";
        }
      case "zh":
        {
          return name?.zh ?? " ";
        }
      default:
        {
          return name?.uz ?? " ";
        }
    }
  }
  static void showErrorSnackBar(String message) {
    final snackBar = SnackBar(
      backgroundColor: Colors.red,
      content: Row(
        children: [
          const Icon(Icons.error, color: Colors.white),
          const SizedBox(width: 8),
          Expanded(
            child: Text(
              message,
              style: const TextStyle(color: Colors.white),
            ),
          ),
        ],
      ),
      behavior: SnackBarBehavior.floating,
      duration: const Duration(seconds: 3),
    );

    ScaffoldMessenger.of(
      rootNavigatorKey.currentContext!,
    ).showSnackBar(snackBar);
  }
}
