Skip to content

Commit

Permalink
Merge pull request #67 from DroidKaigi/MrSmart00/feature/empty-features
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSmart00 authored Jun 24, 2024
2 parents 1c35b9e + 7a1e263 commit cfa08ba
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 2 deletions.
21 changes: 21 additions & 0 deletions app-ios/App/App.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@
"identifier" : "FavoriteFeatureTests",
"name" : "FavoriteFeatureTests"
}
},
{
"target" : {
"containerPath" : "container:..",
"identifier" : "ContributorFeatureTests",
"name" : "ContributorFeatureTests"
}
},
{
"target" : {
"containerPath" : "container:..",
"identifier" : "SponsorFeatureTests",
"name" : "SponsorFeatureTests"
}
},
{
"target" : {
"containerPath" : "container:..",
"identifier" : "StaffFeatureTests",
"name" : "StaffFeatureTests"
}
}
],
"version" : 1
Expand Down
50 changes: 48 additions & 2 deletions app-ios/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ let package = Package(
name: "FavoriteFeature",
targets: ["FavoriteFeature"]
),
.library(
name: "StaffFeature",
targets: ["StaffFeature"]
),
.library(
name: "SponsorFeature",
targets: ["SponsorFeature"]
),
.library(
name: "ContributorFeature",
targets: ["ContributorFeature"]
),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-composable-architecture.git", exact: "1.10.2"),
Expand Down Expand Up @@ -118,7 +130,6 @@ let package = Package(
.tca
]
),

.target(
name: "FavoriteFeature",
dependencies: [
Expand All @@ -132,7 +143,6 @@ let package = Package(
.tca
]
),

.target(
name: "Theme",
resources: [
Expand All @@ -141,6 +151,39 @@ let package = Package(
],
plugins: [.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin")]
),
.target(
name: "StaffFeature",
dependencies: [ .tca ]
),
.testTarget(
name: "StaffFeatureTests",
dependencies: [
.staffFeature,
.tca
]
),
.target(
name: "SponsorFeature",
dependencies: [ .tca ]
),
.testTarget(
name: "SponsorFeatureTests",
dependencies: [
.sponsorFeature,
.tca
]
),
.target(
name: "ContributorFeature",
dependencies: [ .tca ]
),
.testTarget(
name: "ContributorFeatureTests",
dependencies: [
.contributorFeature,
.tca
]
),

// Please run ./gradlew app-ios-shared:assembleSharedXCFramework first
.binaryTarget(name: "KmpModule", path: "../app-ios-shared/build/XCFrameworks/debug/shared.xcframework"),
Expand All @@ -165,6 +208,9 @@ extension Target.Dependency {
static let timetableFeature: Target.Dependency = "TimetableFeature"
static let aboutFeature: Target.Dependency = "AboutFeature"
static let favoriteFeature: Target.Dependency = "FavoriteFeature"
static let staffFeature: Target.Dependency = "StaffFeature"
static let sponsorFeature: Target.Dependency = "SponsorFeature"
static let contributorFeature: Target.Dependency = "ContributorFeature"
static let kmpModule: Target.Dependency = "KmpModule"
static let theme: Target.Dependency = "Theme"

Expand Down
25 changes: 25 additions & 0 deletions app-ios/Sources/ContributorFeature/ContributorReducer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ComposableArchitecture

@Reducer
public struct ContributorReducer {
public init() { }

@ObservableState
public struct State: Equatable {
var text: String
}

public enum Action {
case onAppear
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
state.text = "Contributor Feature"
return .none
}
}
}
}
21 changes: 21 additions & 0 deletions app-ios/Sources/ContributorFeature/ContributorView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ComposableArchitecture
import SwiftUI

public struct ContributorView: View {
private let store: StoreOf<ContributorReducer>

public init(store: StoreOf<ContributorReducer>) {
self.store = store
}

public var body: some View {
Text(store.text)
.onAppear {
store.send(.onAppear)
}
}
}

#Preview {
ContributorView(store: .init(initialState: .init(text: "Hoge"), reducer: { ContributorReducer() }))
}
25 changes: 25 additions & 0 deletions app-ios/Sources/SponsorFeature/SponsorReducer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ComposableArchitecture

@Reducer
public struct SponsorReducer {
public init() { }

@ObservableState
public struct State: Equatable {
var text: String
}

public enum Action {
case onAppear
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
state.text = "Sponsor Feature"
return .none
}
}
}
}
21 changes: 21 additions & 0 deletions app-ios/Sources/SponsorFeature/SponsorView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ComposableArchitecture
import SwiftUI

public struct SponsorView: View {
private let store: StoreOf<SponsorReducer>

public init(store: StoreOf<SponsorReducer>) {
self.store = store
}

public var body: some View {
Text(store.text)
.onAppear {
store.send(.onAppear)
}
}
}

#Preview {
SponsorView(store: .init(initialState: .init(text: "Hoge"), reducer: { SponsorReducer() }))
}
25 changes: 25 additions & 0 deletions app-ios/Sources/StaffFeature/StaffReducer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ComposableArchitecture

@Reducer
public struct StaffReducer {
public init() { }

@ObservableState
public struct State: Equatable {
var text: String
}

public enum Action {
case onAppear
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
state.text = "Staff Feature"
return .none
}
}
}
}
21 changes: 21 additions & 0 deletions app-ios/Sources/StaffFeature/StaffView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ComposableArchitecture
import SwiftUI

public struct StaffView: View {
private let store: StoreOf<StaffReducer>

public init(store: StoreOf<StaffReducer>) {
self.store = store
}

public var body: some View {
Text(store.text)
.onAppear {
store.send(.onAppear)
}
}
}

#Preview {
StaffView(store: .init(initialState: .init(text: "Hoge"), reducer: { StaffReducer() }))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest
import ComposableArchitecture
@testable import ContributorFeature

final class ContributorFeatureTests: XCTestCase {

@MainActor
func testExample() async throws {
let store = TestStore(initialState: ContributorReducer.State(text: "HOGE")) {
ContributorReducer()
}
await store.send(.onAppear) {
$0.text = "Contributor Feature"
}
}

}
17 changes: 17 additions & 0 deletions app-ios/Tests/SponsorFeatureTests/SponsorFeatureTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest
import ComposableArchitecture
@testable import SponsorFeature

final class SponsorFeatureTests: XCTestCase {

@MainActor
func testExample() async throws {
let store = TestStore(initialState: SponsorReducer.State(text: "HOGE")) {
SponsorReducer()
}
await store.send(.onAppear) {
$0.text = "Sponsor Feature"
}
}

}
17 changes: 17 additions & 0 deletions app-ios/Tests/StaffFeatureTests/StaffFeatureTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest
import ComposableArchitecture
@testable import StaffFeature

final class StaffFeatureTests: XCTestCase {

@MainActor
func testExample() async throws {
let store = TestStore(initialState: StaffReducer.State(text: "HOGE")) {
StaffReducer()
}
await store.send(.onAppear) {
$0.text = "Staff Feature"
}
}

}

0 comments on commit cfa08ba

Please sign in to comment.