appBar method

dynamic appBar(
  1. dynamic context,
  2. dynamic ref
)

Implementation

Widget appBar(BuildContext context, WidgetRef ref) {
  final roomAvatarInfo = ref.watch(roomAvatarInfoProvider(roomId));
  final membersLoader = ref.watch(membersIdsProvider(roomId));
  final isEncrypted =
      ref.watch(isRoomEncryptedProvider(roomId)).valueOrNull ?? false;
  return AppBar(
    elevation: 0,
    automaticallyImplyLeading: !context.isLargeScreen,
    centerTitle: true,
    toolbarHeight: 70,
    flexibleSpace: FrostEffect(
      child: Container(),
    ),
    title: GestureDetector(
      onTap: () => context.pushNamed(
        Routes.chatProfile.name,
        pathParameters: {'roomId': roomId},
      ),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text(
            roomAvatarInfo.displayName ?? roomId,
            overflow: TextOverflow.clip,
            style: Theme.of(context).textTheme.bodyLarge,
          ),
          const SizedBox(height: 5),
          membersLoader.when(
            data: (members) => Text(
              L10n.of(context).membersCount(members.length),
              style: Theme.of(context).textTheme.bodySmall,
            ),
            skipLoadingOnReload: false,
            error: (e, s) {
              _log.severe('Failed to load active members', e, s);
              return Text(L10n.of(context).errorLoadingMembersCount(e));
            },
            loading: () => Skeletonizer(
              child: Text(L10n.of(context).membersCount(100)),
            ),
          ),
        ],
      ),
    ),
    actions: [
      if (!isEncrypted)
        IconButton(
          onPressed: () =>
              EasyLoading.showInfo(L10n.of(context).chatNotEncrypted),
          icon: Icon(
            PhosphorIcons.shieldWarning(),
            color: Theme.of(context).colorScheme.error,
          ),
        ),
      GestureDetector(
        onTap: () => context.pushNamed(
          Routes.chatProfile.name,
          pathParameters: {'roomId': roomId},
        ),
        child: Padding(
          padding: const EdgeInsets.only(right: 10),
          child: RoomAvatar(
            roomId: roomId,
            showParents: true,
          ),
        ),
      ),
    ],
  );
}