diff --git a/Docs/Images/ArchitectureDiagram.png b/Docs/Images/ArchitectureDiagram.png new file mode 100644 index 0000000..5af7c19 Binary files /dev/null and b/Docs/Images/ArchitectureDiagram.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6b2a3b0 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 93c63cb..66d6633 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Sources/StatefulArch/Abstracts/PageInterceptor.swift b/Sources/StatefulArch/Abstracts/PageInterceptor.swift index 2ee2c57..7e59179 100644 --- a/Sources/StatefulArch/Abstracts/PageInterceptor.swift +++ b/Sources/StatefulArch/Abstracts/PageInterceptor.swift @@ -1,3 +1,13 @@ +// +// PageInterceptor.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import Combine public protocol PageInterceptor: AnyObject { diff --git a/Sources/StatefulArch/Abstracts/PageState.swift b/Sources/StatefulArch/Abstracts/PageState.swift index 57220a2..85c35a9 100644 --- a/Sources/StatefulArch/Abstracts/PageState.swift +++ b/Sources/StatefulArch/Abstracts/PageState.swift @@ -1,3 +1,13 @@ +// +// PageState.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import Combine public protocol PageState: ObservableObject { diff --git a/Sources/StatefulArch/Abstracts/PageView.swift b/Sources/StatefulArch/Abstracts/PageView.swift index 8fe5647..deca3f9 100644 --- a/Sources/StatefulArch/Abstracts/PageView.swift +++ b/Sources/StatefulArch/Abstracts/PageView.swift @@ -1,3 +1,13 @@ +// +// PageView.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import SwiftUI public protocol PageView: View, ModuleConvertible { diff --git a/Sources/StatefulArch/Abstracts/ServiceProvider.swift b/Sources/StatefulArch/Abstracts/ServiceProvider.swift index 39f8cfe..9fc1a5d 100644 --- a/Sources/StatefulArch/Abstracts/ServiceProvider.swift +++ b/Sources/StatefulArch/Abstracts/ServiceProvider.swift @@ -1,3 +1,14 @@ +// +// ServiceProvider.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation + public protocol ServiceProvider { func provideService() -> T diff --git a/Sources/StatefulArch/Base/BasePageInterceptor.swift b/Sources/StatefulArch/Base/BasePageInterceptor.swift index 6aa9c50..e426179 100644 --- a/Sources/StatefulArch/Base/BasePageInterceptor.swift +++ b/Sources/StatefulArch/Base/BasePageInterceptor.swift @@ -1,3 +1,12 @@ +// +// BasePageInterceptor.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + import Foundation open class BasePageInterceptor: PageInterceptor { diff --git a/Sources/StatefulArch/Base/PageLifeCycleEvent.swift b/Sources/StatefulArch/Base/PageLifeCycleEvent.swift index 5c84884..4ef1fcf 100644 --- a/Sources/StatefulArch/Base/PageLifeCycleEvent.swift +++ b/Sources/StatefulArch/Base/PageLifeCycleEvent.swift @@ -1,3 +1,14 @@ +// +// PageLifeCycleEvent.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation + public enum PageLifeCycleEvent { case didLoad diff --git a/Sources/StatefulArch/Base/PageScenario.swift b/Sources/StatefulArch/Base/PageScenario.swift index 056c048..4b7ba3e 100644 --- a/Sources/StatefulArch/Base/PageScenario.swift +++ b/Sources/StatefulArch/Base/PageScenario.swift @@ -1,5 +1,14 @@ -import Combine +// +// PageScenario.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + import Foundation +import Combine @MainActor open class PageScenario { diff --git a/Sources/StatefulArch/Base/PageViewHostingController.swift b/Sources/StatefulArch/Base/PageViewHostingController.swift index 4c49677..35e8e2c 100644 --- a/Sources/StatefulArch/Base/PageViewHostingController.swift +++ b/Sources/StatefulArch/Base/PageViewHostingController.swift @@ -1,3 +1,13 @@ +// +// PageViewHostingController.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import SwiftUI public class PageViewHostingController: diff --git a/Sources/StatefulArch/Module/Module+ModuleConvertible.swift b/Sources/StatefulArch/Module/Module+ModuleConvertible.swift index 58a9b72..f91785e 100644 --- a/Sources/StatefulArch/Module/Module+ModuleConvertible.swift +++ b/Sources/StatefulArch/Module/Module+ModuleConvertible.swift @@ -1,3 +1,13 @@ +// +// Module+ModuleConvertible.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit import SwiftUI diff --git a/Sources/StatefulArch/Module/ModuleAssembler.swift b/Sources/StatefulArch/Module/ModuleAssembler.swift index a98599a..687a416 100644 --- a/Sources/StatefulArch/Module/ModuleAssembler.swift +++ b/Sources/StatefulArch/Module/ModuleAssembler.swift @@ -1,3 +1,14 @@ +// +// ModuleAssembler.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation + @MainActor public struct ModuleAssembler { diff --git a/Sources/StatefulArch/Module/ModuleBuilder.swift b/Sources/StatefulArch/Module/ModuleBuilder.swift index 07010a6..53fc97e 100644 --- a/Sources/StatefulArch/Module/ModuleBuilder.swift +++ b/Sources/StatefulArch/Module/ModuleBuilder.swift @@ -1,3 +1,14 @@ +// +// ModuleBuilder.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation + public protocol ModuleBuilder { @MainActor diff --git a/Sources/StatefulArch/Module/ModuleOptions.swift b/Sources/StatefulArch/Module/ModuleOptions.swift index 5a1c42b..0a9cb30 100644 --- a/Sources/StatefulArch/Module/ModuleOptions.swift +++ b/Sources/StatefulArch/Module/ModuleOptions.swift @@ -1,3 +1,13 @@ +// +// ModuleOptions.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit public struct ModuleOptions { diff --git a/Sources/StatefulArch/Navigation/Navigation+Default.swift b/Sources/StatefulArch/Navigation/Navigation+Default.swift index bde6040..66a7f57 100644 --- a/Sources/StatefulArch/Navigation/Navigation+Default.swift +++ b/Sources/StatefulArch/Navigation/Navigation+Default.swift @@ -1,3 +1,13 @@ +// +// Navigation+Default.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit public final class RootNavigation: Navigation { diff --git a/Sources/StatefulArch/Navigation/Navigation.swift b/Sources/StatefulArch/Navigation/Navigation.swift index ea7f968..ba18cfe 100644 --- a/Sources/StatefulArch/Navigation/Navigation.swift +++ b/Sources/StatefulArch/Navigation/Navigation.swift @@ -1,3 +1,13 @@ +// +// Navigation.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit public protocol Navigation { diff --git a/Sources/StatefulArch/Navigation/NavigationService.swift b/Sources/StatefulArch/Navigation/NavigationService.swift index f60b2b4..ec99551 100644 --- a/Sources/StatefulArch/Navigation/NavigationService.swift +++ b/Sources/StatefulArch/Navigation/NavigationService.swift @@ -1,3 +1,13 @@ +// +// NavigationService.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import Dispatch @MainActor diff --git a/Sources/StatefulArch/Navigation/RootView.swift b/Sources/StatefulArch/Navigation/RootView.swift index 332d0d0..f9473a6 100644 --- a/Sources/StatefulArch/Navigation/RootView.swift +++ b/Sources/StatefulArch/Navigation/RootView.swift @@ -1,3 +1,13 @@ +// +// RootView.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit import SwiftUI diff --git a/Sources/StatefulArch/Navigation/RootViewController.swift b/Sources/StatefulArch/Navigation/RootViewController.swift index ed52b83..595f3e7 100644 --- a/Sources/StatefulArch/Navigation/RootViewController.swift +++ b/Sources/StatefulArch/Navigation/RootViewController.swift @@ -1,3 +1,13 @@ +// +// RootViewController.swift +// StatefulArch +// +// MIT License +// +// Copyright (c) 2022 Pure Native +// + +import Foundation import UIKit public class RootViewController: UIViewController {