import 'package:flutter/material.dart';

final ThemeData myTheme = ThemeData(
    colorScheme: ColorScheme.fromSeed(
        seedColor: getMaterialColor(const Color(0x007d85ff))));

ThemeData getThemeData(Color color, bool dark) {
  final MaterialColor materialColor = getMaterialColor(color);
  return ThemeData(
    colorScheme: ColorScheme.fromSeed(
      seedColor: materialColor,
      brightness: dark ? Brightness.dark : Brightness.light,
    ).copyWith(
      onPrimary: dark ? materialColor[600] : Colors.white,
    ),
    useMaterial3: true,
  );
}

MaterialColor getMaterialColor(Color color) {
  final int red = color.red;
  final int green = color.green;
  final int blue = color.blue;

  final Map<int, Color> shades = {
    50: Color.fromRGBO(red, green, blue, .1),
    100: Color.fromRGBO(red, green, blue, .2),
    200: Color.fromRGBO(red, green, blue, .3),
    300: Color.fromRGBO(red, green, blue, .4),
    400: Color.fromRGBO(red, green, blue, .5),
    500: Color.fromRGBO(red, green, blue, .6),
    600: Color.fromRGBO(red, green, blue, .7),
    700: Color.fromRGBO(red, green, blue, .8),
    800: Color.fromRGBO(red, green, blue, .9),
    900: Color.fromRGBO(red, green, blue, 1),
  };

  return MaterialColor(color.value, shades);
}
