zdsTabBarThemeData method

  1. @Deprecated('Use ZdsTabBar.buildTheme() instead')
ZdsTabBarStyleContainer zdsTabBarThemeData(
  1. BuildContext context,
  2. {required bool hasIcons,
  3. required ZdsTabBarColor color,
  4. Color? indicatorColor}
)

Generates theme for ZdsTabBar.

Implementation

@Deprecated('Use ZdsTabBar.buildTheme() instead')
ZdsTabBarStyleContainer zdsTabBarThemeData(
  BuildContext context, {
  required bool hasIcons,
  required ZdsTabBarColor color,
  Color? indicatorColor,
}) {
  /// Builds [ZdsTabBarStyleContainer]. Defaults to primary color.
  ZdsTabBarStyleContainer tabBarStyle(
    BuildContext context, {
    required bool hasIcons,
    required Color selectedText,
    required Color background,
    required Color unselectedText,
    required Color indicator,
  }) {
    final double height = hasIcons ? 56.0 : 48.0;
    final ThemeData theme = Theme.of(context);

    final TabBarTheme tabBarTheme = theme.tabBarTheme.copyWith(indicatorSize: TabBarIndicatorSize.tab);
    final TextStyle? labelStyle = hasIcons ? theme.textTheme.bodyXSmall : theme.textTheme.bodyLarge;

    return ZdsTabBarStyleContainer(
      customTheme: ZdsTabBarThemeData(
        decoration: BoxDecoration(color: background),
        height: height,
      ),
      theme: theme.copyWith(
        tabBarTheme: tabBarTheme.copyWith(
          labelStyle: labelStyle,
          unselectedLabelStyle: labelStyle,
          unselectedLabelColor: unselectedText,
          labelColor: selectedText,
          indicator: UnderlineTabIndicator(
            borderSide: BorderSide(
              width: 3,
              color: indicator,
            ),
          ),
        ),
      ),
    );
  }

  final zetaColors = Zeta.of(context).colors;
  switch (color) {
    case ZdsTabBarColor.primary:
      return tabBarStyle(
        context,
        hasIcons: hasIcons,
        background: zetaColors.primary,
        indicator: zetaColors.primary.onColor,
        selectedText: zetaColors.primary.onColor,
        unselectedText: zetaColors.primary.onColor.withOpacity(0.5),
      );
    case ZdsTabBarColor.basic:
      return tabBarStyle(
        context,
        hasIcons: hasIcons,
        background: colorScheme.background,
        indicator: zetaColors.primary,
        selectedText: zetaColors.textDefault,
        unselectedText: zetaColors.textSubtle,
      );
    case ZdsTabBarColor.surface:
      return tabBarStyle(
        context,
        hasIcons: hasIcons,
        background: zetaColors.surfacePrimary,
        indicator: zetaColors.primary,
        selectedText: zetaColors.textDefault,
        unselectedText: zetaColors.textSubtle,
      );
    case ZdsTabBarColor.appBar:
      final appBarTheme = Theme.of(context).appBarTheme;
      return tabBarStyle(
        context,
        hasIcons: hasIcons,
        background: appBarTheme.backgroundColor ?? zetaColors.surfacePrimary,
        indicator: appBarTheme.foregroundColor ?? zetaColors.primary,
        selectedText: appBarTheme.foregroundColor ?? zetaColors.textDefault,
        unselectedText: appBarTheme.foregroundColor?.withOpacity(0.5) ?? zetaColors.textSubtle,
      );
  }
}