Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/Sources/AnalyticsClient/Events/TopicEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

public enum TopicEvent: Event {
case onRefresh
case topicHatOpenButtonTapped
case topicHatButtonTapped
case topicPollOpenButtonTapped
case userTapped(Int)
case urlTapped(URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ extension TopicFeature {
case .view(.onRefresh):
analytics.log(TopicEvent.onRefresh)

case .view(.topicHatOpenButtonTapped):
analytics.log(TopicEvent.topicHatOpenButtonTapped)
case .view(.topicHatButtonTapped):
analytics.log(TopicEvent.topicHatButtonTapped)

case .view(.topicPollOpenButtonTapped):
analytics.log(TopicEvent.topicPollOpenButtonTapped)
Expand Down
10 changes: 10 additions & 0 deletions Modules/Sources/TopicFeature/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
}
}
},
"Close Hat" : {
"localizations" : {
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Закрыть шапку"
}
}
}
},
"Copy Link" : {
"localizations" : {
"ru" : {
Expand Down
14 changes: 8 additions & 6 deletions Modules/Sources/TopicFeature/TopicFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public struct TopicFeature: Reducer, Sendable {
case onNextAppear
case onRefresh
case finishedPostAnimation
case topicHatOpenButtonTapped
case topicHatButtonTapped(forOpen: Bool)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может лучше shouldOpen или isOpened

case topicPollOpenButtonTapped
case topicPollVoteButtonTapped([Int: Set<Int>])
case changeKarmaTapped(Int, Bool)
Expand Down Expand Up @@ -226,11 +226,13 @@ public struct TopicFeature: Reducer, Sendable {
case .view(.onRefresh):
return .send(.internal(.refresh))

case .view(.topicHatOpenButtonTapped):
guard let firstPost = state.topic?.posts.first else { fatalError("No Topic Hat Found") }
let firstPostNodes = TopicNodeBuilder(text: firstPost.content, attachments: firstPost.attachments).build()
state.posts[0] = UIPost(post: firstPost, content: firstPostNodes.map { .init(value: $0) })
state.shouldShowTopicHatButton = false
case .view(.topicHatButtonTapped(let forOpen)):
if forOpen {
guard let firstPost = state.topic?.posts.first else { fatalError("No Topic Hat Found") }
let firstPostNodes = TopicNodeBuilder(text: firstPost.content, attachments: firstPost.attachments).build()
state.posts[0] = UIPost(post: firstPost, content: firstPostNodes.map { .init(value: $0) })
}
state.shouldShowTopicHatButton = !forOpen
return .none

case .view(.topicPollOpenButtonTapped):
Expand Down
9 changes: 8 additions & 1 deletion Modules/Sources/TopicFeature/TopicScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public struct TopicScreen: View {
}
.padding(.bottom, 16)
}
.id(UUID().uuidString) // bugfix for Hat hiding
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Гавно, лагает

._inScrollContentDetector(state: $navigationMinimized)
.onAppear {
scrollProxy = proxy
Expand Down Expand Up @@ -212,7 +213,7 @@ public struct TopicScreen: View {

if store.shouldShowTopicHatButton {
Button {
send(.topicHatOpenButtonTapped)
send(.topicHatButtonTapped(forOpen: true))
} label: {
Text("Topic Hat", bundle: .module)
.font(.headline)
Expand Down Expand Up @@ -435,6 +436,12 @@ public struct TopicScreen: View {
ContextButton(text: LocalizedStringResource("Copy Link", bundle: .module), symbol: .docOnDoc) {
send(.contextPostMenu(.copyLink(post.id)))
}

if store.posts.first?.id == post.id, !store.pageNavigation.isFirstPage, !store.shouldShowTopicHatButton {
ContextButton(text: LocalizedStringResource("Close Hat", bundle: .module), symbol: .eyeSlash) {
send(.topicHatButtonTapped(forOpen: false))
}
}
}
} label: {
Image(systemSymbol: .ellipsis)
Expand Down