Skip to content

Rewrite LiveTranslationFeature to TCA #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions MyLibrary/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions MyLibrary/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ let package = Package(
"trySwiftFeature",
]
),
.target(
name: "BuildConfig",
dependencies: [
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]
),
.target(
name: "DataClient",
dependencies: [
Expand Down Expand Up @@ -69,6 +75,7 @@ let package = Package(
.target(
name: "LiveTranslationFeature",
dependencies: [
"BuildConfig",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
.product(name: "rtt-sdk", package: "rtt_sdk"),
]
Expand Down
7 changes: 6 additions & 1 deletion MyLibrary/Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public struct AppReducer {
@ObservableState
public struct State: Equatable {
var schedule = Schedule.State()
var liveTranslation = LiveTranslation.State()
var guidance = Guidance.State()
var sponsors = SponsorsList.State()
var trySwift = TrySwift.State()
Expand All @@ -24,6 +25,7 @@ public struct AppReducer {

public enum Action {
case schedule(Schedule.Action)
case liveTranslation(LiveTranslation.Action)
case guidance(Guidance.Action)
case sponsors(SponsorsList.Action)
case trySwift(TrySwift.Action)
Expand All @@ -35,6 +37,9 @@ public struct AppReducer {
Scope(state: \.schedule, action: \.schedule) {
Schedule()
}
Scope(state: \.liveTranslation, action: \.liveTranslation) {
LiveTranslation()
}
Scope(state: \.guidance, action: \.guidance) {
Guidance()
}
Expand All @@ -60,7 +65,7 @@ public struct AppView: View {
.tabItem {
Label(String(localized: "Schedule", bundle: .module), systemImage: "calendar")
}
LiveTranslationView()
LiveTranslationView(store: store.scope(state: \.liveTranslation, action: \.liveTranslation))
.tabItem {
Label(String(localized: "Translation", bundle: .module), systemImage: "text.bubble")
}
Expand Down
24 changes: 24 additions & 0 deletions MyLibrary/Sources/BuildConfig/BuildConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Dependencies
import Foundation
import DependenciesMacros

@DependencyClient
public struct BuildConfig {
public var liveTranslationRoomNumber: () -> String = { "" }
}

extension DependencyValues {
public var buildConfig: BuildConfig {
get { self[BuildConfig.self] }
set { self[BuildConfig.self] = newValue }
}
}

extension BuildConfig: DependencyKey {
public static let liveValue: Self = Self(
liveTranslationRoomNumber: {
ProcessInfo.processInfo.environment["LIVE_TRANSLATION_KEY"]
?? (Bundle.main.infoDictionary?["Live translation room number"] as? String) ?? ""
}
)
}
Loading