-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
5,190 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Part of the distributed code is also derived in part from | ||
https://github.com/pointfreeco/swift-composable-architecture, licensed under MIT | ||
(https://github.com/pointfreeco/swift-composable-architecture/blob/main/LICENSE). | ||
Copyright (c) 2020 Point-Free, Inc. | ||
|
||
Part of the distributed code is also derived in part from | ||
https://github.com/apple/swift licensed under Apache | ||
(https://github.com/apple/swift/blob/main/LICENSE.txt). Copyright 2024 Apple, | ||
Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import UIKit | ||
import Workflow | ||
import WorkflowUI | ||
|
||
@main | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
var window: UIWindow? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
let root = WorkflowHostingController( | ||
workflow: MultiCounterWorkflow().mapRendering(MultiCounterScreen.init) | ||
) | ||
root.view.backgroundColor = .systemBackground | ||
|
||
window = UIWindow(frame: UIScreen.main.bounds) | ||
window?.rootViewController = root | ||
window?.makeKeyAndVisible() | ||
|
||
return true | ||
} | ||
|
||
func applicationWillResignActive(_ application: UIApplication) {} | ||
|
||
func applicationDidEnterBackground(_ application: UIApplication) {} | ||
|
||
func applicationWillEnterForeground(_ application: UIApplication) {} | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) {} | ||
|
||
func applicationWillTerminate(_ application: UIApplication) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import SwiftUI | ||
import ViewEnvironment | ||
import WorkflowSwiftUI | ||
import WorkflowUI | ||
|
||
struct CounterScreen: ObservableScreen, Screen { | ||
var model: Model | ||
|
||
typealias State = CounterWorkflow.State | ||
typealias Action = CounterWorkflow.Action | ||
typealias Model = ActionModel<State, Action> | ||
|
||
static func makeView(store: Store<Model>) -> some View { | ||
CounterView(store: store, key: "root") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import SwiftUI | ||
import ViewEnvironment | ||
import WorkflowSwiftUI | ||
|
||
struct CounterView: View { | ||
typealias Model = ActionModel<CounterWorkflow.State, CounterWorkflow.Action> | ||
|
||
let store: Store<Model> | ||
let key: String | ||
|
||
var body: some View { | ||
let _ = Self._printChanges() | ||
WithPerceptionTracking { | ||
let _ = print("Evaluated CounterView[\(key)] body") | ||
HStack { | ||
Text(store.info.name) | ||
|
||
Spacer() | ||
|
||
Button { | ||
store.send(.decrement) | ||
} label: { | ||
Image(systemName: "minus") | ||
} | ||
|
||
Text("\(store.boundedCount)") | ||
.monospacedDigit() | ||
|
||
Button { | ||
store.send(.increment) | ||
} label: { | ||
Image(systemName: "plus") | ||
} | ||
|
||
if let maxValue = store.maxValue { | ||
Text("(max \(maxValue))") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#if DEBUG | ||
|
||
#Preview { | ||
CounterScreen.observableScreenPreview( | ||
state: .init( | ||
count: 0, | ||
info: .init( | ||
name: "Preview counter", | ||
stepSize: 1 | ||
) | ||
) | ||
) | ||
.padding() | ||
} | ||
|
||
#endif |
Oops, something went wrong.