Skip to content

Releases: SwiftfulThinking/SwiftfulRouting

5.3.6

22 Aug 15:08
Compare
Choose a tag to compare

Fix a crash within TransitionSupportViewBuilder when dismissTransition is called multiple times in immediate succession

Full Changelog: 5.3.5...5.3.6

5.3.5

06 Jun 01:33
02a6e29
Compare
Choose a tag to compare
  • Fixing bug where calling dismissScreenStack multiple on an app's Root View didn't work.

What's Changed

Full Changelog: 5.3.4...5.3.5

5.3.4

12 May 21:26
Compare
Choose a tag to compare
  • Add dismissOnBackgroundTap to modal configuration, to disable taps on background layer. Default value remains TRUE.

5.3.3

12 May 19:56
0d8b953
Compare
Choose a tag to compare
  • Fix bug: dismissModal did not work when accessed through Environment variables
  • Fix bug: when displaying multiple modals with background layers, each background was behind all of the modals. Now they are stacked where the background of the top-most modal is above the 2nd-highest modal.
  • Update Readme: include code for adding swipe-back gesture support within Dismiss section

5.3.2

04 Mar 15:47
Compare
Choose a tag to compare

Fix bug from 5.3.1 where swipe-back gesture doesn't render on TransitionSupportViewBuilder

5.3.1

02 Mar 03:23
dc16487
Compare
Choose a tag to compare

Minor updates. Compiler breaking changes:

  • showModal no longer supports BackgroundEffect
  • showModal useDeviceBounds has been renamed ignoreSafeArea
  • AlertOption has been renamed DialogOption

Multiple Modals

Details (Click to expand)

You can now display multiple modals simultaneously (previously 1). Modals have an optional ID field, which can later be used to dismiss the modal.

router.showModal(id: "top1") {
     Text("Sample")
}

// Dismiss top-most modal
router.dismissModal()

// Dismiss modal by ID
router.dismissModal(id: "top1")

// Dismiss all modals
router.dismissAllModules()

Transition View Builder

Details (Click to expand)

Wrap your view in a TransitionViewBuilder to transition the current screen's context. This will change the content without changing the parent View hierarchy (ie. using transitions and not traditional segues).

Set allowsSwipeBack to FALSE disable swipe-back behavior on the transitioned screen.
Set allowSimultaneous to FALSE to render only one view at a time.

TransitionSupportViewBuilder(router: router, allowsSwipeBack: Bool, allowSimultaneous: Bool) { transitionRouter in
     Text("Hello, world!")
          .onTapGesture {
               transitionRouter.showTransition(transition: .trailing) { _ in
                    Rectangle()
               }
          }
}
// Dismiss current transition
transitionRouter.dismissTransition()

Beta 6.0

23 Jan 00:56
f95e323
Compare
Choose a tag to compare
Beta 6.0 Pre-release
Pre-release

Transition Screen

Details (Click to expand)

Use a screen transition to replace the current screen with a new one. This is not the same as a segue and will deallocate the first screen entirely. This changes the current view without affecting the surrounding view hierarchy.

router.transitionScreen(.leading) { router in
     Text("Screen1.1")
}
router.transitionScreen(.trailing) { router in
     Text("Screen1.2")
}

Dismiss most recent transition.

router.dismissTransition()

Dismiss all transitions to root.

router.dismissAllTransitions()

Transition Module

Details (Click to expand)

Modules are high-level containers for your app, where each module has it's own View hierarchy. This will change the entire hierarchy in your app, dismissing the root NavigationView as well as all screens displayed on top. Use this for things like "show onboarding" vs "show tabbar".

router.transitionModule(id: "onboarding", .leading) { router in
     Text("Onboarding View")
}
router.transitionModule(id: "home", .trailing) { router in
     Text("Home View")
}

The user's last module ID will persist across app sessions. This is returned when creating a RouterView and can be used to restore the user's previous module.

RouterView(addNavigationView: true) { (router, lastModuleId) in
     if lastModuleId == "home" {
          Text("Home View")
     } else {
          Text("Onboarding View")
     }
}

Multiple Modals

Details (Click to expand)

You can now display multiple modals simultaneously (previously 1). Modals have an optional ID, which can later be used to dismiss the modal.

router.showModal(id: "top1") {
     Text("Sample")
}

// Dismiss top-most modal
router.dismissModal()

// Dismiss modal by ID
router.dismissModdal(id: String)

// Dismiss all modals
router.dismissAllModules()

5.1.0

17 Jan 02:23
f32b6fb
Compare
Choose a tag to compare

Major release. See updated ReadMe.

  • Add Router to SwiftUI Environment
  • Add Screen Flow support
  • Add onDismiss to all segues
  • Various code tweaks & refactoring

What's Changed

Full Changelog: 4.0.3...5.1.0

v5.0-beta (multi-screen support)

04 Sep 21:14
7de396a
Compare
Choose a tag to compare
Pre-release

This update brings multi-screen support to the framework. Previously, we could only manage one screen at a time. Now, we can create and set of screens (or a flow) from a single call.

let screen1 = { router in
     MyView(router: router, count: 369)
}
let screen2 = { router in
     MyView(router: router, count: 444)
}
let screen3 = { router in
     MyView(router: router, count: 1000000)
}
let screen4 = { router in
     MyView(router: router, count: 123)
}
                
router.showScreens([
     AnyRoute(.fullScreenCover, destination: screen1),
     AnyRoute(.push, destination: screen2),
     AnyRoute(.push, destination: screen3),
     AnyRoute(.push, destination: screen4),
])

Once projects move towards this "flow" setup, the routing logic in each child view can be simplified to a simple "go to next screen". The "next screens" are set from a previous call to showScreens where the next screen is the next screen in the array.

try router.showNextScreen()

This update also introduces the ability to dismiss an environment. This will dismiss the top-most Sheet or FullScreenCover.

router.dismissEnvironment()

In the example above, there are 4 screens, the first one shows a fullScreenCover and then the following 3 screens are shown via push. From any of those screens, I can call dismissEnvironment and it will dismiss the fullScreenCover, which effectively dismisses the entire flow.

This is perfect for peripheral flows in your app, such as Onboarding, where you could present a FullScreenCover and then push to as many screens as needed. At the end of the flow, dismiss the environment!

A combination of these will simplify the routing logic in your flows. In the above example, I would build each of the screens with a generic call to action button, that would first attempt to go to the next screen in the flow, but otherwise fallback to dismissing the environment.

router.showNextScreenOrDismissEnvironment()

4.0.3

30 Aug 20:39
59c2752
Compare
Choose a tag to compare

Improvement

Update showAlert so that iOS 15 no longer needs "buttonsiOS13" parameter.

@available(iOS 15, *)
router.showAlert(.alert, title: String, subtitle: String, alert: {
})
@available(iOS 14, *)
router.showAlert(.alert, title: String, subtitle: String, buttonsiOS13: [Alert.Button]?, alert: {
})