Introduce TabBar.tabAlignment (#125036)
fixes https://github.com/flutter/flutter/issues/124195 This introduces `TabBar.tabAlignment` while keeping the default alignment for both M2 and M3.
This commit is contained in:
@@ -13,12 +13,13 @@ class TabsTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}PrimaryDefaultsM3 extends TabBarTheme {
|
||||
_${blockName}PrimaryDefaultsM3(this.context)
|
||||
_${blockName}PrimaryDefaultsM3(this.context, this.isScrollable)
|
||||
: super(indicatorSize: TabBarIndicatorSize.label);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
final bool isScrollable;
|
||||
|
||||
@override
|
||||
Color? get dividerColor => ${componentColor("md.comp.primary-navigation-tab.divider")};
|
||||
@@ -68,15 +69,19 @@ class _${blockName}PrimaryDefaultsM3 extends TabBarTheme {
|
||||
|
||||
@override
|
||||
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
|
||||
|
||||
@override
|
||||
TabAlignment? get tabAlignment => isScrollable ? TabAlignment.start : TabAlignment.fill;
|
||||
}
|
||||
|
||||
class _${blockName}SecondaryDefaultsM3 extends TabBarTheme {
|
||||
_${blockName}SecondaryDefaultsM3(this.context)
|
||||
_${blockName}SecondaryDefaultsM3(this.context, this.isScrollable)
|
||||
: super(indicatorSize: TabBarIndicatorSize.tab);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
final bool isScrollable;
|
||||
|
||||
@override
|
||||
Color? get dividerColor => ${componentColor("md.comp.secondary-navigation-tab.divider")};
|
||||
@@ -126,6 +131,9 @@ class _${blockName}SecondaryDefaultsM3 extends TabBarTheme {
|
||||
|
||||
@override
|
||||
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
|
||||
|
||||
@override
|
||||
TabAlignment? get tabAlignment => isScrollable ? TabAlignment.start : TabAlignment.fill;
|
||||
}
|
||||
''';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user