azlistview icon indicating copy to clipboard operation
azlistview copied to clipboard

Disable susItem float

Open kightsonsanom opened this issue 4 years ago • 2 comments

Hello, first of all great library! very customizable. I have a question regarding sticky susItems. Is it possible to disable their stickiness? I would prefer them to stay in one place. I saw solutions with using Offstage widget for providing headers in the itemBuilder callback but I wonder if it is possible to user sysItemBuilder with the same effect.

This is what I have: sticky

And the code

return AzListView(
      padding: EdgeInsets.zero,
      data: state.universities!,
      itemCount: state.universities!.length,
      itemBuilder: (BuildContext context, int index) {
        UniversityItem model = state.universities![index];
        return getListItem(context, model);
      },
      susItemBuilder: (BuildContext context, int index) {
        UniversityItem model = state.universities![index];
        String location = model.location;
        return getSusItem(context, location);
      },
      indexBarData: SuspensionUtil.getTagIndexList(state.universities),
      indexBarOptions: const IndexBarOptions(
        needRebuild: true,
        selectTextStyle: TextStyle(
            fontSize: 12,
            color: AppColors.brandGreen,
            fontWeight: FontWeight.w500),
        selectItemDecoration: BoxDecoration(),
      ),
    );

This is what I want: nonsticky

Current code to achieve this:

    return AzListView(
      padding: EdgeInsets.zero,
      data: state.universities!,
      itemCount: state.universities!.length,
      itemBuilder: (BuildContext context, int index) {
        final UniversityItem model = state.universities![index];

        return Column(
          children: [
            Offstage(
              offstage: !model.isShowSuspension,
              child: _buildUniversityHeader(context, model.location),
            ),
            _buildUniversityItem(context, model),
          ],
        );
      },
      indexBarData: SuspensionUtil.getTagIndexList(state.universities),
      indexBarOptions: const IndexBarOptions(
        needRebuild: true,
        selectTextStyle: TextStyle(
            fontSize: 12,
            color: AppColors.brandGreen,
            fontWeight: FontWeight.w500),
        selectItemDecoration: BoxDecoration(),
      ),
    );

kightsonsanom avatar Sep 07 '21 11:09 kightsonsanom

Only in this way,Refer to this example contacts_list_page

Sky24n avatar Sep 08 '21 01:09 Sky24n

I'm having the same issue but I want it to be only sticky, and it seems to be doing both as shown in the gif. My current code is as follows:

AzListView(
  data: displayedUserList,
  physics: const AlwaysScrollableScrollPhysics(),
  itemCount: displayedUserList.length,
  itemBuilder: (BuildContext context, int index) {
    UserModel model = displayedUserList[index];
    return getListItem(context, model);
  },
  itemScrollController: itemScrollController,
  susItemBuilder: (BuildContext context, int index) {
    UserModel model = displayedUserList[index];
    return getSusItem(context, model.getSuspensionTag());
  },
  indexBarOptions: const IndexBarOptions(
    needRebuild: true,
    selectTextStyle: TextStyle(
        fontSize: 12,
        color: Colors.white,
        fontWeight: FontWeight.w500),
    selectItemDecoration: BoxDecoration(
        shape: BoxShape.circle, color: Color(0xFF333333)),
    indexHintWidth: 96,
    indexHintHeight: 97,
    indexHintDecoration: BoxDecoration(
      image: DecorationImage(
        image: AssetImage('assets/images/ic_index_bar_bubble_white.png'),
        fit: BoxFit.contain,
      ),
    ),
    indexHintAlignment: Alignment.centerRight,
    indexHintTextStyle:
        TextStyle(fontSize: 24.0, color: Colors.black87),
    indexHintOffset: Offset(-30, 0),
  ),
)

Any ideas?

garv-shah avatar Dec 29 '22 02:12 garv-shah