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
2 changes: 1 addition & 1 deletion Projects/App/Resources/Pokit-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/ShareExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleName</key>
<string>Pokit</string>
<key>CFBundleShortVersionString</key>
<string>1.0.9</string>
<string>2.0.1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
14 changes: 5 additions & 9 deletions Projects/App/Sources/MainTab/MainTabFeatureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ public extension MainTabView {
}

if self.store.linkPopup != nil {
PokitLinkPopup(
type: $store.linkPopup,
action: { send(.링크팝업_버튼_눌렀을때, animation: .pokitSpring) }
)
PokitLinkPopup(type: $store.linkPopup)
.onAction { send(.링크팝업_버튼_눌렀을때, animation: .pokitSpring) }
}
}
}
Expand All @@ -93,11 +91,9 @@ private extension MainTabView {
.overlay(alignment: .bottom) {
VStack(spacing: 0) {
if store.linkPopup != nil {
PokitLinkPopup(
type: $store.linkPopup,
action: { send(.링크팝업_버튼_눌렀을때, animation: .pokitSpring) }
)
.padding(.bottom, 20)
PokitLinkPopup(type: $store.linkPopup)
.onAction { send(.링크팝업_버튼_눌렀을때, animation: .pokitSpring) }
.padding(.bottom, 20)
}

bottomTabBar
Expand Down
6 changes: 3 additions & 3 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ public extension MainTabFeature {
case .검색:
return .merge(
.send(.path(.element(id: stackElementId, action: .검색(.delegate(.컨텐츠_검색))))),
.send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구))), animation: .pokitSpring)
.send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구, until: 4))), animation: .pokitSpring)
)
default:
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구))), animation: .pokitSpring)
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구, until: 4))), animation: .pokitSpring)
}
case .recommend(.delegate(.저장하기_완료)):
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구))), animation: .pokitSpring)
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구, until: 4))), animation: .pokitSpring)
/// - 각 화면에서 링크 복사 감지했을 때 (링크 추가 및 수정 화면 제외)
case let .path(.element(_, action: .알림함(.delegate(.linkCopyDetected(url))))),
let .path(.element(_, action: .검색(.delegate(.linkCopyDetected(url))))),
Expand Down
21 changes: 15 additions & 6 deletions Projects/DSKit/Sources/Components/PokitCaution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ public struct PokitCaution: View {
private let type: CautionType
private let action: (() -> Void)?

public init(
public init(type: CautionType) {
self.type = type
self.action = nil
}

private init(
type: CautionType,
action: (() -> Void)? = nil
action: (() -> Void)?
) {
self.type = type
self.action = action
Expand Down Expand Up @@ -132,11 +137,15 @@ public struct PokitCaution: View {
.frame(maxHeight: .infinity)
.padding(.bottom, 92)
}

public func onAction(_ action: @escaping () -> Void) -> Self {
PokitCaution(type: self.type, action: action)
}
}

#Preview {
PokitCaution(
type: .미분류_링크없음,
action: {}
)
PokitCaution(type: .미분류_링크없음)
.onAction {
}
}
59 changes: 43 additions & 16 deletions Projects/DSKit/Sources/Components/PokitLinkPopup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,36 @@ public struct PokitLinkPopup: View {
@State
private var second: Int = 0
private let action: (() -> Void)?
private let until: Int
private let timer = Timer.publish(
every: 1,
on: .main,
in: .common
).autoconnect()

public init(
public init(type: Binding<PokitLinkPopup.PopupType?>) {
self._type = type
switch type.wrappedValue {
case let .link(_, _, until),
let .text(_, until),
let .success(_, until),
let .error(_, until),
let .warning(_, until),
let .report(_, until):
self.until = until
default:
self.until = 2
}
self.action = nil
}

private init(
type: Binding<PokitLinkPopup.PopupType?>,
action: (() -> Void)? = nil
until: Int,
action: (() -> Void)?
) {
self._type = type
self.until = until
self.action = action
}

Expand All @@ -40,7 +59,7 @@ public struct PokitLinkPopup: View {
.frame(width: 335, height: 60)
.transition(.move(edge: .bottom).combined(with: .opacity))
.onReceive(timer) { _ in
guard second < 2 else {
guard second < until else {
closedPopup()
return
}
Expand All @@ -61,7 +80,7 @@ public struct PokitLinkPopup: View {
.multilineTextAlignment(.leading)
.foregroundStyle(textColor)

if case let .link(_, url) = type {
if case let .link(_, url, _) = type {
Text(url)
.lineLimit(1)
.pokitFont(.detail2)
Expand Down Expand Up @@ -167,26 +186,34 @@ public struct PokitLinkPopup: View {

private var title: String {
switch type {
case let .link(title, _),
let .text(title),
let .success(title),
let .error(title),
let .warning(title),
let .report(title):
case let .link(title, _, _),
let .text(title, _),
let .success(title, _),
let .error(title, _),
let .warning(title, _),
let .report(title, _):
return title
default: return ""
}
}

public func onAction(_ action: @escaping () -> Void) -> Self {
PokitLinkPopup(
type: self.$type,
until: self.until,
action: action
)
}
}

public extension PokitLinkPopup {
enum PopupType: Equatable {
case link(title: String, url: String)
case text(title: String)
case success(title: String)
case error(title: String)
case warning(title: String)
case report(title: String)
case link(title: String, url: String, until: Int = 2)
case text(title: String, until: Int = 2)
case success(title: String, until: Int = 2)
case error(title: String, until: Int = 2)
case warning(title: String, until: Int = 2)
case report(title: String, until: Int = 2)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Projects/Domain/Sources/Base/BaseContentItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct BaseContentItem: Identifiable, Equatable, PokitLinkCardItem, Sorta
public let data: String
public let domain: String
public let createdAt: String
public let isRead: Bool?
public var isRead: Bool?
public var isFavorite: Bool?
public let keyword: String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public struct CategoryDetailFeature {
domain.contentList.hasNext
}
var isLoading: Bool = true
var isContentsNotEmpty: Bool {
(isFavoriteCategory && contents.contains { $0.content.isFavorite == true }) || (!isFavoriteCategory && !contents.isEmpty)
}

public init(category: BaseCategoryItem) {
self.domain = .init(categpry: category)
Expand Down Expand Up @@ -199,11 +196,14 @@ private extension CategoryDetailFeature {
)

case let .분류_버튼_눌렀을때(type):
if type == .즐겨찾기 {
switch type {
case .즐겨찾기:
state.domain.condition.isFavoriteFlitered.toggle()
guard state.domain.condition.isFavoriteFlitered else { break }
state.domain.condition.isUnreadFlitered = !state.domain.condition.isFavoriteFlitered
} else {
case .안읽음:
state.domain.condition.isUnreadFlitered.toggle()
guard state.domain.condition.isUnreadFlitered else { break }
state.domain.condition.isFavoriteFlitered = !state.domain.condition.isUnreadFlitered
}
return .concatenate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public extension CategoryDetailView {
.padding(.top, 12)
.pokitNavigationBar { navigationBar }
.overlay(
if: store.isContentsNotEmpty,
if: !store.isFavoriteCategory,
alignment: .bottomTrailing
) {
Button(action: { send(.링크_추가_버튼_눌렀을때) }) {
Expand Down Expand Up @@ -215,30 +215,32 @@ private extension CategoryDetailView {
var filterHeader: some View {
let isFavoriteCategory = store.isFavoriteCategory
let favoriteContentsCount = store.contents.filter { $0.content.isFavorite ?? false }.count
if store.isContentsNotEmpty {
HStack(spacing: isFavoriteCategory ? 2 : 8) {
if isFavoriteCategory {
Image(.icon(.link))
.resizable()
.frame(width: 16, height: 16)
.foregroundStyle(.pokit(.icon(.secondary)))
Text("\(favoriteContentsCount)개")
.foregroundStyle(.pokit(.text(.tertiary)))
.pokitFont(.b2(.m))
} else {
favoriteButton

unreadButton
}

HStack(spacing: isFavoriteCategory ? 2 : 8) {
if isFavoriteCategory {
Image(.icon(.link))
.resizable()
.frame(width: 16, height: 16)
.foregroundStyle(.pokit(.icon(.secondary)))

Spacer()
PokitIconLTextLink(
store.sortType.title,
icon: .icon(.align),
action: { send(.정렬_버튼_눌렀을때) }
)
.contentTransition(.numericText())
Text("\(favoriteContentsCount)개")
.foregroundStyle(.pokit(.text(.tertiary)))
.pokitFont(.b2(.m))

} else {
favoriteButton

unreadButton
}

Spacer()

PokitIconLTextLink(
store.sortType.title,
icon: .icon(.align),
action: { send(.정렬_버튼_눌렀을때) }
)
.contentTransition(.numericText())
}
}

Expand Down Expand Up @@ -286,53 +288,47 @@ private extension CategoryDetailView {
}
}

@ViewBuilder
var contentScrollView: some View {
Group {
if !store.isLoading {
if store.contents.isEmpty {
PokitCaution(
type: .포킷상세_링크없음,
action: { send(.링크_추가_버튼_눌렀을때) }
)
} else {
LazyVStack(spacing: 0) {
ForEach(
Array(store.scope(state: \.contents, action: \.contents))
) { store in
let isFirst = store.state.id == self.store.contents.first?.id
let isLast = store.state.id == self.store.contents.last?.id

if !self.store.isFavoriteCategory {
ContentCardView(
store: store,
type: .linkList,
isFirst: isFirst,
isLast: isLast
)
} else {
if store.content.isFavorite == true {
ContentCardView(
store: store,
type: .linkList,
isFirst: isFirst,
isLast: isLast
)
}
}
}
if !store.isLoading {
if store.contents.isEmpty {
PokitCaution(type: .포킷상세_링크없음)
} else {
LazyVStack(spacing: 0) {
ForEach(
Array(store.scope(state: \.contents, action: \.contents))
) { store in
let isFirst = store.state.id == self.store.contents.first?.id
let isLast = store.state.id == self.store.contents.last?.id

if store.hasNext {
PokitLoading()
.task { await send(.pagenation).finish() }
if !self.store.isFavoriteCategory {
ContentCardView(
store: store,
type: .linkList,
isFirst: isFirst,
isLast: isLast
)
} else if store.content.isFavorite == true {
ContentCardView(
store: store,
type: .linkList,
isFirst: isFirst,
isLast: isLast
)
}

Spacer()
}
.padding(.bottom, 36)

if store.hasNext {
PokitLoading()
.task { await send(.pagenation).finish() }
}

Spacer()
}
} else {
PokitLoading()
.padding(.bottom, 36)
}
} else {
PokitLoading()
}
}

Expand Down
Loading
Loading