Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 1.9 KB

API_OVERVIEW.md

File metadata and controls

94 lines (70 loc) · 1.9 KB

API Overview

Get a comprehensive overview of the Navigator API and its components.

1. Navigator Class

Central class for managing navigation paths and modals.

Properties

  • path: NavigationPath - Represents the current navigation stack.
  • alert: NavigatorAlert? - The currently presented alert.
  • sheet: NavigatorSheet? - The currently presented sheet.
  • confirmDialog: NavigatorConfirmDialog? - The currently presented confirmation dialog.

Methods

  • append(_ value: Hashable) - Navigate to a new view.

    navigator.append(
        YourDestination()
    )
  • removeLast(_ count: Int = 1) - Navigate back by removing views from the stack.

    navigator.removeLast(
        count: 2
    )
  • popToRoot() - Reset navigation to the root view.

    navigator.popToRoot()
  • alert(title:message:actions:) - Present an alert.

    navigator.alert(
        title: "Alert Title",
        message: {
            Text("Alert Message")
        },
        actions: {
            NavigatorButton("OK") { $0.dismiss() }
        }
    )
  • sheet(content:onDismiss:) - Present a sheet.

    navigator.sheet(
        content: {
            SheetView()
        },
        onDismiss: {
            // Optional dismissal action
        }
    )
  • confirmDialog(title:message:actions:) - Present a confirmation dialog.

    navigator.confirmDialog(
        title: "Confirm Action",
        message: {
            Text("Are you sure?")
        },
        actions: {
            NavigatorButton("Yes") { $0.dismiss() }
            NavigatorButton("No") { $0.dismiss() }
        }
    )
  • dismiss() - Dismiss the current modal or navigate back.

    navigator.dismiss()

What's Next?

Discover patterns and best practices to design scalable and maintainable navigation flows.

Go to Patterns and Best Practices →