Swiftpack.co - The-Igor/d3-menu-bar as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by The-Igor.
The-Igor/d3-menu-bar v2.0.0
Customizable multi platform menu bar component with the dark and light scheme support - SwiftUI
โญ๏ธ 2
๐Ÿ•“ 4 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/The-Igor/d3-menu-bar.git", from: "v2.0.0")

Menu bar component (SwiftUI)

Features

  • โ˜‘ Observing menu selection changes via generic PreferenceKey
  • โ˜‘ The color intensity automatically adjusts depending on color scheme (Color+Ext.swift) You don't need to set color for every scheme
  • โ˜‘ Various strategies for the item menu width allocation
  • โ˜‘ Set scroll position according the initial selection
  • โ˜‘ Setting custom colors for the component
  • โ˜‘ Customize menu item style [round or square]
  • โ˜‘ iOS and macOS support
  • โ˜‘ Dark and light scheme support

Documentation(API)

  • You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
  • Go to Product > Build Documentation or โŒƒโ‡งโŒ˜ D

Required

1. enum

Define enum with menu items conforming to IMenuItem

enum MenuItems: String, IMenuItem {
    case one = "one"
    case two = "two"
    case three = "three"
}

2. create menu bar

  • selected - pass value bound to @State var selected : MenuItems?
  • values - Pass allCases as a parameter
MenuBar(values: MenuItems.allCases, selected: $selected)
  .onSelectionChanged{ item in }

Optional

  • strategy - default strategy for the item menu width allocation is auto
Size strategy Description
fit Alocate all affodable space not scrollable
auto Auto size acoording the content
flex(CGFloat) Set up minimal width
  • color - default value is .black

  • style - default style is round

Style Description
round rounded corners
square squared corners

Component init examples

    @State var selected : MenuItems?

   VStack{
        MenuBar(values: items, selected: $selected, strategy: .flex(102), color: .green)
        MenuBar(values: items, selected: $selected, color: .purple, style: .square)
        MenuBar(values: items, selected: $selected, strategy: .fit, color: .blue)        
        MenuBar(values: items, selected: $selected, color: .red)
    } 

click to watch expected UI behavior for the example

Code example

Take a look on the example preview in MenuContentView.swift or create a project, add the package and put MenuContentView() in ContentView()

Used in

Auto scrollable header menu - SwiftUI & Combine

GitHub

link
Stars: 2
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

Menu bar component
4 weeks ago

Menu bar component

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics