Skip to content

Repository files navigation

FlowKit

SwiftPlatformsSwift Package ManagerLicense

SwiftUI is great. But navigation isn't.

FlowKit is the ideal navigation library for SwiftUI.

Requirements

PlatformMinimum Swift VersionInstallation
iOS 13.0+5.5Swift Package Manager

Installation

Swift Package Manager

  • File -> Add Packages... And paste the repository URL.
  • Or add it to the dependencies value of your Package.swift.
dependencies:[.package(url:"https://github.com/Mercen-Lee/FlowKit.git",.branch("main"))]

Usage

  • Push View
flow.push(NextView())
// or
flow.push(NextView(), animated:false)
  • Pop View
flow.pop()
flow.pop(3) // 3 Views
  • Pop View to Root
flow.popToRoot()
  • Replace Views
flow.replace([FirstView(),SecondView()])
  • Reload View
flow.reload()
  • Present Sheet
flow.sheet(SheetView())
  • Present Alert
letalert=Alert(title:"Error",
message:"Not Found",
dismissButton:.default("Ok"))
flow.alert(alert)

Example

App

import SwiftUI
import FlowKit
@mainstructSampleApp:App{varbody:someScene{WindowGroup{FlowPresenter(rootView:ContentView())}}}

View

structContentView:View{@Flowvarflowvarbody:someView{Button{
flow.push(NextView())} label:{Text("Push")}}}structNextView:View{@Flowvarflowvarbody:someView{Button{
flow.pop()} label:{Text("Pop")}}}

TCA Example

Dependency

structFlowDependency:DependencyKey{staticvarliveValue:FlowProvider{FlowProvider(rootView:ContentView())}}extensionDependencyValues{varflow:FlowProvider{get{self[FlowDependency.self]}set{self[FlowDependency.self]= newValue }}}

Reducer

structContent:Reducer{@Dependency(\.flow)varflow...}

About

Elegant Navigation in SwiftUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages