FCalendarDayPickerStyle.inherit constructor

FCalendarDayPickerStyle.inherit({
  1. required FColors colors,
  2. required FTypography typography,
  3. required FStyle style,
  4. required bool touch,
})

Creates a FCalendarDayPickerStyle that inherits its properties.

Implementation

factory FCalendarDayPickerStyle.inherit({
  required FColors colors,
  required FTypography typography,
  required FStyle style,
  required bool touch,
}) {
  final backgroundColor = FVariants<FTappableVariantConstraint, FTappableVariant, Color, Delta>(
    colors.card,
    variants: {
      [.hovered, .pressed]: colors.secondary,
      //
      [.selected]: colors.primary,
      [.selected.and(.disabled)]: colors.disable(colors.primary),
    },
  );
  final border = FVariants<FTappableVariantConstraint, FTappableVariant, BorderSide?, Delta>(
    null,
    variants: {
      [.focused]: BorderSide(color: colors.primary, width: style.borderWidth),
      //
      [.disabled.and(.selected).and(.focused)]: null,
      [.disabled.and(.focused)]: null,
    },
  );
  FVariants<FTappableVariantConstraint, FTappableVariant, TextStyle, TextStyleDelta> textStyle(
    TextStyle textStyle,
    Color color,
  ) => FVariants.from(
    textStyle.copyWith(color: color, fontWeight: .w500),
    variants: {
      [.disabled]: .delta(color: colors.disable(color)),
      //
      [.selected]: .delta(color: colors.primaryForeground),
      [.selected.and(.disabled)]: .delta(color: colors.disable(colors.primaryForeground)),
    },
  );

  if (touch) {
    return .new(
      headerTextStyle: typography.xs2.copyWith(color: colors.mutedForeground),
      tileSize: style.sizes.calendar,
      current: FCalendarEntryStyle(
        backgroundColor: backgroundColor,
        borderSide: border,
        textStyle: textStyle(typography.sm, colors.foreground),
        borderRadius: style.borderRadius.md,
      ),
      enclosing: FCalendarEntryStyle(
        backgroundColor: backgroundColor,
        borderSide: border,
        textStyle: textStyle(typography.sm, colors.mutedForeground),
        borderRadius: style.borderRadius.md,
      ),
    );
  } else {
    return .new(
      headerTextStyle: typography.xs.copyWith(color: colors.mutedForeground),
      tileSize: style.sizes.calendar,
      current: FCalendarEntryStyle(
        backgroundColor: backgroundColor,
        borderSide: border,
        textStyle: textStyle(typography.sm, colors.foreground),
        borderRadius: style.borderRadius.sm,
      ),
      enclosing: FCalendarEntryStyle(
        backgroundColor: backgroundColor,
        borderSide: border,
        textStyle: textStyle(typography.sm, colors.mutedForeground),
        borderRadius: style.borderRadius.sm,
      ),
    );
  }
}