EcpUserPicker constructor

EcpUserPicker({
  1. Key? key,
  2. int limitNum = noLimit,
  3. bool allowEmpty = false,
  4. List<User>? selectUserList,
  5. bool appBarVisible = true,
  6. bool? clickWithoutConfirm = true,
  7. String? title,
  8. List<String>? indexList,
  9. bool? showIndex = false,
  10. String? searchHint = '请输入人员名称进行搜索',
  11. OnSelected<User>? onSelected,
  12. bool showSearch = true,
  13. bool? showSelectedList,
  14. bool refreshEnable = true,
  15. bool loadMoreEnable = true,
  16. bool isAutoLeading = true,
  17. List<User>? frozenList,
  18. bool showCharacter = false,
  19. UserSelectorBuilder<User, Department>? userSelectorBuilder,
  20. SelectedBuilder<User>? userSelectedBuilder,
  21. UserRepo<User, Department>? userRepo,
  22. SearchRepo<User, Department>? userSearchRepo,
  23. IndexPredicate<User, Department>? indexPredicate,
  24. EcpDepartmentRange? range,
  25. List<String>? deptIds,
  26. int? hideLeaderFlag,
  27. int? queryHeadshipName,
})

Implementation

EcpUserPicker({
  super.key,
  super.limitNum,
  super.allowEmpty,
  super.selectUserList,
  super.appBarVisible,
  super.clickWithoutConfirm = true,
  super.title,
  super.indexList,
  super.showIndex = false,
  super.searchHint = '请输入人员名称进行搜索',
  super.onSelected,
  bool showSearch = true,
  super.showSelectedList,
  super.refreshEnable,
  super.loadMoreEnable,
  super.isAutoLeading = true,
  super.frozenList,
  bool showCharacter = false,
  UserSelectorBuilder<User, Department>? userSelectorBuilder,
  SelectedBuilder<User>? userSelectedBuilder,
  UserRepo<User, Department>? userRepo,
  SearchRepo<User, Department>? userSearchRepo,
  IndexPredicate<User, Department>? indexPredicate,
  EcpDepartmentRange? range,
  List<String>? deptIds,
  int? hideLeaderFlag,
  int? queryHeadshipName,
}) : super(
        userSelectorBuilder: userSelectorBuilder ??
            (ctx, proxy, user) {
              var list = proxy.currentUserList;
              int index = list.indexOf(user);
              String? current = user.origin.pinYin.firstOrNull;
              String? pre =
                  list.getElementOrNull(index - 1)?.origin.pinYin.firstOrNull;
              bool showChar = current != null && current != pre;
              return UserPickerItem(
                wrapper: user,
                showCheckBox: !(clickWithoutConfirm ?? limitNum == 1),
                showCharacter: showCharacter && showChar,
              );
            },
        userSelectedBuilder: userSelectedBuilder ??
            (ctx, user) => UserPickerItem(wrapper: user),
        userRepo: userRepo ??
            (d, index) {
              return defaultUserRepo(
                d,
                index,
                hideLeaderFlag: hideLeaderFlag,
                queryHeadshipName: queryHeadshipName,
              );
            },
        searchRepo: showSearch
            ? userSearchRepo ??
                (proxy, key, index) {
                  bool designated = range != EcpDepartmentRange.designated;
                  var deptId = designated ? null : proxy.rootDept?.deptId;
                  return defaultUserSearchRepo(
                    proxy,
                    key,
                    index,
                    deptId: deptId,
                    deptIds: deptIds,
                    hideLeaderFlag: hideLeaderFlag,
                  );
                }
            : null,
        indexPredicate: indexPredicate ??
            (c, index, proxy) {
              var list = proxy.currentUserList.where((element) =>
                  element.origin.pinYin.firstOrNull?.toUpperCase() == c);
              if (list.isNotEmpty) {
                var index = proxy.currentUserList.indexOf(list.first);
                return index >= 0 ? index : null;
              }
              return null;
            },
      );