Skip to content

Commit

Permalink
fix: Add selected tab pill text color (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
GittHub-d committed May 26, 2023
1 parent 129b0a7 commit 1ce39cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/src/theme/tab_bar/tab_bar_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class MoonTabBarColors extends ThemeExtension<MoonTabBarColors> with Diagnostica
indicatorColor: MoonColors.light.piccolo,
textColor: MoonTypography.light.colors.bodyPrimary,
selectedTextColor: MoonColors.light.piccolo,
selectedPillTextColor: MoonTypography.light.colors.bodyPrimary,
selectedPillTabColor: MoonColors.light.gohan,
);

static final dark = MoonTabBarColors(
indicatorColor: MoonColors.dark.piccolo,
textColor: MoonTypography.dark.colors.bodyPrimary,
selectedTextColor: MoonColors.dark.piccolo,
selectedPillTextColor: MoonTypography.dark.colors.bodyPrimary,
selectedPillTabColor: MoonColors.dark.gohan,
);

Expand All @@ -30,13 +32,17 @@ class MoonTabBarColors extends ThemeExtension<MoonTabBarColors> with Diagnostica
/// TabBar selected tab text color.
final Color selectedTextColor;

/// TabBar selected pill tab text color.
final Color selectedPillTextColor;

/// TabBar selected pill tab color.
final Color selectedPillTabColor;

const MoonTabBarColors({
required this.indicatorColor,
required this.textColor,
required this.selectedTextColor,
required this.selectedPillTextColor,
required this.selectedPillTabColor,
});

Expand All @@ -45,12 +51,14 @@ class MoonTabBarColors extends ThemeExtension<MoonTabBarColors> with Diagnostica
Color? indicatorColor,
Color? textColor,
Color? selectedTextColor,
Color? selectedPillTextColor,
Color? selectedPillTabColor,
}) {
return MoonTabBarColors(
indicatorColor: indicatorColor ?? this.indicatorColor,
textColor: textColor ?? this.textColor,
selectedTextColor: selectedTextColor ?? this.selectedTextColor,
selectedPillTextColor: selectedPillTextColor ?? this.selectedPillTextColor,
selectedPillTabColor: selectedPillTabColor ?? this.selectedPillTabColor,
);
}
Expand All @@ -63,6 +71,7 @@ class MoonTabBarColors extends ThemeExtension<MoonTabBarColors> with Diagnostica
indicatorColor: colorPremulLerp(indicatorColor, other.indicatorColor, t)!,
textColor: colorPremulLerp(textColor, other.textColor, t)!,
selectedTextColor: colorPremulLerp(selectedTextColor, other.selectedTextColor, t)!,
selectedPillTextColor: colorPremulLerp(selectedPillTextColor, other.selectedPillTextColor, t)!,
selectedPillTabColor: colorPremulLerp(selectedPillTabColor, other.selectedPillTabColor, t)!,
);
}
Expand All @@ -75,6 +84,7 @@ class MoonTabBarColors extends ThemeExtension<MoonTabBarColors> with Diagnostica
..add(ColorProperty("indicatorColor", indicatorColor))
..add(ColorProperty("textColor", textColor))
..add(ColorProperty("selectedTextColor", selectedTextColor))
..add(ColorProperty("selectedPillTextColor", selectedPillTextColor))
..add(ColorProperty("selectedPillTabColor", selectedPillTabColor));
}
}
4 changes: 2 additions & 2 deletions lib/src/widgets/tab_bar/tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ class _PillTabBuilder extends StatelessWidget {
MoonTypography.light.colors.bodyPrimary;

final Color effectiveSelectedTextColor = tabStyle?.selectedTextColor ??
context.moonTheme?.tabBarTheme.colors.selectedTextColor ??
MoonColors.light.piccolo;
context.moonTheme?.tabBarTheme.colors.selectedPillTextColor ??
MoonTypography.light.colors.bodyPrimary;

final TextStyle effectiveTextStyle = moonTabBarSizeProperties.textStyle.merge(tabStyle?.textStyle);

Expand Down

0 comments on commit 1ce39cf

Please sign in to comment.