Giter Club home page Giter Club logo

navigation-stack-backport's Introduction

SwiftUI NavigationStack Backport

NavigationStack for iOS 14 and 15 implemented on top of UINavigationController. Backport just bridges to existing SwiftUI API on iOS 16 or newer.

Features

  • NavigationPath is fully supported including codable representation
  • View.navigationDestination() and View.navigationDestination(isPresented:destination:)
  • NavigationLink with value
  • for now tested only on iOS

Getting Started

Installation via Swift Package Manager is supported. Use https://github.com/lm/navigation-stack-backport as depedency URL. For more information how to add dependency in Xcode see https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app or add dependency in your Package.swift .package(url: "https://github.com/lm/navigation-stack-backport", from: "1.0.0")

Usage Example

Usage is the same as SwiftUI's NavigationStack on iOS 16, just prefix NavigationStack and other types with NavigationStackBackport. or import exact types from NavigationStackBackport package. For view modifiers introduced in iOS 16 use backport. prefix like .backport.navigationDestination(for: โ€ฆ).

import NavigationStackBackport

struct ContentView: View {
	@State private var navigationPath = NavigationStackBackport.NavigationPath()

	var body: some View {
			NavigationStackBackport.NavigationStack(path: $navigationPath) {
				Button("Push") {
					navigationPath.append("Hello World")
				}
				.backport.navigationDestination(for: String.self) { value in
					Image(systemName: "globe")
						.navigationTitle(value) // use available SwiftUI's modifiers
				}
			}
	}
}

For more examples see the TestApp within this repository.

navigation-stack-backport's People

Contributors

lm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.