• Stars
    star
    106
  • Rank 314,945 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 3 years ago
  • Updated 9 months 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,450
star
2

LBYouTubeView

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

nuage-macos

A native SoundCloud app for macOS, written in SwiftUI
Swift
298
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

LBSegmentedButton

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

SoundCloud

The private SoundCloud API v2 in Swift
Swift
25
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

spotit

Python
8
star
16

SearchField

A GitHub-like search field for SwiftUI.
Swift
8
star
17

alexandria-extension

A browser extension for academic papers
TypeScript
8
star
18

swift-stm

An optimistic STM written in Swift
Swift
6
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

RetainCarousel

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

Blog

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

HackZurich

Objective-C
2
star
24

Spectral

A Β΅framework that adds hex support to UIColor/NSColor
Swift
2
star
25

AtomicLinkedList

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

nutshell-macos

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

poly

🌈 poly - a crowd-sourced and AI-assisted localization tool
Rust
1
star
28

hotkeyd

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