Skip to content

Commit

Permalink
Merge pull request #270 from Team-return/feature/(#269)-employment_chart
Browse files Browse the repository at this point in the history
🔗 :: (#269) ChartView 구현
  • Loading branch information
circle0802 authored Feb 13, 2025
2 parents 35ba638 + 56f210d commit d04a830
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 16 deletions.
15 changes: 8 additions & 7 deletions .package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "b067a63c8bc0f5aca329f5ca41354d30c3caa5c3e8dd95aa4c5af77ae6b5b2f1",
"pins" : [
{
"identity" : "abseil-cpp-swiftpm",
Expand Down Expand Up @@ -50,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "26c898aed8bed13b8a63057ee26500abbbcb8d55",
"version" : "7.13.1"
"revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6",
"version" : "7.13.3"
}
},
{
Expand All @@ -77,8 +78,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "43aaef65e0c665daadf848761d560e446d350d3d",
"version" : "1.22.4"
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
Expand All @@ -104,10 +105,10 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8",
"version" : "1.25.2"
"revision" : "ebc7251dd5b37f627c93698e4374084d98409633",
"version" : "1.28.2"
}
}
],
"version" : 2
"version" : 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public extension TargetDependency.SPM {
static let KeychainSwift = TargetDependency.external(name: "KeychainSwift")
static let ReactorKit = TargetDependency.external(name: "ReactorKit")
static let RxGesture = TargetDependency.external(name: "RxGesture")
static let DGCharts = TargetDependency.external(name: "DGCharts")
static let FCM = TargetDependency.package(product: "FirebaseMessaging")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "extended-srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x53",
"green" : "0x2C",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "extended-srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xC9",
"green" : "0x7B",
"red" : "0x23"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public extension UIColor.Sub {
static let green20: UIColor = DesignSystemAsset.Sub.green20.color
static let skyBlue10: UIColor = DesignSystemAsset.Sub.skyBlue10.color
static let skyBlue20: UIColor = DesignSystemAsset.Sub.skyBlue20.color
static let skyBlue30: UIColor = DesignSystemAsset.Sub.skyBlue30.color
}
30 changes: 24 additions & 6 deletions Projects/Modules/DesignSystem/Sources/Typography/JobisFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ extension JobisFontStyle {
case .headLine:
return 28

case .subHeadLine, .body:
case .subHeadLine, .body, .largeBody:
return 24

case .subBody, .description:
case .subBody, .description, .boldBody:
return 20

case .cation:
case .caption:
return 16

case .subcaption:
return 14
}
}

Expand All @@ -46,11 +49,20 @@ extension JobisFontStyle {
case .subBody:
return pretendard.semiBold.font(size: 14)

case .boldBody:
return pretendard.bold.font(size: 16)

case .largeBody:
return pretendard.medium.font(size: 20)

case .description:
return pretendard.medium.font(size: 14)

case .cation:
case .caption:
return pretendard.medium.font(size: 12)

case .subcaption:
return pretendard.medium.font(size: 10)
}
}

Expand All @@ -64,14 +76,20 @@ extension JobisFontStyle {
case .headLine:
return 18

case .subHeadLine, .body:
case .largeBody:
return 20

case .subHeadLine, .body, .boldBody:
return 16

case .subBody, .description:
return 14

case .cation:
case .caption:
return 12

case .subcaption:
return 10
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public enum JobisFontStyle {
case subHeadLine
case body
case subBody
case boldBody
case largeBody
case description
case cation
case caption
case subcaption
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class JobisTabBarItem: UITabBarItem {
self.title = title
self.image = image
self.tag = tag
self.setTitleTextAttributes([.font: UIFont.jobisFont(.cation)], for: .normal)
self.setTitleTextAttributes([.font: UIFont.jobisFont(.caption)], for: .normal)
}

required init?(coder: NSCoder) {
Expand Down
3 changes: 2 additions & 1 deletion Projects/Modules/ThirdPartyLib/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let project = Project.makeModule(
.SPM.KeychainSwift,
.SPM.ReactorKit,
.SPM.RxGesture,
.SPM.FCM
.SPM.FCM,
.SPM.DGCharts
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import UIKit
import Domain
import SnapKit
import Then
import DesignSystem
import RxSwift
import DGCharts

final class ChartView: BaseView {
private let disposeBag = DisposeBag()
private let chartContainerView = UIView()
private var employPieChartView = PieChartView().then {
$0.rotationEnabled = false
$0.highlightPerTapEnabled = false
$0.holeRadiusPercent = 0.6
$0.legend.enabled = false
let entries = [
PieChartDataEntry(value: 100, label: ""),
PieChartDataEntry(value: 0, label: "")
]

let dataSet = PieChartDataSet(entries: entries)
dataSet.colors = [.Sub.skyBlue10, .Primary.blue20]
dataSet.drawValuesEnabled = false
dataSet.selectionShift = 0

let data = PieChartData(dataSet: dataSet)
$0.data = data
}
private let employPercentageLabel = UILabel().then {
$0.setJobisText("\(0)%", font: .boldBody, color: .Primary.blue20)
}
private let employLabel = UILabel().then {
$0.setJobisText("취업 현황", font: .subBody, color: .Sub.skyBlue30)
}
private let stickView = UIView().then {
$0.backgroundColor = .GrayScale.gray40
$0.layer.cornerRadius = 7
}
private let totalStatsLabel = UILabel().then {
$0.setJobisText("전체 통계", font: .description, color: .Sub.skyBlue30)
}
private let totalStatsValueLabel = UILabel().then {
$0.setJobisText("\(0)/\(0)", font: .description, color: .Primary.blue20)
}
private let completedLegend = LegendView().then {
$0.setup(color: .Primary.blue20, textColor: .Primary.blue20, text: "취업완료")
}
private let incompleteLegend = LegendView().then {
$0.setup(color: .Sub.skyBlue10, textColor: .GrayScale.gray60, text: "취업 전")
}
private let legendView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 4
$0.alignment = .leading
}
override func addView() {
[
chartContainerView,
employLabel,
legendView,
totalStatsLabel,
totalStatsValueLabel
].forEach { self.addSubview($0) }
[
employPieChartView,
stickView,
totalStatsLabel,
totalStatsValueLabel
].forEach { chartContainerView.addSubview($0) }
employPieChartView.addSubview(employPercentageLabel)
[
completedLegend,
incompleteLegend
].forEach { legendView.addArrangedSubview($0) }
}
override func setLayout() {
chartContainerView.snp.makeConstraints {
$0.center.equalToSuperview()
$0.height.equalTo(120)
$0.width.equalTo(215)
}

employPieChartView.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalToSuperview()
$0.height.width.equalTo(120)
}

stickView.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalTo(employPieChartView.snp.trailing).offset(16)
$0.height.equalTo(30)
$0.width.equalTo(1)
}

totalStatsLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(38)
$0.centerX.equalTo(totalStatsValueLabel)
}

totalStatsValueLabel.snp.makeConstraints {
$0.top.equalTo(totalStatsLabel.snp.bottom).offset(8)
$0.leading.equalTo(stickView.snp.trailing).offset(21)
}

employPercentageLabel.snp.makeConstraints {
$0.center.equalToSuperview()
}

employLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(20)
$0.leading.equalToSuperview().inset(16)
}

legendView.snp.makeConstraints {
$0.top.equalToSuperview().inset(20)
$0.trailing.equalToSuperview().inset(16)
$0.height.equalTo(28)
$0.width.equalTo(47)
}
}
override func configureView() {
super.configureView()
backgroundColor = .GrayScale.gray10
layer.cornerRadius = 6
layer.borderWidth = 1
layer.borderColor = UIColor.GrayScale.gray30.cgColor
layer.shadowOffset = CGSize(width: 0, height: 3)
layer.shadowColor = UIColor(red: 112/255, green: 144/255, blue: 176/255, alpha: 0.12).cgColor
layer.shadowRadius = 12
layer.shadowOpacity = 1
clipsToBounds = false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import UIKit
import Domain
import SnapKit
import Then
import DesignSystem
import RxSwift

final class LegendView: BaseView {
private let legendColorView = UIView().then {
$0.layer.cornerRadius = 3
}
private let legendLabel = UILabel()

override func addView() {
[
legendColorView,
legendLabel
].forEach { self.addSubview($0) }
}
override func setLayout() {
self.snp.makeConstraints {
$0.height.equalTo(12)
$0.width.equalTo(47)
}

legendColorView.snp.makeConstraints {
$0.leading.equalToSuperview()
$0.centerY.equalToSuperview()
$0.width.height.equalTo(6)
}

legendLabel.snp.makeConstraints {
$0.leading.equalTo(legendColorView.snp.trailing).offset(6)
$0.centerY.equalToSuperview()
}
}
public func setup(
color: UIColor,
textColor: UIColor,
text: String
) {
self.legendColorView.backgroundColor = color
self.legendLabel.setJobisText(text, font: .subcaption, color: textColor)
}
}
Loading

0 comments on commit d04a830

Please sign in to comment.