Skip to content

Commit

Permalink
0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Mar 17, 2024
1 parent e526c04 commit 00c903b
Show file tree
Hide file tree
Showing 37 changed files with 552 additions and 553 deletions.
8 changes: 4 additions & 4 deletions Examples/SyncUps/SyncUps/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension Store<AppFeature>: RecordMeetingDelegate {

func debounceSave(syncUps: [SyncUp]) async throws {
cancel(Self.debounceSave)
try await di.continuousClock.sleep(for: .seconds(1))
try await di.continuousClock.sleep(for: .seconds(1))
try await di.dataManager.save(JSONEncoder().encode(syncUps), .syncUps)
}
}
Expand Down Expand Up @@ -81,8 +81,8 @@ struct AppView: View {

var body: some View {
NavigationSteps(
selection: $state.binding.path.selected
) {
selection: $state.binding.path.selected
) {
listView
detailView

Expand All @@ -93,7 +93,7 @@ struct AppView: View {
meetingView
}
}
.stepEnvironment($state.binding.path)
.stepEnvironment($state.binding.path)
}

private var listView: some View {
Expand Down
4 changes: 2 additions & 2 deletions Examples/SyncUps/SyncUps/Dependencies/OpenSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import VDStore

extension StoreDIValues {

@StoreDIValue
var openSettings: @Sendable () async -> Void = Self.openSettings
@StoreDIValue
var openSettings: @Sendable () async -> Void = Self.openSettings

private static let openSettings: @Sendable () async -> Void = {
await MainActor.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private actor Speech {
request: SFSpeechAudioBufferRecognitionRequest
) -> AsyncThrowingStream<SpeechRecognitionResult, Error> {
AsyncThrowingStream { continuation in
return;
return;
self.recognitionContinuation = continuation
let audioSession = AVAudioSession.sharedInstance()
do {
Expand Down
20 changes: 10 additions & 10 deletions Examples/SyncUps/SyncUps/RecordMeeting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ extension StoreDIValues {
extension Store<RecordMeeting> {

func confirmDiscard() {
di.pop()
cancel(Self.onTask)
di.pop()
cancel(Self.onTask)
}

func save() {
state.syncUp.meetings.insert(
Meeting(
id: di.uuid(),
date: di.date.now,
date: di.date.now,
transcript: state.transcript
),
at: 0
)
di.recordMeetingDelegate?.savePath(transcript: state.transcript)
di.pop()
cancel(Self.onTask)
di.pop()
cancel(Self.onTask)
}

func endMeetingButtonTapped() {
Expand Down Expand Up @@ -85,10 +85,10 @@ extension Store<RecordMeeting> {
}

group.addTask {
while !Task.isCancelled {
await timerTick()
try? await di.continuousClock.sleep(for: .seconds(1))
}
while !Task.isCancelled {
await timerTick()
try? await di.continuousClock.sleep(for: .seconds(1))
}
}
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@ struct MeetingHeaderView: View {

var body: some View {
VStack {
ProgressView(value: max(0, min(1, progress)))
ProgressView(value: max(0, min(1, progress)))
.progressViewStyle(MeetingProgressViewStyle(theme: theme))
HStack {
VStack(alignment: .leading) {
Expand Down
6 changes: 3 additions & 3 deletions Examples/SyncUps/SyncUps/SyncUpDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct SyncUpDetail: Equatable {
@Steps
struct Destination: Equatable {
var alert = Alert()
var edit = SyncUpForm(syncUp: SyncUp(id: StoreDIValues.current.uuid()))
var edit = SyncUpForm(syncUp: SyncUp(id: StoreDIValues.current.uuid()))

@Steps
struct Alert: Equatable {
Expand Down Expand Up @@ -52,7 +52,7 @@ extension Store<SyncUpDetail> {
withAnimation {
di.syncUpDetailDelegate?.deleteSyncUp(syncUp: state.syncUp)
}
di.pop()
di.pop()
}

func continueWithoutRecording() {
Expand Down Expand Up @@ -210,7 +210,7 @@ extension View {
isPresented: store.binding.destination.alert.isSelected(.confirmDeletion)
) {
Button("Yes", role: .destructive) {
store.confirmDeletion()
store.confirmDeletion()
}
Button("Nevermind", role: .cancel) {}
} message: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/SyncUps/SyncUps/SyncUpForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ struct SyncUpForm: Equatable {
) {
self.focus = focus
self.syncUp = syncUp
if self.syncUp.attendees.isEmpty {
self.syncUp.attendees.append(Attendee(id: StoreDIValues.current.uuid()))
}
if self.syncUp.attendees.isEmpty {
self.syncUp.attendees.append(Attendee(id: StoreDIValues.current.uuid()))
}
}

enum Field: Hashable {
Expand Down
52 changes: 26 additions & 26 deletions Examples/TicTacToe/App/RootView.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AppCore
import AppSwiftUI
import AppUIKit
import VDStore
import SwiftUI
import VDStore

private let readMe = """
This application demonstrates how to build a moderately complex application in the VDStore.
Expand All @@ -27,35 +27,35 @@ enum GameType: Identifiable {

struct RootView: View {

@ViewStore(
Store(TicTacToe.login()).transformDI {
$0.logoutButtonDelegate = $0.store(for: TicTacToe.self)
$0.loginDelegate = $0.store(for: TicTacToe.self)
}
)
private var state
@ViewStore(
Store(TicTacToe.login()).transformDI {
$0.logoutButtonDelegate = $0.store(for: TicTacToe.self)
$0.loginDelegate = $0.store(for: TicTacToe.self)
}
)
private var state

@State var showGame: GameType?

var body: some View {
NavigationStack {
Form {
Text(readMe)
Section {
Button("SwiftUI version") { showGame = .swiftui }
Button("UIKit version") { showGame = .uikit }
}
}
.sheet(item: $showGame) { gameType in
if gameType == .swiftui {
AppView(store: $state)
} else {
UIKitAppView(store: $state)
}
}
.navigationTitle("Tic-Tac-Toe")
}
NavigationStack {
Form {
Text(readMe)

Section {
Button("SwiftUI version") { showGame = .swiftui }
Button("UIKit version") { showGame = .uikit }
}
}
.sheet(item: $showGame) { gameType in
if gameType == .swiftui {
AppView(store: $state)
} else {
UIKitAppView(store: $state)
}
}
.navigationTitle("Tic-Tac-Toe")
}
}
}

Expand Down
Binary file not shown.
18 changes: 9 additions & 9 deletions Examples/TicTacToe/tic-tac-toe/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
],
dependencies: [
.package(name: "VDStore", path: "../../.."),
.package(url: "https://github.com/dankinsoid/VDFlow.git", from: "4.21.0")
.package(url: "https://github.com/dankinsoid/VDFlow.git", from: "4.21.0"),
],
targets: [
.target(
Expand All @@ -37,7 +37,7 @@ let package = Package(
"LoginCore",
"NewGameCore",
"VDStore",
"VDFlow"
"VDFlow",
]
),
.testTarget(
Expand Down Expand Up @@ -67,7 +67,7 @@ let package = Package(
),
.target(
name: "GameCore",
dependencies: ["VDStore", "VDFlow"]
dependencies: ["VDStore", "VDFlow"]
),
.testTarget(
name: "GameCoreTests",
Expand All @@ -87,8 +87,8 @@ let package = Package(
dependencies: [
"AuthenticationClient",
"TwoFactorCore",
"VDStore",
"VDFlow"
"VDStore",
"VDFlow",
]
),
.testTarget(
Expand All @@ -114,8 +114,8 @@ let package = Package(
name: "NewGameCore",
dependencies: [
"GameCore",
"VDStore",
"VDFlow"
"VDStore",
"VDFlow",
]
),
.testTarget(
Expand All @@ -141,8 +141,8 @@ let package = Package(
name: "TwoFactorCore",
dependencies: [
"AuthenticationClient",
"VDStore",
"VDFlow"
"VDStore",
"VDFlow",
]
),
.testTarget(
Expand Down
20 changes: 10 additions & 10 deletions Examples/TicTacToe/tic-tac-toe/Sources/AppCore/AppCore.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import VDStore
import VDFlow
import LoginCore
import NewGameCore
import TwoFactorCore
import VDFlow
import VDStore

@Steps
public struct TicTacToe: Equatable {

public var login: Login = Login()
public var newGame: NewGame = NewGame()
public var login = Login()
public var newGame = NewGame()
}

extension Store<TicTacToe>: LogoutButtonDelegate {

public func logoutButtonTapped() {
state = .login()
}
public func logoutButtonTapped() {
state = .login()
}
}

extension Store<TicTacToe>: LoginDelegate {

public func didSucceedLogin() {
state = .newGame()
}
public func didSucceedLogin() {
state = .newGame()
}
}
26 changes: 13 additions & 13 deletions Examples/TicTacToe/tic-tac-toe/Sources/AppSwiftUI/AppView.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AppCore
import VDStore
import LoginSwiftUI
import NewGameSwiftUI
import SwiftUI
import VDStore

public struct AppView: View {
@ViewStore private var state: TicTacToe
Expand All @@ -11,16 +11,16 @@ public struct AppView: View {
_state = ViewStore(store)
}

public var body: some View {
switch state.selected {
case .login:
NavigationStack {
LoginView(store: $state.login)
}
case .newGame:
NavigationStack {
NewGameView(store: $state.newGame)
}
}
}
public var body: some View {
switch state.selected {
case .login:
NavigationStack {
LoginView(store: $state.login)
}
case .newGame:
NavigationStack {
NewGameView(store: $state.newGame)
}
}
}
}
Loading

0 comments on commit 00c903b

Please sign in to comment.