-
Notifications
You must be signed in to change notification settings - Fork 33
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
박스오피스II [STEP 2] Jusbug, Redmango #107
base: ic_9_jusbug2
Are you sure you want to change the base?
Changes from 9 commits
25b0437
ba1fe36
08e21cd
29a62d5
63941df
d0c063b
eebd642
e57197a
00858bf
471fc2a
12c0be7
40d1019
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
*.xcuserstate | ||
|
||
APIKey.plist | ||
APIKey.plist | ||
BoxOffice.xcodeproj/xcuserdata/redmango1446.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// CollectionViewIconCell.swift | ||
// BoxOffice | ||
// | ||
// Created by redmango1446 on 2023/08/15. | ||
// | ||
|
||
import UIKit | ||
|
||
class CollectionViewIconCell: UICollectionViewCell { | ||
@IBOutlet weak var rankNumberLabel: UILabel! | ||
@IBOutlet weak var movieNameLabel: UILabel! | ||
@IBOutlet weak var rankInfoLabel: UILabel! | ||
@IBOutlet weak var audiNumberLabel: UILabel! | ||
|
||
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
|
||
} | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
self.layer.borderWidth = 1 | ||
self.layer.borderColor = UIColor.black.cgColor | ||
self.layer.cornerRadius = 10 | ||
} | ||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요 함수는 언제 호출될까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
func configureFont() { | ||
rankNumberLabel.font = .preferredFont(forTextStyle: .title1) | ||
rankInfoLabel.font = .preferredFont(forTextStyle: .body) | ||
audiNumberLabel.font = .preferredFont(forTextStyle: .body) | ||
audiNumberLabel.adjustsFontSizeToFitWidth = true | ||
movieNameLabel.font = .preferredFont(forTextStyle: .title3) | ||
movieNameLabel.allowsDefaultTighteningForTruncation = true | ||
movieNameLabel.numberOfLines = 2 | ||
} | ||
|
||
func configureDynamicType() { | ||
rankNumberLabel.adjustsFontForContentSizeCategory = true | ||
rankInfoLabel.adjustsFontForContentSizeCategory = true | ||
movieNameLabel.adjustsFontForContentSizeCategory = true | ||
audiNumberLabel.adjustsFontForContentSizeCategory = true | ||
} | ||
|
||
func configureLabels(with dailyBoxOffice: DailyBoxOffice) { | ||
configureAudiNumberLabel(with: dailyBoxOffice) | ||
configureRankInfoLabel(with: dailyBoxOffice) | ||
rankNumberLabel.text = dailyBoxOffice.rank | ||
movieNameLabel.text = dailyBoxOffice.movieName | ||
} | ||
|
||
func configureAudiNumberLabel(with dailyBoxOffice: DailyBoxOffice) { | ||
let numberFormatter = NumberFormatter() | ||
numberFormatter.numberStyle = .decimal | ||
|
||
guard let audiCnt = Int(dailyBoxOffice.audiCnt), | ||
let formattedAudiCnt = numberFormatter.string(from: NSNumber(value: audiCnt)) else { return } | ||
|
||
guard let audiAcc = Int(dailyBoxOffice.audiAcc), | ||
let formattedAudiAcc = numberFormatter.string(from: NSNumber(value: audiAcc)) else { return } | ||
|
||
audiNumberLabel.text = "오늘 \(formattedAudiCnt) / 총 \(formattedAudiAcc)" | ||
} | ||
|
||
func configureRankInfoLabel(with dailyBoxOffice: DailyBoxOffice) { | ||
switch dailyBoxOffice.rankOldAndNew { | ||
case "NEW": | ||
rankInfoLabel.textColor = .red | ||
rankInfoLabel.text = "신작" | ||
case "OLD": | ||
if dailyBoxOffice.rankInten == "0" { | ||
rankInfoLabel.text = "-" | ||
return | ||
} | ||
|
||
if let rankInten = Int(dailyBoxOffice.rankInten), | ||
let arrow = Arrow(rawValue: rankInten) { | ||
rankInfoLabel.textColor = .black | ||
let rankIntenString = "\(arrow.rawValue)\(abs(rankInten))" | ||
let attributedString = NSMutableAttributedString(string: rankIntenString) | ||
let range = (rankIntenString as NSString).range(of: arrow.rawValue) | ||
attributedString.addAttribute(.foregroundColor, value: arrow.color, range: range) | ||
rankInfoLabel.attributedText = attributedString | ||
} | ||
default: | ||
print("no Data") | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Arrow.swift | ||
// BoxOffice | ||
// | ||
// Created by 박종화 on 2023/08/16. | ||
// | ||
|
||
import UIKit | ||
|
||
enum Arrow: String { | ||
case upArrow = "▲" | ||
case downArrow = "▼" | ||
|
||
var color: UIColor { | ||
switch self { | ||
case .upArrow: | ||
return .red | ||
case .downArrow: | ||
return .blue | ||
} | ||
} | ||
|
||
init?(rawValue: Int) { | ||
self = rawValue > 0 ? .upArrow : .downArrow | ||
} | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 실패하는 경우가 있을까요~? |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
외부에서 접근하는 경우가 있을까요~?
나머지 프로퍼티들도 한 번씩 더 고민 해 보셔도 좋을듯합니다 :)