Skip to content

onTap not triggering on CNTabBar, dragging works. #1

@kkoskenvirta

Description

@kkoskenvirta

Hi! I tried the package and it is awesome, just having a small issue with the bottom CNTabBar, for some reason the tap events are not triggering the on valueChanged method call. However dragging does work. Is this a known issue or might it have something to do with my implementation 🤔

useEffect(() {
  currentIndex.value = switch (currentMode) {
    DiaryPageMode.intake => 0,
    DiaryPageMode.weight => 1,
    DiaryPageMode.activity => 2,
    DiaryPageMode.goals_and_streaks => 3,
  };
  return null;
}, [currentMode]);

return CNTabBar(
  iconSize: 16,
  items: [
    CNTabBarItem(label: S.of(context).diary, icon: CNSymbol('book', color: context.colors.onSurface, size: 16)),
    CNTabBarItem(
      label: S.of(context).progress,
      icon: CNSymbol('chart.bar', color: context.colors.onSurface, size: 16),
    ),
    CNTabBarItem(
      label: S.of(context).activity,
      icon: CNSymbol('dumbbell', color: context.colors.onSurface, size: 16),
    ),
    CNTabBarItem(icon: CNSymbol('trophy', color: context.colors.onSurface, size: 16), label: S.of(context).goals),
    CNTabBarItem(icon: CNSymbol('plus', color: context.colors.onSurface, size: 16)),
  ],
  currentIndex: currentIndex.value,
  tint: context.colors.secondary,
  onTap: (index) {
    currentIndex.value = index;
    if (index == 4) {
      openMainActionModal(MyRouter.authenticatedKey.currentContext!);
    }
    switch (index) {
      case 0:
        context.read<DiaryCubit>().onChangeDiaryPageMode(mode: DiaryPageMode.intake);
        context.read<PrimaryScrollCubit>().triggerScrollUp(ScrollPage.diary);
        break;
      case 1:
        context.read<DiaryCubit>().onChangeDiaryPageMode(mode: DiaryPageMode.weight);
        context.read<PrimaryScrollCubit>().triggerScrollUp(ScrollPage.diary);
        break;
      case 2:
        context.read<DiaryCubit>().onChangeDiaryPageMode(mode: DiaryPageMode.activity);
        context.read<PrimaryScrollCubit>().triggerScrollUp(ScrollPage.diary);
        break;
      case 3:
        context.read<DiaryCubit>().onChangeDiaryPageMode(mode: DiaryPageMode.goals_and_streaks);
        context.read<PrimaryScrollCubit>().triggerScrollUp(ScrollPage.diary);
        break;
    }
  },
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions