Forked from ethanhuang13/SwiftUI-ViewBuilderFunc.swift
Created
February 15, 2022 13:57
-
-
Save erichsu/f99b0a2d046243b481627a267a6d84ad to your computer and use it in GitHub Desktop.
Xcode Snippets
This file contains hidden or 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
@ViewBuilder | |
private func build<#name#>(_ viewStore: ViewStoreType) -> some View { | |
} |
This file contains hidden or 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
@ViewBuilder | |
private var name: some View { | |
} |
This file contains hidden or 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment