Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Modules/Sources/ArticleFeature/ArticleScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public struct ArticleScreen: View {

ToolbarItemGroup(placement: .topBarTrailing) {
HStack(spacing: 8) {
ToolbarButton(placement: .topBarTrailing, symbol: .bookmark) {
store.send(.bookmarkButtonTapped)
}
// ToolbarButton(placement: .topBarTrailing, symbol: .bookmark) {
// store.send(.bookmarkButtonTapped)
// }

ArticleMenu(store: store, isDark: navBarFullyVisible)
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/Sources/ArticleFeature/Comments/CommentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ struct CommentView: View {
@ViewBuilder
private func MenuButton() -> some View {
Menu {
ContextButton(text: "Report", symbol: .exclamationmarkTriangle, bundle: .module) {
store.send(.reportButtonTapped)
}
// ContextButton(text: "Report", symbol: .exclamationmarkTriangle, bundle: .module) {
// store.send(.reportButtonTapped)
// }
ContextButton(
text: store.comment.isHidden ? "Unhide comment" : "Hide comment",
symbol: store.comment.isHidden ? .eyeSlash : .eye,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
}
},
"Problems with article?" : {
"extractionState" : "stale",
"localizations" : {
"ru" : {
"stringUnit" : {
Expand All @@ -152,6 +153,7 @@
}
},
"Report" : {
"extractionState" : "stale",
"localizations" : {
"ru" : {
"stringUnit" : {
Expand Down
6 changes: 3 additions & 3 deletions Modules/Sources/ArticleFeature/Views/ArticleMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public struct ArticleMenu: View {
ContextButton(text: "Share Link", symbol: .squareAndArrowUp, bundle: .module) {
store.send(.menuActionTapped(.shareLink))
}
ContextButton(text: "Problems with article?", symbol: .questionmarkCircle, bundle: .module) {
store.send(.menuActionTapped(.report))
}
// ContextButton(text: "Problems with article?", symbol: .questionmarkCircle, bundle: .module) {
// store.send(.menuActionTapped(.report))
// }
} label: {
Image(systemSymbol: .ellipsis)
.font(.body)
Expand Down
5 changes: 5 additions & 0 deletions Modules/Sources/FavoritesFeature/FavoritesFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct FavoritesFeature: Reducer, Sendable {
@ObservableState
public struct State: Equatable {
@Shared(.appSettings) var appSettings: AppSettings
@Shared(.userSession) var userSession: UserSession?
@Presents var sort: SortFeature.State?

public var favorites: [FavoriteInfo] = []
Expand All @@ -35,6 +36,10 @@ public struct FavoritesFeature: Reducer, Sendable {

public var pageNavigation = PageNavigationFeature.State(type: .forum)

public var isUserAuthorized: Bool {
return userSession != nil
}

public init(
favorites: [FavoriteInfo] = [],
favoritesImportant: [FavoriteInfo] = []
Expand Down
36 changes: 19 additions & 17 deletions Modules/Sources/FavoritesFeature/FavoritesScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,26 @@ public struct FavoritesScreen: View {
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
HStack {
Menu {
ContextButton(
text: "Sort",
symbol: .line3HorizontalDecrease,
bundle: .module
) {
store.send(.contextOptionMenu(.sort))
}

ContextButton(
text: "Read All",
symbol: .checkmarkCircle,
bundle: .module
) {
store.send(.contextOptionMenu(.markAllAsRead))
if store.isUserAuthorized {
Menu {
ContextButton(
text: "Sort",
symbol: .line3HorizontalDecrease,
bundle: .module
) {
store.send(.contextOptionMenu(.sort))
}

ContextButton(
text: "Read All",
symbol: .checkmarkCircle,
bundle: .module
) {
store.send(.contextOptionMenu(.markAllAsRead))
}
} label: {
Image(systemSymbol: .ellipsisCircle)
}
} label: {
Image(systemSymbol: .ellipsisCircle)
}

Button {
Expand Down
5 changes: 5 additions & 0 deletions Modules/Sources/ForumFeature/ForumFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct ForumFeature: Reducer, Sendable {
@ObservableState
public struct State: Equatable {
@Shared(.appSettings) var appSettings: AppSettings
@Shared(.userSession) var userSession: UserSession?

public var forumId: Int
public var forumName: String?
Expand All @@ -37,6 +38,10 @@ public struct ForumFeature: Reducer, Sendable {

public var pageNavigation = PageNavigationFeature.State(type: .forum)

public var isUserAuthorized: Bool {
return userSession != nil
}

public init(
forumId: Int,
forumName: String?
Expand Down
26 changes: 14 additions & 12 deletions Modules/Sources/ForumFeature/ForumScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,21 @@ public struct ForumScreen: View {
store.send(.contextCommonMenu(.openInBrowser, id, isForum))
}

if isUnread {
ContextButton(text: "Mark Read", symbol: .checkmarkCircle, bundle: .module) {
store.send(.contextCommonMenu(.markRead, id, isForum))
if store.isUserAuthorized {
if isUnread {
ContextButton(text: "Mark Read", symbol: .checkmarkCircle, bundle: .module) {
store.send(.contextCommonMenu(.markRead, id, isForum))
}
}
}

Section {
ContextButton(
text: isFavorite ? "Remove from favorites" : "Add to favorites",
symbol: isFavorite ? .starFill : .star,
bundle: .module
) {
store.send(.contextCommonMenu(.setFavorite(isFavorite), id, isForum))
Section {
ContextButton(
text: isFavorite ? "Remove from favorites" : "Add to favorites",
symbol: isFavorite ? .starFill : .star,
bundle: .module
) {
store.send(.contextCommonMenu(.setFavorite(isFavorite), id, isForum))
}
}
}
}
Expand Down
62 changes: 51 additions & 11 deletions Modules/Sources/HistoryFeature/HistoryScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,46 @@ public struct HistoryScreen: View {
Color(.Background.primary)
.ignoresSafeArea()

if !store.isLoading {
VStack(spacing: 1) {
if store.pageNavigation.shouldShow {
PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation))
.padding(.horizontal, 16)
}
if !store.history.isEmpty {
List {
Navigation()

List(store.history, id: \.hashValue) { history in
ForEach(store.history, id: \.hashValue) { history in
HistorySection(history: history)
}
.scrollContentBackground(.hidden)
.listRowInsets(EdgeInsets(top: 0, leading: 24, bottom: 0, trailing: 24))

Navigation()
}
} else {
PDALoader()
.frame(width: 24, height: 24)
.scrollContentBackground(.hidden)
} else if !store.isLoading {
EmptyHistory()
}
}
.navigationTitle(Text("History", bundle: .module))
.navigationBarTitleDisplayMode(.large)
.overlay {
if store.isLoading {
PDALoader()
.frame(width: 24, height: 24)
}
}
.task {
store.send(.onTask)
}
}
}

// MARK: - Page Navigation

@ViewBuilder
private func Navigation() -> some View {
if store.pageNavigation.shouldShow {
PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation))
//.listRowBackground(.primary)
}
}

// MARK: - History Section

private func HistorySection(history: HistoryRow) -> some View {
Expand All @@ -68,6 +83,31 @@ public struct HistoryScreen: View {
.listRowBackground(Color(.Background.teritary))
}

// MARK: - Empty History

@ViewBuilder
private func EmptyHistory() -> some View {
VStack(spacing: 0) {
Image(systemSymbol: .clockArrowCirclepath)
.font(.title)
.foregroundStyle(tintColor)
.frame(width: 48, height: 48)
.padding(.bottom, 6)

Text("No history", bundle: .module)
.font(.title3)
.bold()
.foregroundColor(.primary)
.padding(.bottom, 6)

Text("View any topic in forum and it displays here.", bundle: .module)
.font(.footnote)
.foregroundStyle(.tertiary)
.multilineTextAlignment(.center)
.frame(maxWidth: UIScreen.main.bounds.width * 0.7)
}
}

// MARK: - Row

@ViewBuilder
Expand Down
22 changes: 22 additions & 0 deletions Modules/Sources/HistoryFeature/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
}
}
},
"No history" : {
"localizations" : {
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Нет истории"
}
}
}
},
"Today" : {
"extractionState" : "stale",
"localizations" : {
"ru" : {
"stringUnit" : {
Expand All @@ -24,7 +35,18 @@
}
}
},
"View any topic in forum and it displays here." : {
"localizations" : {
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Посмотрите любую тему на форуме и она появится тут."
}
}
}
},
"Yesterday" : {
"extractionState" : "stale",
"localizations" : {
"ru" : {
"stringUnit" : {
Expand Down
8 changes: 6 additions & 2 deletions Modules/Sources/Models/Forum/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public struct Post: Sendable, Hashable, Identifiable, Codable {
public let name: String
public let size: Int
public let metadata: Metadata?
public let downloadCount: Int?

public enum AttachmentType: Sendable, Hashable, Codable {
case file
Expand All @@ -68,13 +69,15 @@ public struct Post: Sendable, Hashable, Identifiable, Codable {
type: AttachmentType,
name: String,
size: Int,
metadata: Metadata?
metadata: Metadata?,
downloadCount: Int?
) {
self.id = id
self.type = type
self.name = name
self.size = size
self.metadata = metadata
self.downloadCount = downloadCount
}
}

Expand Down Expand Up @@ -146,7 +149,8 @@ extension Post {
width: 281,
height: 500,
url: "https://cs2c9f.4pda.ws/14308454.png"
)
),
downloadCount: nil
)
],
createdAt: Date(timeIntervalSince1970: 1725706321),
Expand Down
5 changes: 4 additions & 1 deletion Modules/Sources/ParsingClient/Parsers/TopicParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public struct TopicParser {
)
} else { nil }

let downloadCount = attachment.count == 5 ? attachment[4] as? Int : nil

let type = if attachment[1] as! Int == 1 {
Post.Attachment.AttachmentType.image
} else {
Expand All @@ -123,7 +125,8 @@ public struct TopicParser {
type: type,
name: attachment[2] as! String,
size: attachment[3] as! Int,
metadata: metadata
metadata: metadata,
downloadCount: downloadCount
)
}
}
Expand Down
16 changes: 8 additions & 8 deletions Modules/Sources/SharedUI/Articles/MenuButtons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public struct MenuButtons: View {
ContextButton(text: "Open In Browser", symbol: .safari, bundle: .module) {
contextMenuActions.openInBrowserAction()
}
ContextButton(text: "Problems with article?", symbol: .exclamationmarkBubble, bundle: .module) {
contextMenuActions.reportAction()
}
// ContextButton(text: "Problems with article?", symbol: .exclamationmarkBubble, bundle: .module) {
// contextMenuActions.reportAction()
// }
}

Section {
ContextButton(text: "Add To Bookmarks", symbol: .bookmark, bundle: .module) {
contextMenuActions.addToBookmarksAction()
}
}
// Section {
// ContextButton(text: "Add To Bookmarks", symbol: .bookmark, bundle: .module) {
// contextMenuActions.addToBookmarksAction()
// }
// }
}
}
}
5 changes: 5 additions & 0 deletions Modules/Sources/TopicFeature/TopicFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct TopicFeature: Reducer, Sendable {
@ObservableState
public struct State: Equatable {
@Shared(.appSettings) var appSettings: AppSettings
@Shared(.userSession) var userSession: UserSession?

public let topicId: Int
public let initialOffset: Int
Expand All @@ -39,6 +40,10 @@ public struct TopicFeature: Reducer, Sendable {

var pageNavigation = PageNavigationFeature.State(type: .topic)

public var isUserAuthorized: Bool {
return userSession != nil
}

public init(
topicId: Int,
initialOffset: Int = 0,
Expand Down
Loading