selectMember method

Future selectMember(
  1. BuildContext context
)

选择@的成员

Implementation

Future<dynamic> selectMember(BuildContext context) async {
  // P2P 场景:无数字人则不弹框,直接返回 null
  if (isP2P && (_aiUserList == null || _aiUserList!.isEmpty)) {
    return null;
  }
  return showModalBottomSheet(
    context: context,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topLeft: Radius.circular(8),
        topRight: Radius.circular(8),
      ),
    ),
    builder: (context) {
      return ValueListenableBuilder(
        valueListenable: _aitMemberList,
        builder: (BuildContext context, List<AitBean>? value, Widget? child) {
          var _teamMembers = value
              ?.where(
                (element) => element.getAccountId() != IMKitClient.account(),
              )
              .toList();
          return Column(
            children: [
              SizedBox(
                height: 48,
                child: Stack(
                  alignment: Alignment.centerLeft,
                  children: [
                    IconButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      icon: Icon(
                        Icons.keyboard_arrow_down_rounded,
                        color: CommonColors.color_999999,
                      ),
                    ),
                    Align(
                      alignment: Alignment.center,
                      child: Text(S.of(context).chatMessageAitContactTitle),
                    ),
                  ],
                ),
              ),
              // P2P 单聊不显示"@所有人"
              if (!isP2P && NIMChatCache.instance.haveAitAllPrivilege())
                ListTile(
                  leading: SvgPicture.asset(
                    'images/ic_team_all.svg',
                    package: kPackage,
                    height: 42,
                    width: 42,
                  ),
                  title: Text(S.of(context).chatTeamAitAll),
                  onTap: () {
                    Navigator.pop(context, AitContactsModel.accountAll);
                  },
                ),
              if (_teamMembers?.isNotEmpty == true)
                Expanded(
                  child: ListView.builder(
                    controller: _scrollController,
                    itemCount: _teamMembers!.length,
                    itemBuilder: (context, index) {
                      var user = _teamMembers[index];
                      return ListTile(
                        leading: Avatar(
                          avatar: user.getAvatar(),
                          name: user.getAvatarName(),
                          height: 42,
                          width: 42,
                        ),
                        title: Text(
                          user.getName(),
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                        onTap: () {
                          Navigator.pop(context, user);
                        },
                      );
                    },
                  ),
                ),
            ],
          );
        },
      );
    },
  );
}