FCalendarDayPickerStyle.inherit constructor

FCalendarDayPickerStyle.inherit({
  1. required FColors colors,
  2. required FTypography typography,
})

Creates a FCalendarDayPickerStyle that inherits its properties.

Implementation

factory FCalendarDayPickerStyle.inherit({required FColors colors, required FTypography typography}) {
  final mutedTextStyle = typography.base.copyWith(
    color: colors.disable(colors.mutedForeground),
    fontWeight: FontWeight.w500,
  );

  final background = {
    WidgetState.disabled & WidgetState.selected: colors.primaryForeground,
    WidgetState.disabled: colors.background,
  };

  final border = {
    WidgetState.disabled & WidgetState.selected & WidgetState.focused: colors.primaryForeground,
    WidgetState.disabled & WidgetState.focused: colors.background,
    WidgetState.focused: colors.foreground,
  };

  return FCalendarDayPickerStyle(
    headerTextStyle: typography.xs.copyWith(color: colors.mutedForeground),
    current: FCalendarEntryStyle(
      backgroundColor: FWidgetStateMap({
        ...background,
        WidgetState.selected: colors.foreground,
        ~WidgetState.selected & (WidgetState.hovered | WidgetState.pressed): colors.secondary,
        WidgetState.any: colors.background,
      }),
      borderColor: FWidgetStateMap(border),
      textStyle: FWidgetStateMap({
        WidgetState.disabled: mutedTextStyle,
        WidgetState.selected: typography.base.copyWith(color: colors.background, fontWeight: FontWeight.w500),
        WidgetState.any: typography.base.copyWith(color: colors.foreground, fontWeight: FontWeight.w500),
      }),
      radius: const Radius.circular(4),
    ),
    enclosing: FCalendarEntryStyle(
      backgroundColor: FWidgetStateMap({
        ...background,
        WidgetState.selected: colors.primaryForeground,
        ~WidgetState.selected & (WidgetState.hovered | WidgetState.pressed): colors.secondary,
        WidgetState.any: colors.background,
      }),
      borderColor: FWidgetStateMap(border),
      textStyle: FWidgetStateMap.all(mutedTextStyle),
      radius: const Radius.circular(4),
    ),
  );
}