Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ are commonly used.
When using Swift package manager install using or add following line to your dependencies:

```swift
.package(url: "https://github.com/futuredapp/FuturedKit.git", from: "1.0.0")
.package(url: "https://github.com/futuredapp/FuturedKit.git", from: "2.0.0")
```

The repository provides number of Xcode Templates for user convenience.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import EnumIdentable
import FuturedArchitecture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import ProxyMembers

Expand All @@ -11,7 +11,7 @@ nonisolated struct ___VARIABLE_sceneIdentifier___CacheProjection: CacheProjectio
Self(state: state, data: .mock)
}

static func data(from cache: DataCacheModel) -> Self? {
static func data(from _: DataCacheModel) -> Self? {
// TODO: Map cache data to projection
nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import SwiftUI

Expand All @@ -16,9 +16,9 @@ struct ___VARIABLE_sceneIdentifier___Component<Model: ___VARIABLE_sceneIdentifie
}

#if DEBUG
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import FuturedArchitecture
import Observation
Expand All @@ -11,7 +11,6 @@ protocol ___VARIABLE_sceneIdentifier___ComponentModelProtocol: ComponentModel {

@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModel: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {

let onEvent: (Event) -> Void

private let dataCache: DataCache<DataCacheModel>
Expand All @@ -38,13 +37,13 @@ extension ___VARIABLE_sceneIdentifier___ComponentModel {
}

#if DEBUG
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event

var onEvent: (Event) -> Void = { _ in }
var projection: ___VARIABLE_sceneIdentifier___CacheProjection = .empty(state: .ready)
var onEvent: (Event) -> Void = { _ in }
var projection: ___VARIABLE_sceneIdentifier___CacheProjection = .empty(state: .ready)

func onAppear() async {}
}
func onAppear() async {}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import SwiftUI

Expand All @@ -14,9 +14,9 @@ struct ___VARIABLE_sceneIdentifier___Component<Model: ___VARIABLE_sceneIdentifie
}

#if DEBUG
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import FuturedArchitecture
import Observation
Expand All @@ -9,7 +9,6 @@ protocol ___VARIABLE_sceneIdentifier___ComponentModelProtocol: ComponentModel {

@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModel: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {

let onEvent: (Event) -> Void

private let dataCache: DataCache<DataCacheModel>
Expand All @@ -35,12 +34,12 @@ extension ___VARIABLE_sceneIdentifier___ComponentModel {
}

#if DEBUG
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event

var onEvent: (Event) -> Void = { _ in }
var onEvent: (Event) -> Void = { _ in }

func onAppear() async {}
}
func onAppear() async {}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// ___FILEHEADER___
//___FILEHEADER___

protocol ___VARIABLE_sceneIdentifier___ResourceProtocol {
}
protocol ___VARIABLE_sceneIdentifier___ResourceProtocol {}

struct ___VARIABLE_sceneIdentifier___Resource: ___VARIABLE_sceneIdentifier___ResourceProtocol {
}
struct ___VARIABLE_sceneIdentifier___Resource: ___VARIABLE_sceneIdentifier___ResourceProtocol {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import SwiftUI

Expand All @@ -14,9 +14,9 @@ struct ___VARIABLE_sceneIdentifier___Component<Model: ___VARIABLE_sceneIdentifie
}

#if DEBUG
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#Preview {
___VARIABLE_sceneIdentifier___Component(
model: ___VARIABLE_sceneIdentifier___ComponentModelMock()
)
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import FuturedArchitecture
import Observation
Expand All @@ -9,7 +9,6 @@ protocol ___VARIABLE_sceneIdentifier___ComponentModelProtocol: ComponentModel {

@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModel: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {

let onEvent: (Event) -> Void

private let dataCache: DataCache<DataCacheModel>
Expand All @@ -32,12 +31,12 @@ extension ___VARIABLE_sceneIdentifier___ComponentModel {
}

#if DEBUG
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event
@Observable
final class ___VARIABLE_sceneIdentifier___ComponentModelMock: ___VARIABLE_sceneIdentifier___ComponentModelProtocol {
typealias Event = ___VARIABLE_sceneIdentifier___ComponentModel.Event

var onEvent: (Event) -> Void = { _ in }
var onEvent: (Event) -> Void = { _ in }

func onAppear() async {}
}
func onAppear() async {}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import EnumIdentable
import FuturedArchitecture
Expand Down Expand Up @@ -31,8 +31,8 @@ final class ___VARIABLE_sceneFlowProviderIdentifier___SceneFlowProvider: @MainAc
EmptyView()
case .otherDestination:
EmptyView()
// case .end:
// EmptyView()
// case .end:
// EmptyView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// ___FILEHEADER___
//___FILEHEADER___

protocol ___VARIABLE_serviceIdentifier___ {
}
protocol ___VARIABLE_serviceIdentifier___ {}

final class Production___VARIABLE_serviceIdentifier___: ___VARIABLE_serviceIdentifier___ {
}
final class Production___VARIABLE_serviceIdentifier___: ___VARIABLE_serviceIdentifier___ {}
9 changes: 3 additions & 6 deletions Templates/SwiftUI App.xctemplate/App.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// ___FILEHEADER___
//___FILEHEADER___

import SwiftUI

#error("Add https://github.com/futuredapp/FuturedKit.git to the project!")

// swiftlint:disable:next line_length
#warning("Add UILaunchScreen (dictionary) to Info.plist. Without it, iOS runs the app in legacy compatibility mode and the UI does not fill the full screen on modern devices.")

#warning("Move the SwiftFormat and SwiftLint build phases above Compile Sources (templates can only append phases).")

@main
Expand All @@ -17,8 +14,8 @@ struct ___PACKAGENAME:identifier___App: App {

init() {
let coordinator = AppCoordinator(container: Container())
self._coordinator = State(wrappedValue: coordinator)
self.appDelegate.delegate = coordinator
_coordinator = State(wrappedValue: coordinator)
appDelegate.delegate = coordinator
}

var body: some Scene {
Expand Down
5 changes: 2 additions & 3 deletions Templates/SwiftUI App.xctemplate/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import SwiftUI

Expand All @@ -19,6 +19,5 @@ final class AppCoordinator {

extension AppCoordinator: AppDelegateProtocol {
// swiftlint:disable:next discouraged_optional_collection
func applicationDidFinishLaunching(with launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
}
func applicationDidFinishLaunching(with _: [UIApplication.LaunchOptionsKey: Any]?) {}
}
5 changes: 3 additions & 2 deletions Templates/SwiftUI App.xctemplate/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

import UIKit

Expand All @@ -12,11 +12,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
weak var delegate: AppDelegateProtocol?

func application(
_ application: UIApplication,
_: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
delegate?.applicationDidFinishLaunching(with: launchOptions)
return true
}
}

// swiftlint:enable discouraged_optional_collection
4 changes: 2 additions & 2 deletions Templates/SwiftUI App.xctemplate/CacheProjection.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

protocol CacheProjection: Equatable {
associatedtype CacheModel: Equatable
Expand All @@ -20,7 +20,7 @@ protocol CacheProjection: Equatable {
/// Default `data(for:from:)` for projections that don't use an ID.
/// Projections with a real `ID` type are forced to implement it.
extension CacheProjection where ID == Void {
static func data(for id: ID, from cache: CacheModel) -> Self? {
static func data(for _: ID, from _: CacheModel) -> Self? {
nil
}
}
14 changes: 9 additions & 5 deletions Templates/SwiftUI App.xctemplate/ComponentState.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ___FILEHEADER___
//___FILEHEADER___

/// Screen/component-level lifecycle state.
///
Expand All @@ -11,21 +11,25 @@ nonisolated enum ComponentState: Equatable {
case error(StateInfoConfig)

var isLoading: Bool {
if case .loading = self { return true }
if case .loading = self {
return true
}
return false
}

var isError: Bool {
if case .error = self { return true }
if case .error = self {
return true
}
return false
}

var infoConfig: StateInfoConfig? {
switch self {
case let .empty(config), let .error(config):
return config
config
case .ready, .loading:
return nil
nil
}
}
}
Loading