buildSidebar method

Widget buildSidebar(
  1. BuildContext context,
  2. int index, {
  3. bool drawer = false,
})

Implementation

Widget buildSidebar(BuildContext context, int index, {bool drawer = false}) =>
    ArcaneSidebar(
        children: (context) => [
              ...tabs.mapIndexed((e, i) => switch (e) {
                    NavTab e => ArcaneSidebarButton(
                        icon: Icon(
                            index == i ? e.selectedIcon ?? e.icon : e.icon),
                        label: e.label ?? "Item ${index + 1}",
                        selected: index == i,
                        onTap: () {
                          if (drawer) {
                            Arcane.closeDrawer(context);
                          }

                          if (index != i) {
                            onIndexChanged?.call(i);
                          }
                        },
                      ),
                    NavItem e => e.builder(context),
                  })
            ].joinSeparator(SizedBox(height: sidebarSpacing)),
        footer: sidebarFooter == null
            ? null
            : drawer
                ? (context) =>
                    context.streamPylon<ArcaneSidebarState?>().build((st) {
                      if (st == ArcaneSidebarState.collapsed) {
                        Arcane.closeDrawer(context);
                      }

                      context.setPylon(ArcaneSidebarState.expanded);
                      return Pylon<ArcaneDrawerSignal?>(
                        local: true,
                        value: ArcaneDrawerSignal(true),
                        builder: sidebarFooter,
                      );
                    })
                : sidebarFooter);