StreamChatThemeData.fromColorAndTextTheme constructor

StreamChatThemeData.fromColorAndTextTheme(
  1. ColorTheme colorTheme,
  2. TextTheme textTheme
)

Create theme from color and text theme

Implementation

factory StreamChatThemeData.fromColorAndTextTheme(
  ColorTheme colorTheme,
  TextTheme textTheme,
) {
  final accentColor = colorTheme.accentPrimary;
  final iconTheme =
      IconThemeData(color: colorTheme.textHighEmphasis.withOpacity(0.5));
  final channelHeaderTheme = ChannelHeaderThemeData(
    avatarTheme: AvatarThemeData(
      borderRadius: BorderRadius.circular(20),
      constraints: const BoxConstraints.tightFor(
        height: 40,
        width: 40,
      ),
    ),
    color: colorTheme.barsBg,
    titleStyle: textTheme.headlineBold,
    subtitleStyle: textTheme.footnote.copyWith(
      color: const Color(0xff7A7A7A),
    ),
  );
  final channelPreviewTheme = ChannelPreviewThemeData(
    unreadCounterColor: colorTheme.accentError,
    avatarTheme: AvatarThemeData(
      borderRadius: BorderRadius.circular(20),
      constraints: const BoxConstraints.tightFor(
        height: 40,
        width: 40,
      ),
    ),
    titleStyle: textTheme.bodyBold,
    subtitleStyle: textTheme.footnote.copyWith(
      color: const Color(0xff7A7A7A),
    ),
    lastMessageAtStyle: textTheme.footnote.copyWith(
      color: colorTheme.textHighEmphasis.withOpacity(0.5),
    ),
    indicatorIconSize: 16,
  );
  return StreamChatThemeData.raw(
    textTheme: textTheme,
    colorTheme: colorTheme,
    primaryIconTheme: iconTheme,
    defaultUserImage: (context, user) => Center(
      child: GradientAvatar(
        name: user.name,
        userId: user.id,
      ),
    ),
    channelPreviewTheme: channelPreviewTheme,
    channelListHeaderTheme: ChannelListHeaderThemeData(
      avatarTheme: AvatarThemeData(
        borderRadius: BorderRadius.circular(20),
        constraints: const BoxConstraints.tightFor(
          height: 40,
          width: 40,
        ),
      ),
      color: colorTheme.barsBg,
      titleStyle: textTheme.headlineBold,
    ),
    channelHeaderTheme: channelHeaderTheme,
    ownMessageTheme: MessageThemeData(
      messageAuthorStyle:
          textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
      messageTextStyle: textTheme.body,
      createdAtStyle:
          textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
      repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
      messageBackgroundColor: colorTheme.disabled,
      reactionsBackgroundColor: colorTheme.barsBg,
      reactionsBorderColor: colorTheme.borders,
      reactionsMaskColor: colorTheme.appBg,
      messageBorderColor: colorTheme.disabled,
      avatarTheme: AvatarThemeData(
        borderRadius: BorderRadius.circular(20),
        constraints: const BoxConstraints.tightFor(
          height: 32,
          width: 32,
        ),
      ),
      messageLinksStyle: TextStyle(
        color: accentColor,
      ),
      linkBackgroundColor: colorTheme.linkBg,
    ),
    otherMessageTheme: MessageThemeData(
      reactionsBackgroundColor: colorTheme.disabled,
      reactionsBorderColor: colorTheme.barsBg,
      reactionsMaskColor: colorTheme.appBg,
      messageTextStyle: textTheme.body,
      createdAtStyle:
          textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
      messageAuthorStyle:
          textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
      repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
      messageLinksStyle: TextStyle(
        color: accentColor,
      ),
      messageBackgroundColor: colorTheme.barsBg,
      messageBorderColor: colorTheme.borders,
      avatarTheme: AvatarThemeData(
        borderRadius: BorderRadius.circular(20),
        constraints: const BoxConstraints.tightFor(
          height: 32,
          width: 32,
        ),
      ),
      linkBackgroundColor: colorTheme.linkBg,
    ),
    messageInputTheme: MessageInputThemeData(
      borderRadius: BorderRadius.circular(20),
      sendAnimationDuration: const Duration(milliseconds: 300),
      actionButtonColor: colorTheme.accentPrimary,
      actionButtonIdleColor: colorTheme.textLowEmphasis,
      expandButtonColor: colorTheme.accentPrimary,
      sendButtonColor: colorTheme.accentPrimary,
      sendButtonIdleColor: colorTheme.disabled,
      inputBackgroundColor: colorTheme.barsBg,
      inputTextStyle: textTheme.body,
      idleBorderGradient: LinearGradient(
        colors: [
          colorTheme.disabled,
          colorTheme.disabled,
        ],
      ),
      activeBorderGradient: LinearGradient(
        colors: [
          colorTheme.disabled,
          colorTheme.disabled,
        ],
      ),
    ),
    reactionIcons: [
      ReactionIcon(
        type: 'love',
        builder: (context, highlighted, size) {
          final theme = StreamChatTheme.of(context);
          return StreamSvgIcon.loveReaction(
            color: highlighted
                ? theme.colorTheme.accentPrimary
                : theme.primaryIconTheme.color!.withOpacity(0.5),
            size: size,
          );
        },
      ),
      ReactionIcon(
        type: 'like',
        builder: (context, highlighted, size) {
          final theme = StreamChatTheme.of(context);
          return StreamSvgIcon.thumbsUpReaction(
            color: highlighted
                ? theme.colorTheme.accentPrimary
                : theme.primaryIconTheme.color!.withOpacity(0.5),
            size: size,
          );
        },
      ),
      ReactionIcon(
        type: 'sad',
        builder: (context, highlighted, size) {
          final theme = StreamChatTheme.of(context);
          return StreamSvgIcon.thumbsDownReaction(
            color: highlighted
                ? theme.colorTheme.accentPrimary
                : theme.primaryIconTheme.color!.withOpacity(0.5),
            size: size,
          );
        },
      ),
      ReactionIcon(
        type: 'haha',
        builder: (context, highlighted, size) {
          final theme = StreamChatTheme.of(context);
          return StreamSvgIcon.lolReaction(
            color: highlighted
                ? theme.colorTheme.accentPrimary
                : theme.primaryIconTheme.color!.withOpacity(0.5),
            size: size,
          );
        },
      ),
      ReactionIcon(
        type: 'wow',
        builder: (context, highlighted, size) {
          final theme = StreamChatTheme.of(context);
          return StreamSvgIcon.wutReaction(
            color: highlighted
                ? theme.colorTheme.accentPrimary
                : theme.primaryIconTheme.color!.withOpacity(0.5),
            size: size,
          );
        },
      ),
    ],
    galleryHeaderTheme: GalleryHeaderThemeData(
      closeButtonColor: colorTheme.textHighEmphasis,
      backgroundColor: channelHeaderTheme.color,
      iconMenuPointColor: colorTheme.textHighEmphasis,
      titleTextStyle: textTheme.headlineBold,
      subtitleTextStyle: channelPreviewTheme.subtitleStyle,
      bottomSheetBarrierColor: colorTheme.overlay,
    ),
    galleryFooterTheme: GalleryFooterThemeData(
      backgroundColor: colorTheme.barsBg,
      shareIconColor: colorTheme.textHighEmphasis,
      titleTextStyle: textTheme.headlineBold,
      gridIconButtonColor: colorTheme.textHighEmphasis,
      bottomSheetBarrierColor: colorTheme.overlay,
      bottomSheetBackgroundColor: colorTheme.barsBg,
      bottomSheetPhotosTextStyle: textTheme.headlineBold,
      bottomSheetCloseIconColor: colorTheme.textHighEmphasis,
    ),
    messageListViewTheme: MessageListViewThemeData(
      backgroundColor: colorTheme.barsBg,
    ),
    channelListViewTheme: ChannelListViewThemeData(
      backgroundColor: colorTheme.appBg,
    ),
    userListViewTheme: UserListViewThemeData(
      backgroundColor: colorTheme.appBg,
    ),
    messageSearchListViewTheme: MessageSearchListViewThemeData(
      backgroundColor: colorTheme.appBg,
    ),
  );
}