getNewThemeParams function

Map<String, dynamic> getNewThemeParams(
  1. Map<String, dynamic> tp
)

Implementation

Map<String, dynamic> getNewThemeParams(Map<String, dynamic> tp) {
  Map<String, dynamic> newTp = Map<String, dynamic>.from(tp);

  newTp['accentColor'] = tp['accentColor'] ?? accentColor;
  newTp['accentForegroundColor'] = tp['accentForegroundColor'] ?? Colors.white;

  newTp['borderRadius'] = ((tp['borderRadius'] ?? borderRadius) as num)
      .toDouble();

  newTp['textColor'] = tp['textColor'] ?? textColor;

  newTp['separatorColor'] = tp['separatorColor'] ?? separatorColor;
  newTp['separatorWidth'] = tp['separatorWidth'] ?? separatorWidth;

  newTp['scaffoldBackgroundColor'] =
      tp['scaffoldBackgroundColor'] ?? scaffoldBackgroundColor;

  newTp['errorBackgroundColor'] =
      tp['errorBackgroundColor'] ?? errorBackgroundColor;

  newTp['appBarBackgroundColor'] =
      tp['appBarBackgroundColor'] ?? appBarBackgroundColor;
  newTp['appBarForegroundColor'] =
      tp['appBarForegroundColor'] ?? appBarForegroundColor;

  newTp['secondaryTextColor'] = tp['secondaryTextColor'] ?? secondaryTextColor;

  newTp['drawerBackgroundColor'] =
      tp['drawerBackgroundColor'] ?? drawerBackgroundColor;
  newTp['drawerForegroundColor'] =
      tp['drawerForegroundColor'] ?? drawerForegroundColor;

  newTp['focusedBorderWidth'] = ((tp['focusedBorderWidth'] ?? 2) as num)
      .toDouble();

  newTp['contentPaddingHorizontal'] =
      ((tp['contentPaddingHorizontal'] ?? 12) as num).toDouble();
  newTp['contentPaddingVertical'] =
      ((tp['contentPaddingVertical'] ?? 12) as num).toDouble();

  newTp['shadColorSchemeName'] =
      tp['shadColorSchemeName'] ?? shadColorSchemeName;
  newTp['neutralSurfaceColor'] =
      tp['neutralSurfaceColor'] ?? neutralSurfaceColor;
  newTp['errorForegroundColor'] =
      tp['errorForegroundColor'] ?? errorForegroundColor;

  final BorderRadius corners = BorderRadius.circular(newTp['borderRadius']);
  newTp['corners'] = corners;

  TextTheme baseTextTheme;
  if (tp['textTheme'] != null) {
    baseTextTheme = tp['textTheme'];
  } else if ((tp['fontFamily'] ?? gsFontFamily) == 'Inter') {
    baseTextTheme = GoogleFonts.interTextTheme();
  } else {
    baseTextTheme = Typography.blackCupertino.apply(
      fontFamily: tp['fontFamily'],
    );
  }
  baseTextTheme = baseTextTheme.apply(
    bodyColor: newTp['textColor'],
    displayColor: newTp['textColor'],
  );
  newTp['baseTextTheme'] = baseTextTheme;

  return newTp;
}