FLineCalendarStyle.inherit constructor

FLineCalendarStyle.inherit({
  1. required FColors colors,
  2. required FTypography typography,
  3. required FStyle style,
})

Creates a FLineCalendarStyle that inherits its properties.

Implementation

factory FLineCalendarStyle.inherit({
  required FColors colors,
  required FTypography typography,
  required FStyle style,
}) {
  final focusedShape = RoundedSuperellipseBorder(
    side: BorderSide(color: colors.primary, width: style.borderWidth),
    borderRadius: style.borderRadius.md,
  );

  return .new(
    decoration: FVariants.from(
      ShapeDecoration(
        shape: RoundedSuperellipseBorder(borderRadius: style.borderRadius.md),
        color: colors.card,
      ),
      variants: {
        [.focused]: .shapeDelta(shape: focusedShape),
        [.hovered, .pressed]: .shapeDelta(color: colors.secondary),
        [.hovered.and(.focused), .pressed.and(.focused)]: .shapeDelta(color: colors.secondary, shape: focusedShape),
        //
        [.disabled]: .shapeDelta(color: colors.disable(colors.card)),
        [.disabled.and(.focused)]: .shapeDelta(color: colors.disable(colors.card), shape: focusedShape),
        [.disabled.and(.selected).and(.focused)]: .shapeDelta(
          shape: focusedShape,
          color: colors.disable(colors.primary),
        ),
        //
        [.selected]: .shapeDelta(
          shape: RoundedSuperellipseBorder(borderRadius: style.borderRadius.md),
          color: colors.primary,
        ),
        [.selected.and(.focused)]: .shapeDelta(color: colors.primary, shape: focusedShape),
        [.selected.and(.hovered), .selected.and(.pressed)]: .shapeDelta(
          shape: RoundedSuperellipseBorder(borderRadius: style.borderRadius.md),
          color: colors.hover(colors.primary),
        ),
        [.selected.and(.hovered).and(.focused), .selected.and(.pressed).and(.focused)]: .shapeDelta(
          shape: focusedShape,
          color: colors.hover(colors.primary),
        ),
        [.selected.and(.disabled)]: .shapeDelta(color: colors.disable(colors.primary)),
        //
        [.today]: .shapeDelta(color: colors.secondary),
        [.today.and(.focused)]: .shapeDelta(color: colors.secondary, shape: focusedShape),
        [.today.and(.hovered), .today.and(.pressed)]: .shapeDelta(color: colors.hover(colors.secondary)),
        [.today.and(.hovered).and(.focused), .today.and(.pressed).and(.focused)]: .shapeDelta(
          color: colors.hover(colors.secondary),
          shape: focusedShape,
        ),
      },
    ),
    todayIndicatorColor: FVariants(
      colors.foreground,
      variants: {
        [.hovered, .pressed]: colors.hover(colors.foreground),
        //
        [.disabled]: colors.disable(colors.foreground),
        //
        [.selected]: colors.primaryForeground,
        [.selected.and(.hovered), .selected.and(.pressed)]: colors.hover(colors.primaryForeground),
        [.selected.and(.disabled)]: colors.disable(colors.primaryForeground),
      },
    ),
    dateTextStyle: FVariants.from(
      typography.sm.copyWith(color: colors.foreground, height: 1),
      variants: {
        [.disabled]: .delta(color: colors.disable(colors.foreground)),
        //
        [.selected]: .delta(color: colors.primaryForeground),
        [.selected.and(.disabled)]: .delta(color: colors.disable(colors.primaryForeground)),
      },
    ),
    weekdayTextStyle: FVariants.from(
      typography.xs3.copyWith(color: colors.mutedForeground, height: 1),
      variants: {
        [.disabled]: .delta(color: colors.disable(colors.mutedForeground)),
        //
        [.selected]: .delta(color: colors.primaryForeground),
        [.selected.and(.disabled)]: .delta(color: colors.disable(colors.primaryForeground)),
      },
    ),
    tappableStyle: style.tappableStyle,
  );
}