Skip to content

Commit

Permalink
Merge pull request #57 from DroidKaigi/MrSmart00/feature/about-other-…
Browse files Browse the repository at this point in the history
…links
  • Loading branch information
MrSmart00 authored Jun 20, 2024
2 parents 3427e85 + 90bc26f commit 693a40f
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app-ios/Sources/AboutFeature/AboutReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public struct AboutReducer {
@ObservableState
public struct State: Equatable {
var path = StackState<Path.State>()
@Presents var destination: Destination.State?

public init(path: StackState<Path.State> = .init()) {
self.path = path
Expand All @@ -16,20 +17,31 @@ public struct AboutReducer {
public enum Action: ViewAction {
case path(StackAction<Path.State, Path.Action>)
case view(View)
case presentation(PresentationAction<Destination.Action>)

@CasePathable
public enum View {
case staffsTapped
case contributersTapped
case sponsorsTapped
case codeOfConductTapped
case acknowledgementsTapped
case privacyPolicyTapped
}
}

@Reducer(state: .equatable)
public enum Destination {
case codeOfConduct
case privacyPolicy
}

@Reducer(state: .equatable)
public enum Path {
case staffs
case contributers
case sponsors
case acknowledgements
}

public var body: some ReducerOf<Self> {
Expand All @@ -44,6 +56,17 @@ public struct AboutReducer {
case .view(.sponsorsTapped):
state.path.append(.sponsors)
return .none
case .view(.codeOfConductTapped):
state.destination = .codeOfConduct
return .none
case .view(.acknowledgementsTapped):
state.path.append(.acknowledgements)
return .none
case .view(.privacyPolicyTapped):
state.destination = .privacyPolicy
return .none
case .presentation:
return .none
case .path:
return .none
}
Expand Down
63 changes: 62 additions & 1 deletion app-ios/Sources/AboutFeature/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ public struct AboutView: View {
Text("Contributers")
case .sponsors:
Text("Sponsors")
case .acknowledgements:
Text("Acknowledgements")
}
}
.sheet(item: $store.scope(state: \.destination?.codeOfConduct, action: \.presentation.codeOfConduct), content: { _ in
Text("CodeOfConduct")
})
.sheet(item: $store.scope(state: \.destination?.privacyPolicy, action: \.presentation.privacyPolicy), content: { _ in
Text("PrivacyPolicy")
})
}

@ViewBuilder var content: some View {
Expand Down Expand Up @@ -82,7 +90,60 @@ public struct AboutView: View {
.background(Color(.outlineOutlineVariant))

}

.padding(.bottom, 32)

VStack(alignment: .leading) {
Text("Others")
.foregroundStyle(Color(.surfaceOnSurfaceVariant))
.font(.headline)

Button(action: {
send(.codeOfConductTapped)
}, label: {
Label(
String(localized: "CodeOfConduct", bundle: .module),
systemImage: "apple.logo"
)
.labelStyle(AboutLabelStyle())
Spacer()
})
.padding(.init(top: 24, leading: 14, bottom: 24, trailing: 14))

Divider()
.background(Color(.outlineOutlineVariant))

Button(action: {
send(.acknowledgementsTapped)
}, label: {
Label(
String(localized: "Acknowledgements", bundle: .module),
systemImage: "doc.on.doc"
)
.labelStyle(AboutLabelStyle())
Spacer()
})
.padding(.init(top: 24, leading: 14, bottom: 24, trailing: 14))

Divider()
.background(Color(.outlineOutlineVariant))

Button(action: {
send(.privacyPolicyTapped)
}, label: {
Label(
String(localized: "PrivacyPolicy", bundle: .module),
systemImage: "lock.shield"
)
.labelStyle(AboutLabelStyle())
Spacer()
})
.padding(.init(top: 24, leading: 14, bottom: 24, trailing: 14))

Divider()
.background(Color(.outlineOutlineVariant))

}

}
.padding(.horizontal, 16)
}
Expand Down
40 changes: 40 additions & 0 deletions app-ios/Sources/AboutFeature/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
{
"sourceLanguage" : "en",
"strings" : {
"Acknowledgements" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "ライセンス"
}
}
}
},
"CodeOfConduct" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "行動規範"
}
}
}
},
"Contributers" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -81,6 +101,26 @@
}
}
},
"Others" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "Others"
}
}
}
},
"PrivacyPolicy" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "プライバシーポリシー"
}
}
}
},
"Sponsors" : {
"localizations" : {
"ja" : {
Expand Down
30 changes: 30 additions & 0 deletions app-ios/Tests/AboutFeatureTests/AboutFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,34 @@ final class AboutFeatureTests: XCTestCase {
$0.path[id: 0] = .sponsors
}
}

@MainActor
func testTappedCodeOfConduct() async {
let store = TestStore(initialState: AboutReducer.State()) {
AboutReducer()
}
await store.send(\.view.codeOfConductTapped) {
$0.destination = .codeOfConduct
}
}

@MainActor
func testTappedAcknowledgements() async {
let store = TestStore(initialState: AboutReducer.State()) {
AboutReducer()
}
await store.send(\.view.acknowledgementsTapped) {
$0.path[id: 0] = .acknowledgements
}
}

@MainActor
func testTappedPrivacyPolicy() async {
let store = TestStore(initialState: AboutReducer.State()) {
AboutReducer()
}
await store.send(\.view.privacyPolicyTapped) {
$0.destination = .privacyPolicy
}
}
}

0 comments on commit 693a40f

Please sign in to comment.