Skip to content

Commit

Permalink
Merge pull request #20 from rokon-uddin/update_template
Browse files Browse the repository at this point in the history
chore: update template and drop version for iOS 15
  • Loading branch information
Mohammed Rokon Uddin authored Feb 16, 2024
2 parents 6d1bdd3 + e42de50 commit a4857e0
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 329 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## iOS Project Template for SwiftUI
[![IDE](https://img.shields.io/badge/Xcode-14-blue.svg)](https://developer.apple.com/xcode/)
[![Language](https://img.shields.io/badge/swift-5.5-orange.svg)](https://swift.org)
[![Platform](https://img.shields.io/badge/iOS-15-green.svg)](https://developer.apple.com/ios/)
[![IDE](https://img.shields.io/badge/Xcode-15-blue.svg)](https://developer.apple.com/xcode/)
[![Language](https://img.shields.io/badge/swift-5.9-orange.svg)](https://swift.org)
[![Platform](https://img.shields.io/badge/iOS-16-green.svg)](https://developer.apple.com/ios/)
[![Build Status](https://github.com/monstar-lab-oss/swiftui-template-tca/actions/workflows/build.yml/badge.svg)](https://github.com/monstar-lab-oss/swiftui-template-tca/actions/workflows/build.yml)


Expand All @@ -18,14 +18,11 @@ This template will save those hours and help to follow standard project architec
* [R.swift](https://github.com/mac-cain13/R.swift) Get strong typed, autocompleted resources like images, fonts and segues in Swift projects
* [Standard gitignore](https://github.com/github/gitignore/blob/master/Swift.gitignore)
* [Moya](https://github.com/Moya/Moya) for netwoking layer
* [Swiftlint](https://github.com/realm/SwiftLint) [SwiftLint SPM Plugin showing build error]
* [Swinject](https://github.com/Swinject/Swinject) [Swinject SPM Plugin showing build error]
* Development/Staging/Production app flavours
* [Swift-Format](https://github.com/apple/swift-format) [For doing code formatting transformations]
* Development, Staging and Production app flavours
* Separate build configuration for each flavour

### Todo
* Database Platform
* Persistency Platform
* Base classes for handling deeplink, notifications and multiple scheme

### Supporting Tools
Expand Down Expand Up @@ -72,8 +69,8 @@ Please refer to [Contributing Guidelines](https://github.com/monstar-lab-oss/swi

## Acknowledgments

* [iOS project best practices and tools](https://medium.com/@piotr.gorzelany/ios-project-best-practices-and-tools-c46135b8116d)
* [Development/Staging/Production Configs in Xcode](https://medium.com/better-programming/how-to-create-development-staging-and-production-configs-in-xcode-ec58b2cc1df4)
* [iOS Project Best Practices and Tools](https://medium.com/@piotr.gorzelany/ios-project-best-practices-and-tools-c46135b8116d)
* [Development, Staging and Production Configs in Xcode](https://medium.com/better-programming/how-to-create-development-staging-and-production-configs-in-xcode-ec58b2cc1df4)
* [iOS Build Management using Custom Build Scheme](https://www.talentica.com/blogs/ios-build-management-using-custom-build-scheme/)

## 👥 Credits
Expand Down
4 changes: 2 additions & 2 deletions TCA.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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>SupportsSwiftPackage</key>
<true/>
<key>DefaultCompletionName</key>
<string>File</string>
<key>Summary</key>
Expand Down Expand Up @@ -63,8 +65,6 @@
<string>static</string>
</dict>
</array>
<key>SupportsSwiftPackage</key>
<true/>
<key>SortOrder</key>
<string>7</string>
</dict>
Expand Down
70 changes: 37 additions & 33 deletions TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,60 @@ import ComposableArchitecture
import Domain
import Foundation

public struct ___VARIABLE_moduleName___Feature: Reducer {
public struct ___VARIABLE_moduleName___Feature: FeatureReducer {

public struct State: Equatable {
public init() {}

@ObservableState
public struct State: Equatable, Hashable {
public init() {}
}

public enum Action: BaseAction {
public enum ViewAction {

enum ViewAction: Equatable {
case onAppear
}

}
public enum InternalAction {

enum InlyingAction: Equatable {
}

}
public var body: some ReducerOf<Self> {

enum DelegateAction: Equatable {
}

}
public func reduce(into state: inout State, viewAction: ViewAction) -> Effect<Action> {
switch viewAction {

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
public func reduce(into state: inout State, presentedAction: Destination.Action) -> Effect<Action> {

}
case .inlying(let action):
switch action {
}

}
case .delegate(let action):
switch action {
public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
switch internalAction {

}
}
}

// Remove commented code if not needed
// public var body: some Reducer<State, Action> {
//
// Reduce { state, action in
//
// }
// }
public struct Destination: DestinationReducer {

public init() {}

@dynamicMemberLookup
@CasePathable
public enum State: Hashable {

}

@CasePathable
public enum Action {

}

public var body: some ReducerOf<Self> {

}
}
}
25 changes: 13 additions & 12 deletions TCA.xctemplate/___FILEBASENAME___/___FILEBASENAME___View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@
//___COPYRIGHT___
//

import SwiftUI
import Commons
import ComposableArchitecture
import Resources
import SwiftUI
import ComposableArchitecture

public struct ___VARIABLE_moduleName___View: View {
let store: StoreOf<___VARIABLE_moduleName___Feature>
let store: StoreOf<___VARIABLE_moduleName___Feature>

public init(store: StoreOf<___VARIABLE_moduleName___Feature>) {
self.store = store
}
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)
public var body: some View {
WithPerceptionTracking {
Text("Hello World!!!")
.onAppear {
// Just for example
// store.send(.onAppear)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let R = _R(bundle: Bundle.module)

struct _R {
let bundle: Foundation.Bundle
var color:color { .init(bundle: bundle) }
var color: color { .init(bundle: bundle) }
var image: image { .init(bundle: bundle) }

func color(bundle: Foundation.Bundle) -> color {
Expand All @@ -23,35 +23,56 @@ struct _R {

}


/// This `_R.color` struct is generated, and contains static references to 3 colors.
struct color {
let bundle: Foundation.Bundle

/// Color `BgColor`.
var bgColor: ColorResource { .init(name: "BgColor", path: [], bundle: bundle) }
var bgColor: ColorResource {
.init(name: "BgColor", path: [], bundle: bundle)
}

/// Color `PrimaryColor`.
var primaryColor: ColorResource { .init(name: "PrimaryColor", path: [], bundle: bundle) }
var primaryColor: ColorResource {
.init(name: "PrimaryColor", path: [], bundle: bundle)
}

/// Color `TitleTextColor`.
var titleTextColor: ColorResource { .init(name: "TitleTextColor", path: [], bundle: bundle) }
var titleTextColor: ColorResource {
.init(name: "TitleTextColor", path: [], bundle: bundle)
}
}

/// This `_R.image` struct is generated, and contains static references to 4 images.
struct image {
let bundle: Foundation.Bundle

/// Image `apple`.
var apple: ImageResource { .init(name: "apple", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
var apple: ImageResource {
.init(
name: "apple", path: [], bundle: bundle, locale: nil,
onDemandResourceTags: nil)
}

/// Image `fork_icon`.
var fork_icon: ImageResource { .init(name: "fork_icon", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
var fork_icon: ImageResource {
.init(
name: "fork_icon", path: [], bundle: bundle, locale: nil,
onDemandResourceTags: nil)
}

/// Image `google`.
var google: ImageResource { .init(name: "google", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
var google: ImageResource {
.init(
name: "google", path: [], bundle: bundle, locale: nil,
onDemandResourceTags: nil)
}

/// Image `onboard`.
var onboard: ImageResource { .init(name: "onboard", path: [], bundle: bundle, locale: nil, onDemandResourceTags: nil) }
var onboard: ImageResource {
.init(
name: "onboard", path: [], bundle: bundle, locale: nil,
onDemandResourceTags: nil)
}
}
}
2 changes: 1 addition & 1 deletion {{cookiecutter.app_name}}/Common/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Common",
platforms: [.macOS(.v12), .iOS(.v15)],
platforms: [.macOS(.v12), .iOS(.v16)],
products: [
.library(
name: "Common",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,35 @@ public enum EmptyDestination: DestinationReducer {
Action
> { .none }
}

extension FeatureReducer {

public func delayedMediumEffect(internal internalAction: InternalAction)
-> Effect<Action>
{
self.delayedMediumEffect(for: .internal(internalAction))
}

public func delayedMediumEffect(
for action: Action
) -> Effect<Action> {
delayedEffect(delay: .seconds(0.6), for: action)
}

public func delayedShortEffect(
for action: Action
) -> Effect<Action> {
delayedEffect(delay: .seconds(0.3), for: action)
}

private func delayedEffect(
delay: Duration,
for action: Action
) -> Effect<Action> {
@Dependency(\.continuousClock) var clock
return .run { send in
try await clock.sleep(for: delay)
await send(action)
}
}
}
2 changes: 1 addition & 1 deletion {{cookiecutter.app_name}}/Domain/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Domain",
platforms: [.macOS(.v12), .iOS(.v15)],
platforms: [.macOS(.v12), .iOS(.v16)],
products: [
.library(
name: "Domain",
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.app_name}}/Features/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Features",
platforms: [.macOS(.v12), .iOS(.v15)],
platforms: [.macOS(.v12), .iOS(.v16)],
products: [
.library(
name: "App",
Expand Down
Loading

0 comments on commit a4857e0

Please sign in to comment.