import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../i18n/app_localizations.dart';

/// TDesign 组件国际化资源代理
///
/// 将 [TDResourceDelegate] 的 63 个文本 getter 映射到 [AppLocalizations]，
/// 实现 TDesign 组件文本随应用语言切换。
///
/// 在 [MaterialApp] 初始化后注册：
/// ```dart
/// TDTheme.setResourceBuilder(
///   (context) => TDResourceI18nDelegate(context),
///   needAlwaysBuild: true,
/// );
/// ```
class TDResourceI18nDelegate extends TDResourceDelegate {
  final BuildContext context;

  TDResourceI18nDelegate(this.context);

  AppLocalizations get l10n => AppLocalizations.of(context);

  // ── TDSwitch ──
  @override
  String get open => l10n.get('tdOpen');

  @override
  String get close => l10n.get('tdClose');

  // ── TDBadge ──
  @override
  String get badgeZero => '0';

  // ── TDAlertDialog / TDPicker ──
  @override
  String get cancel => l10n.get('tdCancel');

  @override
  String get confirm => l10n.get('tdConfirm');

  @override
  String get other => l10n.get('tdOther');

  @override
  String get reset => l10n.get('tdReset');

  // ── TDLoading ──
  @override
  String get loading => l10n.get('tdLoading');

  @override
  String get loadingWithPoint => l10n.get('tdLoadingWithPoint');

  // ── TDConfirmDialog ──
  @override
  String get knew => l10n.get('tdKnew');

  // ── TDRefreshHeader ──
  @override
  String get refreshing => l10n.get('tdRefreshing');

  @override
  String get releaseRefresh => l10n.get('tdReleaseRefresh');

  @override
  String get pullToRefresh => l10n.get('tdPullToRefresh');

  @override
  String get completeRefresh => l10n.get('tdCompleteRefresh');

  // ── TDTimeCounter ──
  @override
  String get days => l10n.get('tdDays');

  @override
  String get hours => l10n.get('tdHours');

  @override
  String get minutes => l10n.get('tdMinutes');

  @override
  String get seconds => l10n.get('tdSeconds');

  @override
  String get milliseconds => l10n.get('tdMilliseconds');

  // ── TDDatePicker ──
  @override
  String get yearLabel => l10n.get('tdYearLabel');

  @override
  String get monthLabel => l10n.get('tdMonthLabel');

  @override
  String get dateLabel => l10n.get('tdDateLabel');

  @override
  String get weeksLabel => l10n.get('tdWeeksLabel');

  // ── TDCalendarHeader 星期 ──
  @override
  String get sunday => l10n.get('tdSunday');

  @override
  String get monday => l10n.get('tdMonday');

  @override
  String get tuesday => l10n.get('tdTuesday');

  @override
  String get wednesday => l10n.get('tdWednesday');

  @override
  String get thursday => l10n.get('tdThursday');

  @override
  String get friday => l10n.get('tdFriday');

  @override
  String get saturday => l10n.get('tdSaturday');

  // ── TDCalendar 月份 ──
  @override
  String get year => l10n.get('tdYear');

  @override
  String get january => l10n.get('tdJanuary');

  @override
  String get february => l10n.get('tdFebruary');

  @override
  String get march => l10n.get('tdMarch');

  @override
  String get april => l10n.get('tdApril');

  @override
  String get may => l10n.get('tdMay');

  @override
  String get june => l10n.get('tdJune');

  @override
  String get july => l10n.get('tdJuly');

  @override
  String get august => l10n.get('tdAugust');

  @override
  String get september => l10n.get('tdSeptember');

  @override
  String get october => l10n.get('tdOctober');

  @override
  String get november => l10n.get('tdNovember');

  @override
  String get december => l10n.get('tdDecember');

  // ── TDCalendar 时间选择 ──
  @override
  String get time => l10n.get('tdTime');

  @override
  String get start => l10n.get('tdStart');

  @override
  String get end => l10n.get('tdEnd');

  // ── TDRate ──
  @override
  String get notRated => l10n.get('tdNotRated');

  // ── TDCascader ──
  @override
  String get cascadeLabel => l10n.get('tdCascadeLabel');

  // ── TDBackTop ──
  @override
  String get back => l10n.get('tdBack');

  @override
  String get top => l10n.get('tdTop');

  // ── TDTable / TDEmpty ──
  @override
  String get emptyData => l10n.get('tdEmptyData');
}
