Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: (#715) ๊ณต์ง€์‚ฌํ•ญ ๋ฆฌ์ŠคํŠธ์— ์ฝ์—ˆ๋Š”์ง€ ์—ฌ๋ถ€ ์ธ๋””์ผ€์ดํ„ฐ ์ถ”๊ฐ€ #718

Merged
merged 6 commits into from
Jul 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public struct FetchNoticeEntity {
public let thumbnail: FetchNoticeEntity.Image
public let origins: [FetchNoticeEntity.Image]
public let createdAt: Double
public var isRead: Bool = true
}

public extension FetchNoticeEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ import RxSwift

public struct FetchNoticeAllUseCaseStub: FetchNoticeAllUseCase {
public func execute() -> Single<[FetchNoticeEntity]> {
return .just([])
let title1 = "๊ณต์ง€์‚ฌํ•ญ ๋‘์ค„์ธ ๊ฒฝ์šฐ ๊ณต์ง€์‚ฌํ•ญ ๋‘์ค„์ธ ๊ฒฝ์šฐ ๊ณต์ง€์‚ฌํ•ญ ๋‘์ค„์ธ ๊ฒฝ์šฐ ๊ณต์ง€์‚ฌํ•ญ ๋‘์ค„์ธ ๊ฒฝ์šฐ"
let title2 = "์™ํƒ€๋ฒ„์Šค ๋ฎค์ง 2.0 ์—…๋ฐ์ดํŠธ"
let content2 =
"๊ณต์ง€์‚ฌํ•ญ ๋‚ด์šฉ์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.\n์œ„์•„๋ž˜ ์—ฌ๋ฐฑ์— ๋งž์ถฐ ๋‹ต๋ณ€ ๊ธธ์ด๊ฐ€ ์œ ๋™์ ์œผ๋กœ ๋ฐ”๋€๋‹ˆ๋‹ค.\n\n์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ ๋‹ต๋ณ€์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.\n์œ„์•„๋ž˜ ์—ฌ๋ฐฑ์— ๋งž์ถฐ ๋‹ต๋ณ€ ๊ธธ์ด๊ฐ€ ์œ ๋™์ ์œผ๋กœ ๋ฐ”๋€๋‹ˆ๋‹ค."
let stubs = [
FetchNoticeEntity(
id: 99992,
category: "์นดํ…Œ๊ณ ๋ฆฌ1",
title: title1,
content: "",
thumbnail: .init(url: "", link: ""),
origins: [],
createdAt: 1
),
FetchNoticeEntity(
id: 99993,
category: "์นดํ…Œ๊ณ ๋ฆฌ2",
title: title2,
content: "",
thumbnail: .init(url: "", link: ""),
origins: [],
createdAt: 2
)
]
return .just(stubs)
}

public init() {}
}
4 changes: 2 additions & 2 deletions Projects/Features/MyInfoFeature/Resources/Notice.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="m1f-sa-uDl">
<rect key="frame" x="20" y="12" width="353" height="24"/>
<rect key="frame" x="20" y="12" width="313" height="24"/>
youn9k marked this conversation as resolved.
Show resolved Hide resolved
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="24" id="pee-Ny-RLf"/>
</constraints>
Expand Down Expand Up @@ -105,7 +105,7 @@
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="m1f-sa-uDl" secondAttribute="trailing" constant="20" id="3tm-Gh-bqA"/>
<constraint firstAttribute="trailing" secondItem="m1f-sa-uDl" secondAttribute="trailing" constant="60" id="3tm-Gh-bqA"/>
<constraint firstAttribute="bottom" secondItem="4h0-84-mJi" secondAttribute="bottom" id="Ah2-oK-8zy"/>
<constraint firstItem="N4D-sc-Poj" firstAttribute="leading" secondItem="m1f-sa-uDl" secondAttribute="leading" id="Gaw-YH-Un4"/>
<constraint firstItem="4h0-84-mJi" firstAttribute="leading" secondItem="SN6-Hr-l7a" secondAttribute="leading" id="Pud-v9-7a7"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private extension NoticeViewController {
return UITableViewCell()
}
cell.update(model: model)
cell.updateVisibleIndicator(visible: !model.isRead)
return cell
}
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@ public final class NoticeViewModel {
return fetchNoticeAllUseCase.execute()
.catchAndReturn([])
}
.map { notices in
let readIDs = Set(PreferenceManager.readNoticeIDs ?? [])
return notices.map { notice in
var notice = notice
notice.isRead = readIDs.contains(notice.id)
return notice
}
}
.bind(to: output.dataSource)
.disposed(by: disposeBag)

