import 'package:didvan/config/theme_data.dart';
import 'package:didvan/main.dart';
import 'package:didvan/providers/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';

class DesignConfig {
  static BuildContext? get context => navigatorKey.currentContext;

  static const BorderRadius lowBorderRadius = BorderRadius.all(
    Radius.circular(8),
  );
  static const BorderRadius mediumBorderRadius = BorderRadius.all(
    Radius.circular(10),
  );
  static const BorderRadius highBorderRadius = BorderRadius.all(
    Radius.circular(16),
  );

  static Border get cardBorder => Border.all(
        color: Theme.of(context!).colorScheme.cardBorder,
        width: 0.5,
      );

  static List<BoxShadow> get defaultShadow => [
        BoxShadow(
          color: const Color(0XFF1B3C59).withValues(alpha: 0.25),
          blurRadius: 16,
          spreadRadius: 0,
        )
      ];

  static String get fontFamily => context!.read<ThemeProvider>().fontFamily;
  static double get fontScale => context!.read<ThemeProvider>().fontScale;

  static Brightness get brightness => Theme.of(context!).brightness;
  static bool get isDark => brightness == Brightness.dark;

  static const Duration lowAnimationDuration = Duration(milliseconds: 300);
  static const Duration mediumAnimationDuration = Duration(milliseconds: 350);

  static SystemUiOverlayStyle get systemUiOverlayStyle => SystemUiOverlayStyle(
        statusBarIconBrightness:
            brightness == Brightness.dark ? Brightness.light : Brightness.dark,
        statusBarColor: Theme.of(context!).colorScheme.surface,
        systemNavigationBarColor: Theme.of(context!).colorScheme.surface,
        systemNavigationBarDividerColor: Colors.transparent,
        systemNavigationBarIconBrightness:
            brightness == Brightness.dark ? Brightness.light : Brightness.dark,
      );

  static void updateSystemUiOverlayStyle() {
    Future.delayed(
      DesignConfig.lowAnimationDuration,
      () => SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle),
    );
  }
}
