Giter Site home page Giter Site logo

mswiftuinavigator's Introduction

MSwiftUINavigator

MSwiftUINavigator is a Swift package that provides a navigation solution for SwiftUI applications, leveraging the UIKit navigation system. It simplifies common navigation tasks and integrates seamlessly with SwiftUI views.

Features

  • Push views onto the navigation stack.
  • Present views modally with custom transition and presentation styles.
  • Dismiss views and navigate back.
  • Pop to the root view.
  • Present sheets with customizable sizes using the FittedSheets library.
  • Present dialogs and action sheets above the current view.
  • Pop to a specific view type in the navigation stack.
  • Present dialogs and action sheets above the current view, with options for customizations.

Installation

You can add MSwiftUINavigator to your Swift package by adding it as a dependency in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/MahmoudAbdelshafi/MSwiftUINavigator.git", .branch("main"))
],

Usage

To use MSwiftUINavigator in your SwiftUI project, you'll need to import it and conform to the Navigator protocol in the main view where you want to use the navigator:

import MSwiftUINavigator

struct ContentView: View, Navigator {
    // Your view code here
}

Additionally, you can access the Navigator as an @Environment object:

@Environment(\.navigator) var navigator

navigator.presentSheet {
    // Your view code here
}

navigator.pushView {
    // Your view code here
}

To present an action sheet, you can use the presentActionSheet function provided by MSwiftUINavigator:

navigator.presentActionSheet {
    ActionSheet(
        title: Text("Choose an action"),
        message: Text("What would you like to do?"),
        buttons: [
            .default(Text("Option 1")) {
                // Handle option 1
            },
            .default(Text("Option 2")) {
                // Handle option 2
            },
            .cancel()
        ]
    )
}

For singleton access to the NavigationManager, you can use the shared instance like this:

NavigationManager.shared.presentView(transitionStyle: .coverVertical,
                                      presentStyle: .fullScreen,
                                      animated: true) {
                // Your View here
}

There's also an example project available on GitHub for reference: MSwiftUINavigatorExample.

Dependencies

MSwiftUINavigator relies on the following external dependency to enhance its functionality, particularly for handling popups, sheets, and dialogs:

  • FittedSheets: FittedSheets is a powerful library available on GitHub that provides advanced capabilities for presenting sheets with customizable sizes and behaviors. MSwiftUINavigator utilizes FittedSheets to create dynamic and interactive sheet presentations, enhancing the user experience when displaying popups, sheets, and dialogs in your SwiftUI applications.

License

This package is released under the MIT License.

Author

mswiftuinavigator's People

Contributors

mahmoudabdelshafi avatar

Stargazers

Acassio Mendonça Vilas Boas avatar Yevhenii Serdiukov avatar Abdelhamid Nasser avatar Anas Amer avatar Dzhunet Hasan avatar Jobie Peng avatar Pavel Ermakov avatar Tomasz Kubiak avatar Harshal Kulkarni avatar Covalent avatar Dursun Yıldız avatar Kristoffer Knape avatar Omar R. avatar Karim Ebrahem avatar Narcis avatar Umair Irfan avatar  avatar  avatar Sherif Darwish avatar  avatar Mohamed Shimy avatar Sharan Thakur avatar  avatar Barczi avatar Shervin Koushan avatar Rodrigo A. Cavalcanti avatar soliman avatar Mohaned Yossry avatar

Watchers

 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.