• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A SwiftUI component for macOS that makes complex view hierarchies possible

StackNavigationView

Twitter: @lbrndnr License

โš ๏ธ SwiftUI now supports NavigationStack, making this repo redundant for new projects. I recommend to only use this if you have to support macOS 11 or 12. โš ๏ธ

About

As of SwiftUI v2, NavigationView only supports a simple sidebar selection. This makes it impossible to push new views onto the view hierarchy, as one could do e.g. with UINavigationController. This project is a workaround that builds upon NavigationView to support complex view hierarchies.

Demo

Usage

The interface of StackNavigationView is very similar to the one of NavigationView, just make sure not to use NavigationLink inside of StackNavigationView though, it will result in undefined behaviour. You'll find the full example here.

struct ContentView: View {

@State private var selection: Int? = 0

var body: some View {
    
    return StackNavigationView(selection: $selection) {
        List {
            SidebarNavigationLink("Apples", destination: rootView(title: "Apples"), tag: 0, selection: $selection)
            SidebarNavigationLink("Bananas", destination: rootView(title: "Bananas"), tag: 1, selection: $selection)
            SidebarNavigationLink("Clementines", destination: rootView(title: "Clementines"), tag: 2, selection: $selection)
        }
        Text("Empty Selection")
    }
    .frame(minWidth: 600, minHeight: 400)
}

@ViewBuilder private func rootView(title: String) -> some View {
    VStack {
        Text("This is the root view of \(title)")
            .font(.system(size: 50))
            .bold()
        Spacer()
            .frame(height: 40)
        StackNavigationLink("Next", destination: ChildView(sidebar: title, level: 1))
    }
    .padding(20)
    .navigationTitle(title)
}
}

Requirements

StackNavigationView is a SwiftUI component for macOS. macOS Big Sur is required.

Author

I'm Laurin Brandner, I'm on Twitter.

License

StackNavigationView is licensed under the MIT License.

More Repositories

1

ImagePickerSheetController

ImagePickerSheetController replicates the custom photo action sheet in iMessage.
Swift
1,447
star
2

LBYouTubeView

A MPMoviePlayerViewController subclass that can display YouTube videos.
Objective-C
526
star
3

nuage-macos

A native SoundCloud app for macOS, written in SwiftUI
Swift
327
star
4

LBGIFImage

This is a small category that creates an animated UIImage out of a gif image.
Objective-C
174
star
5

LBProgressBar

This is a custom subclass of NSProgressIndicator designed by Orman Clark (http://www.premiumpixels.com/)
Objective-C
87
star
6

LBGradient

NSGradient for iOS
Objective-C
68
star
7

ImagePickerTrayController

The iOS 10 version of ImagePickerSheetController
Swift
68
star
8

LBActionSheet

A very customizable drop-in replacement for UIActionSheet
Objective-C
47
star
9

LBAudioDetective

An audio fingerprinting library to compare audio signals
Objective-C
40
star
10

SoundCloud

The private SoundCloud API v2 in Swift
Swift
34
star
11

LBSegmentedButton

This is a twitter-like button.
Objective-C
29
star
12

MuseumGuide

A small framework that makes UIImage accessible
Swift
22
star
13

Sweets

A framework that extends UIKit so that it's somewhat convenient to use with Swift
Swift
16
star
14

ethz-summaries-b15

Cheat Sheets und Zusammenfassungen Basisjahr D-INFK 2015/16 ETHZ
TeX
12
star
15

SearchField

A GitHub-like search field for SwiftUI.
Swift
9
star
16

alexandria-extension

A browser extension for academic papers
TypeScript
9
star
17

spotit

Python
8
star
18

swift-stm

An optimistic STM written in Swift
Swift
7
star
19

Scholarship

iPad app that I use as a resume to apply for scholarships.
Swift
5
star
20

wink

A little script that takes a picture when you wink
Python
4
star
21

nutshell-macos

An AI-powered note-taking app for your meetings. Built for macOS using SwiftUI.
Swift
4
star
22

RetainCarousel

This is a small category that helps you finding retain cycles.
Objective-C
4
star
23

Blog

Source code for my blog posts
Objective-C
3
star
24

HackZurich

Objective-C
2
star
25

Spectral

A ยตframework that adds hex support to UIColor/NSColor
Swift
2
star
26

AtomicLinkedList

A lazy, lock-free linked list
Swift
2
star
27

http-echo-rs

An echo service for HTTP
Rust
1
star
28

sca-rs

A scapy-inspired packet parsing library
Rust
1
star
29

poly

๐ŸŒˆ poly - a crowd-sourced and AI-assisted localization tool
Rust
1
star
30

hotkeyd

Simple and hackable global keyboard shortcuts for macOS.
Rust
1
star