Plug and play modular SideBar for macOS / iPad
SideBarKit is a customizable Sidebar framework. Decouple the sidebar implementation. This results in cleaner, more manageable code.
- 🔄 Toggleable groups (hide / show)
- 🏷️ Reactive tag labels (count change reactively)
- 🌗 Dark / Light mode support
- 🧩 BYO (Bring your own) enum models
@State var selectedIdx: CombinedIndex? = .init(group: 0, item: 0) // Track selection
let model = [Top(), Middle(), Bottom()] // Define your model
MenuStack(selectedIndex: $selectedIdx, groups: model) // Add sidebar view
Defining a Custom Group:
struct CustomGroup: GroupKind {
let title: String = "Custom Group"
typealias EnumType = Items
enum Items: String, CaseIterable {
case first = "First Item"
case second = "Second Item"
}
func getItem(item: Items) -> any RowKind {
// Return your custom row
}
}
Defining a Custom Row:
struct CustomRowModel: RowKind {
let title: String
let action: () -> Void
// Additional properties and methods
}
To install SideBarKit using Swift Package Manager, add the following dependency to your Package.swift
file:
.package(url: "https://github.com/sentryco/SideBarKit", branch: "main")
- Add a way to customize metrics a bit. paddings, offsets etc to match original component
- Consider removing binding from selection var. Bidning might not be needed
- Remove unit-tests
- Add UITests
- Tag count may not need to be a binding
- Tweak padding around groups. Looks too tall when collapsed
- Make sure icons keeps its aspect ratio, double check this
- Consider implementing toggle compact-mode / expanded-mode functionality etc, or not? at least wait and do it later when things are 👉 more stable 👈 etc (align icons to support compact mode)
- Consider persisting collapsed state
- Consider persisting selected index
- start refactoring to use async/await where appropriate.
- reorg files:
Sources/
└── SideBarKit/
├── style/
│ ├── MenuTagStyle.swift
│ └── RowTextStyle.swift