import 'dart:ui';
import 'package:design_system/design_system.dart';
import 'package:get_it/get_it.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final GetIt getIt = GetIt.instance;

void themePackages() {
  getIt.registerSingleton<ThemePort>(ThemeSfAdapter());
}

final themePortProvider = Provider<ThemePort>((ref) => getIt<ThemePort>());

enum ThemeCode {
  backgroundPrimary,
  backgroundSecondary,
  backgroundTertiary,
  textPrimary,
  textSecondary,
  textTertiary,
  buttonPrimary,
  buttonSecondary,
}

abstract class ThemePort {
  late Map<ThemeCode, Color> theme;
  late List<List<Color>> cardColors;

  Color getColorFor(ThemeCode code) {
    Color? c = theme[code];
    if (c == null) {
      throw Exception("Theme key not found");
    }
    return c;
  }

  List<Color> getCardColorFor(int index) {
    return cardColors[index % cardColors.length];
  }
}