input.didTapList
.withLatestFrom(output.dataSource) { ($0, $1) }
.do { selectedIndexPath, notices in
var savedIDs = PreferenceManager.readNoticeIDs ?? []
let selecterdID = notices[selectedIndexPath.row].id
savedIDs.append(selecterdID)
PreferenceManager.readNoticeIDs = savedIDs
youn9k marked this conversation as resolved.
Show resolved Hide resolved
}
.map { _, notices in
let readIDs = Set(PreferenceManager.readNoticeIDs ?? [])
return notices.map { notice in
var notice = notice
notice.isRead = readIDs.contains(notice.id)
return notice
}
}
.debug()
.bind(to: output.dataSource)
.disposed(by: disposeBag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class NoticeListCell: UITableViewCell {
self.contentView.backgroundColor = .clear

titleStringLabel.font = DesignSystemFontFamily.Pretendard.medium.font(size: 16)
titleStringLabel.textColor = DesignSystemAsset.BlueGrayColor.gray900.color
titleStringLabel.textColor = DesignSystemAsset.BlueGrayColor.blueGray900.color
titleStringLabel.setTextWithAttributes(kernValue: -0.5, lineSpacing: 0, lineHeightMultiple: 1.26)

dayLabel.font = DesignSystemFontFamily.Pretendard.light.font(size: 12)
dayLabel.textColor = DesignSystemAsset.BlueGrayColor.gray500.color
dayLabel.textColor = DesignSystemAsset.BlueGrayColor.blueGray500.color
dayLabel.setTextWithAttributes(kernValue: -0.5, lineSpacing: 0, lineHeightMultiple: 0)

timeLabel.font = DesignSystemFontFamily.Pretendard.light.font(size: 12)
timeLabel.textColor = DesignSystemAsset.BlueGrayColor.gray500.color
timeLabel.textColor = DesignSystemAsset.BlueGrayColor.blueGray500.color
timeLabel.setTextWithAttributes(kernValue: -0.5, lineSpacing: 0, lineHeightMultiple: 0)
}
}
Expand All @@ -33,4 +33,24 @@ extension NoticeListCell {
dayLabel.text = (model.createdAt / 1000.0).unixTimeToDate.dateToString(format: "yy.MM.dd")
timeLabel.text = (model.createdAt / 1000.0).unixTimeToDate.dateToString(format: "HH:mm")
}

func updateVisibleIndicator(visible: Bool) {
if visible {
let attributedString = NSMutableAttributedString(string: titleStringLabel.text ?? "")
let padding = NSTextAttachment()
let imageAttachment = NSTextAttachment()
imageAttachment.image = DesignSystemAsset.MyInfo.redDot.image
imageAttachment.bounds = CGRect(x: 0, y: 10, width: 5, height: 5)
padding.bounds = CGRect(x: 0, y: 0, width: 2, height: 0)

attributedString.append(NSAttributedString(attachment: padding))
attributedString.append(NSAttributedString(attachment: imageAttachment))
titleStringLabel.attributedText = attributedString
} else {
guard let attributedText = titleStringLabel.attributedText else { return }
let text = attributedText.string
titleStringLabel.attributedText = nil
youn9k marked this conversation as resolved.
Show resolved Hide resolved
titleStringLabel.text = text
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "dot.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading