forked from ml-opensource/swiftui-template-tca
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add file template to create View and Feature based on TCA
- Loading branch information
Mohammed Rokon Uddin
committed
Sep 6, 2023
1 parent
8935593
commit a68ab8d
Showing
7 changed files
with
175 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>DefaultCompletionName</key> | ||
<string>File</string> | ||
<key>Summary</key> | ||
<string>This generates a new Feature.</string> | ||
<key>Description</key> | ||
<string>The template create a new Feature which is based on The Composable Architecture(TCA). It consists of a SwiftUI View and Feature file that implments the TCA Reducer.</string> | ||
<key>Kind</key> | ||
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string> | ||
<key>Options</key> | ||
<array> | ||
<dict> | ||
<key>Description</key> | ||
<string>The name of the feature to create</string> | ||
<key>Identifier</key> | ||
<string>moduleName</string> | ||
<key>Name</key> | ||
<string>New Feature Name:</string> | ||
<key>NotPersisted</key> | ||
<true/> | ||
<key>Required</key> | ||
<true/> | ||
<key>Type</key> | ||
<string>text</string> | ||
</dict> | ||
<dict> | ||
<key>Default</key> | ||
<string>___VARIABLE_moduleName___</string> | ||
<key>Identifier</key> | ||
<string>productName</string> | ||
<key>Type</key> | ||
<string>static</string> | ||
</dict> | ||
<dict> | ||
<key>Default</key> | ||
<string>___VARIABLE_moduleName___View</string> | ||
<key>Description</key> | ||
<string>The view name</string> | ||
<key>Identifier</key> | ||
<string>viewName</string> | ||
<key>Name</key> | ||
<string>View Name:</string> | ||
<key>Required</key> | ||
<true/> | ||
<key>Type</key> | ||
<string>static</string> | ||
</dict> | ||
<dict> | ||
<key>Default</key> | ||
<string>___VARIABLE_moduleName___Feature</string> | ||
<key>Description</key> | ||
<string>The name of the feature</string> | ||
<key>Identifier</key> | ||
<string>featureName</string> | ||
<key>Name</key> | ||
<string>Name of Feature:</string> | ||
<key>Required</key> | ||
<true/> | ||
<key>Type</key> | ||
<string>static</string> | ||
</dict> | ||
</array> | ||
<key>SortOrder</key> | ||
<string>7</string> | ||
</dict> | ||
</plist> |
66 changes: 66 additions & 0 deletions
66
TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___Feature.swift
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,66 @@ | ||
// | ||
// ___FILENAME___ | ||
// ___PROJECTNAME___ | ||
// | ||
// Created by ___FULLUSERNAME___ on ___DATE___. | ||
//___COPYRIGHT___ | ||
// | ||
|
||
import Domain | ||
import Commons | ||
import Foundation | ||
import ComposableArchitecture | ||
|
||
public struct ___VARIABLE_moduleName___Feature: Reducer { | ||
|
||
public struct State: Equatable { | ||
public init() {} | ||
} | ||
|
||
public enum Action: BaseAction { | ||
|
||
enum ViewAction: Equatable { | ||
case onAppear | ||
|
||
} | ||
|
||
enum InlyingAction: Equatable { | ||
|
||
} | ||
|
||
enum DelegateAction: Equatable { | ||
|
||
} | ||
|
||
case view(ViewAction) | ||
case inlying(InlyingAction) | ||
case delegate(DelegateAction) | ||
} | ||
|
||
public func reduce(into state: inout State, action: Action) -> Effect<Action> { | ||
switch action { | ||
case .view(let action): | ||
switch action { | ||
case .onAppear: | ||
return .none | ||
|
||
} | ||
case .inlying(let action): | ||
switch action { | ||
|
||
} | ||
case .delegate(let action): | ||
switch action { | ||
|
||
} | ||
} | ||
} | ||
|
||
// Remove commented code if not needed | ||
// public var body: some Reducer<State, Action> { | ||
// | ||
// Reduce { state, action in | ||
// | ||
// } | ||
// } | ||
} |
29 changes: 29 additions & 0 deletions
29
TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___View.swift
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,29 @@ | ||
// | ||
// ___FILENAME___ | ||
// ___PROJECTNAME___ | ||
// | ||
// Created by ___FULLUSERNAME___ on ___DATE___. | ||
//___COPYRIGHT___ | ||
// | ||
|
||
import SwiftUI | ||
import Commons | ||
import Resources | ||
import ComposableArchitecture | ||
|
||
public struct ___VARIABLE_moduleName___View: View { | ||
let store: StoreOf<___VARIABLE_moduleName___Feature> | ||
|
||
public init(store: StoreOf<___VARIABLE_moduleName___Feature>) { | ||
self.store = store | ||
} | ||
|
||
public var body: some View { | ||
WithViewStore(self.store, observe: { $0 }) { viewStore in | ||
Text("Hello World!!!") | ||
.onAppear { | ||
viewStore.send(.onAppear) | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.