• Stars
    star
    251
  • Rank 161,862 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Swift DSL for navigation in iOS and tvOS apps with a simplified, chainable, and compile time safe syntax

Nivelir

Build Status Cocoapods Carthage compatible SPM compatible Platforms Xcode Swift License

Nivelir is a DSL for navigation in iOS and tvOS apps with a simplified, chainable, and compile time safe syntax.

Contents

Requirements

  • iOS 13.0+ / tvOS 13.0+
  • Xcode 14.0+
  • Swift 5.7+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Nivelir into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '13.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Nivelir', '~> 1.6.3'
end

Finally run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Nivelir into your Xcode project using Carthage, specify it in your Cartfile:

github "hhru/Nivelir" ~> 1.6.3

Finally run carthage update to build the framework and drag the built Nivelir.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate Nivelir into your Xcode project using Swift Package Manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/hhru/Nivelir.git", from: "1.6.3")

Then specify "Nivelir" as a dependency of the Target in which you wish to use Nivelir.

Here's an example Package.swift:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
    name: "MyPackage",
    products: [
        .library(name: "MyPackage", targets: ["MyPackage"])
    ],
    dependencies: [
        .package(url: "https://github.com/hhru/Nivelir.git", from: "1.6.3")
    ],
    targets: [
        .target(name: "MyPackage", dependencies: ["Nivelir"])
    ]
)

Usage

API Documentation

Quick Start

Let's implement a simple view controller that can set the background color:

class SomeViewController: UIViewController {

    let color: UIColor

    init(color: UIColor) {
        self.color = color

        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = color
    }
}

Next, we need to implement a builder that creates our controller:

struct SomeScreen: Screen {

    let color: UIColor

    func build(navigator: ScreenNavigator) -> UIViewController {
        SomeViewController(color: color)
    }
}

Now we can use this screen for navigation:

let navigator = ScreenNavigator()

navigator.navigate { route in
    route
        .top(.stack)
        .popToRoot()
        .push(SomeScreen(color: .red))
        .push(SomeScreen(color: .green)) { route in
            route.present(SomeScreen(color: .blue))
        }
}

This navigation performs the following steps:

  • Search for the topmost container of the stack (UINavigationController)
  • Resetting its stack to the first screen
  • Adding a red screen to the stack
  • Adding a green screen to the stack
  • Presenting a blue screen on the green screen modally

Cheat sheets

Learn the most common use cases for Nivelir. See article in API documentation.

Example App

Example app is a simple iOS and tvOS app that demonstrates how Nivelir works in practice. It's also a good place to start playing with the framework.

To install it, run these commands in a terminal:

$ git clone https://github.com/hhru/Nivelir.git
$ cd Nivelir/Example
$ pod install
$ open NivelirExample.xcworkspace

Articles and Videos

Articles

Videos

Communication

  • If you need help, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

📬 You can also write to us in telegram, we will help you: https://t.me/hh_tech

License

Nivelir is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

api

HeadHunter API: документация и библиотеки
518
star
2

android-multimodule-plugin

Kotlin
161
star
3

kotlin-swift-interopedia

148
star
4

nginx_requestid

Nginx request_id module
C
104
star
5

FigmaGen

Command line tool to generate code for styles using the Figma API.
Swift
63
star
6

frontik

Python
46
star
7

android-style-guide

Правила написания кода и утилиты, помогающие их поддерживать
FreeMarker
36
star
8

HandlersKit

HandlersKit is a light-weight iOS Framework that allows you to use modern closure syntax instead of the target-action and delegate patterns
Swift
34
star
9

nuts-and-bolts

Мейнтейнер: Команда Платформа. Web application framework for HeadHunter internal services
Java
25
star
10

hh-histories-android-multimodule-playground

Kotlin
25
star
11

mvi-swift

Swift
21
star
12

hh-histories-view-binding-migration-plugin

Kotlin
20
star
13

hh-histories-compose-custom-toolbar

Jetpack Compose toolbar implementation sample based on specification from HeadHunter design system
Kotlin
19
star
14

react-d3-chart-graphs

JavaScript
16
star
15

tornado-cassandra-client

Naive usage cassandra python client with tornado web server
Python
13
star
16

babel-plugin-react-displayname

JavaScript
12
star
17

hh-webutils

hh.ru python common web utility library
Python
10
star
18

school-tasks-tester

JavaScript
10
star
19

jetpack-compose-navigation-research

Kotlin
10
star
20

http-rpc

rpc over http implementation with protobuf and netty
Java
9
star
21

AnalyticsGen

Swift
8
star
22

school.hh.ru-java-stdlib

Java
8
star
23

tornado-protobuf-utils

Python
7
star
24

html-set-source-attribute

JavaScript
5
star
25

AdaptationProject

Java
5
star
26

babel-plugin-react-source

JavaScript
4
star
27

hh-histories-android-feature-toggles-playground

Kotlin
4
star
28

jclient-common

Maintainers: Вознесенский, пуллреквесты обязательны, страница миграций: https://wiki.hh.ru/pages/viewpage.action?pageId=322903998
Java
4
star
29

hh-histories-android-geminio-example

Maintainer: Шабаева Анна
Kotlin
3
star
30

pycerberus-deb

Pycerberus debian scripts
Python
2
star
31

hh-common-errors

Java
2
star
32

ssl-cert-check

Python
2
star
33

stylelint-config-hh

JavaScript
2
star
34

checkstyle

Java
2
star
35

hh-histories-ios-navigation-sample

Demo project for comparing navigation frameworks
Swift
1
star
36

SwiftGen-Example

Swift
1
star
37

jira-tax-stat

Python
1
star
38

jersey-hc-httpclient

HttpCommons HttpClient backend for Jersey
Java
1
star
39

python_social_auth

Python
1
star
40

hh-proto

Python
1
star
41

jersey-logging-filter

Java
1
star
42

metrics

Java
1
star
43

hh-java-logging

Java
1
star
44

eslint-plugin-import-rules

JavaScript
1
star
45

nginx-modules

Shell
1
star
46

janet

Java
1
star