Skip to content

Instantly share code, notes, and snippets.

@ethanhuang13
Last active June 15, 2023 07:41
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ethanhuang13/6389106d2dcfe3cc00ac08fbb3293cd3 to your computer and use it in GitHub Desktop.
Save ethanhuang13/6389106d2dcfe3cc00ac08fbb3293cd3 to your computer and use it in GitHub Desktop.
Xcode Snippets
@ViewBuilder
private func build<#name#>(_ viewStore: ViewStoreType) -> some View {
}
@ViewBuilder
private var <#name#>: some View {
}
import ComposableArchitecture
import SwiftUI
struct <#Name#>State: Equatable {}
enum <#Name#>Action: Equatable {}
struct <#Name#>Environment {}
extension <#Name#>Environment {
static var live = Self()
}
let <#Name#>Reducer = Reducer<
<#Name#>State,
<#Name#>Action,
<#Name#>Environment
> { state, action, environment in
.none
}
struct <#Name#>View: View {
typealias ViewStoreType = ViewStore<<#Name#>State, <#Name#>Action>
let store: Store<<#Name#>State, <#Name#>Action>
var body: some View {
WithViewStore(store) { viewStore in
}
}
}
#if DEBUG
struct <#Name#>View_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
<#Name#>View(store: .init(
initialState: .init(),
reducer: <#Name#>Reducer,
environment: .live
))
}
}
}
#endif
@ethanhuang13
Copy link
Author

ethanhuang13 commented Jan 9, 2022

Using Xcode Snippet to quickly add SwiftUI View with TCA. (It would be even faster if the placeholder can support multi-cursor editing.)

Setting Up
CleanShot 2022-01-09 at 09 47 54@2x

Profit
2022-01-09 09 38 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment