Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Docs/Images/ArchitectureDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Pure Native

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# StatefulArch

A description of this package.
This package contains a set of useful entities to develop scalable iOS applications using either SwiftUI or UIKit along with Combine.

## Requirements

- Swift 5.7 or newer
- iOS 14.0 or newer

## Installation

You can install this package using [Swift Package Manager](https://www.swift.org/package-manager/) by adding the following line to the `dependencies` in your `Package.swift` file:

```swift
.package(url: "https://github.com/purenative/StatefulArch.git", .upToNextMajor(from: "1.0.0"))
```

## Architecture Overview

StatetefulArch proposes to split screens into independent parts called modules which of them consists of three main components - View, Interceptor and State.

![architecture diagram](Docs/Images/ArchitectureDiagram.png)

### View

View is responsible for user interface and it doesn't contain any business logic or input data validations. Also it delegates user actions processing to Interceptor.

### Interceptor

Interceptor processes user actions received from View and updates State. Interceptor may contain input data validations but it's not responsible for business logic directly.

*There is another entity in this architecture called Scenario which is responsible for business logic. Scenario isn't displayed on the diagram due to business logic optionality - some screens may not contain business logic such as screens which only consist of static content.*

### State

This entity stores screen's state and determines View's behavior.

## Contributing

Don't forget to open an issue if you found a bug or have a question. Feel free to fork this repository and open a pull request if you fixed an existing feature or implemented a new one.

## License

StatefulArch is released under the MIT license. See LICENSE for details.
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Abstracts/PageInterceptor.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// PageInterceptor.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import Combine

public protocol PageInterceptor: AnyObject {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Abstracts/PageState.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// PageState.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import Combine

public protocol PageState: ObservableObject {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Abstracts/PageView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// PageView.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import SwiftUI

public protocol PageView: View, ModuleConvertible {
Expand Down
11 changes: 11 additions & 0 deletions Sources/StatefulArch/Abstracts/ServiceProvider.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// ServiceProvider.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

public protocol ServiceProvider {

func provideService<T>() -> T
Expand Down
9 changes: 9 additions & 0 deletions Sources/StatefulArch/Base/BasePageInterceptor.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
//
// BasePageInterceptor.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

open class BasePageInterceptor<Action, State: PageState, LaunchInfo>: PageInterceptor {
Expand Down
11 changes: 11 additions & 0 deletions Sources/StatefulArch/Base/PageLifeCycleEvent.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// PageLifeCycleEvent.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

public enum PageLifeCycleEvent {

case didLoad
Expand Down
11 changes: 10 additions & 1 deletion Sources/StatefulArch/Base/PageScenario.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import Combine
//
// PageScenario.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import Combine

@MainActor
open class PageScenario {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Base/PageViewHostingController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// PageViewHostingController.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import SwiftUI

public class PageViewHostingController<Page: PageView>:
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Module/Module+ModuleConvertible.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// Module+ModuleConvertible.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit
import SwiftUI

Expand Down
11 changes: 11 additions & 0 deletions Sources/StatefulArch/Module/ModuleAssembler.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// ModuleAssembler.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

@MainActor
public struct ModuleAssembler {

Expand Down
11 changes: 11 additions & 0 deletions Sources/StatefulArch/Module/ModuleBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// ModuleBuilder.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

public protocol ModuleBuilder {

@MainActor
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Module/ModuleOptions.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// ModuleOptions.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit

public struct ModuleOptions {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Navigation/Navigation+Default.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// Navigation+Default.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit

public final class RootNavigation: Navigation {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Navigation/Navigation.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// Navigation.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit

public protocol Navigation {
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Navigation/NavigationService.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// NavigationService.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import Dispatch

@MainActor
Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Navigation/RootView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// RootView.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit
import SwiftUI

Expand Down
10 changes: 10 additions & 0 deletions Sources/StatefulArch/Navigation/RootViewController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//
// RootViewController.swift
// StatefulArch
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation
import UIKit

public class RootViewController: UIViewController {
Expand Down