Skip to content
Open
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
16 changes: 16 additions & 0 deletions 35th-Sopt-Seminar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
A3730B072CD086230075016D /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3730B062CD086230075016D /* SearchViewController.swift */; };
A3730B0E2CD08E9C0075016D /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3730B0D2CD08E9C0075016D /* UIView+.swift */; };
A3730B102CD08F480075016D /* FinanceAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3730B0F2CD08F480075016D /* FinanceAppViewController.swift */; };
A3ED0AF92CF833C50074B07A /* PopularApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3ED0AF82CF833C50074B07A /* PopularApp.swift */; };
A3ED0AFB2CF835F00074B07A /* PopularCharView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3ED0AFA2CF835F00074B07A /* PopularCharView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -68,6 +70,8 @@
A3730B062CD086230075016D /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = "<group>"; };
A3730B0D2CD08E9C0075016D /* UIView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "UIView+.swift"; path = "35th-Sopt-Seminar/Resource/Extension/UIView+.swift"; sourceTree = SOURCE_ROOT; };
A3730B0F2CD08F480075016D /* FinanceAppViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinanceAppViewController.swift; sourceTree = "<group>"; };
A3ED0AF82CF833C50074B07A /* PopularApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopularApp.swift; sourceTree = "<group>"; };
A3ED0AFA2CF835F00074B07A /* PopularCharView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopularCharView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -201,6 +205,7 @@
A35A68C12CD1776200F955A2 /* Core */,
A35A68A52CD0BBC200F955A2 /* Menu */,
A35A68C22CD1776F00F955A2 /* Finance */,
A3ED0AF52CF833230074B07A /* SwiftUIRefactoring */,
);
path = Presentation;
sourceTree = "<group>";
Expand All @@ -214,6 +219,15 @@
path = Extension;
sourceTree = "<group>";
};
A3ED0AF52CF833230074B07A /* SwiftUIRefactoring */ = {
isa = PBXGroup;
children = (
A3ED0AFA2CF835F00074B07A /* PopularCharView.swift */,
A3ED0AF82CF833C50074B07A /* PopularApp.swift */,
);
path = SwiftUIRefactoring;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -298,6 +312,7 @@
A3730B032CD085E90075016D /* GameViewController.swift in Sources */,
A3730AFF2CD0810F0075016D /* AppViewController.swift in Sources */,
A3730B072CD086230075016D /* SearchViewController.swift in Sources */,
A3ED0AFB2CF835F00074B07A /* PopularCharView.swift in Sources */,
A3730B012CD085A00075016D /* TodayViewController.swift in Sources */,
A37050452CD21A2D00C8E163 /* FinancePopularChartTableViewCell.swift in Sources */,
A3730B052CD086090075016D /* ArcadeViewController.swift in Sources */,
Expand All @@ -315,6 +330,7 @@
A3730AFD2CD070CF0075016D /* MainTabBarController.swift in Sources */,
A36347BC2CD8CBDA003B5322 /* FinanceAppModel.swift in Sources */,
A3042BB32CB802100012E684 /* SceneDelegate.swift in Sources */,
A3ED0AF92CF833C50074B07A /* PopularApp.swift in Sources */,
A3730B102CD08F480075016D /* FinanceAppViewController.swift in Sources */,
A370503F2CD20B2300C8E163 /* DownloadState.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import SwiftUI
import SnapKit
import Then

Expand Down Expand Up @@ -133,8 +134,9 @@ extension FinanceAppViewController: UICollectionViewDataSource {
) as? FinanceHeaderView else { return UICollectionReusableView() }
header.configureHeader(title: "유료 순위", subtitle: nil)
header.didTapTotalLabel = { [weak self] in
let viewController = FinancePopularChartViewController()
self?.navigationController?.pushViewController(viewController, animated: true)
let popularChartView = PopularChartView()
let hostingController = UIHostingController(rootView: popularChartView)
self?.navigationController?.pushViewController(hostingController, animated: true)
}
return header
case 3:
Expand All @@ -145,8 +147,9 @@ extension FinanceAppViewController: UICollectionViewDataSource {
) as? FinanceHeaderView else { return UICollectionReusableView() }
header.configureHeader(title: "무료 순위", subtitle: nil)
header.didTapTotalLabel = { [weak self] in
let viewController = FinancePopularChartViewController()
self?.navigationController?.pushViewController(viewController, animated: true)
let popularChartView = PopularChartView()
let hostingController = UIHostingController(rootView: popularChartView)
self?.navigationController?.pushViewController(hostingController, animated: true)
}
return header
default:
Expand Down
162 changes: 162 additions & 0 deletions 35th-Sopt-Seminar/Presentation/SwiftUIRefactoring/PopularApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
//
// PopularApp.swift
// 35th-Sopt-Seminar
//
// Created by 예삐 on 11/28/24.
//

import SwiftUI

struct PopularApp: Identifiable {
let id = UUID()
let appImage: Image
let ranking: Int
let title: String
let subtitle: String
let downloadState: DownloadState
}

extension PopularApp {
static let popularAppList: [PopularApp] = [
PopularApp(
appImage: Image(.imgSilson24),
ranking: 1,
title: "실손 24",
subtitle: "간편한 실손보험 청구",
downloadState: .download
),
PopularApp(
appImage: Image(.imgHantu),
ranking: 2,
title: "한국투자증권",
subtitle: "한국투자",
downloadState: .download
),
PopularApp(
appImage: Image(.imgNaverPay),
ranking: 3,
title: "네이버페이",
subtitle: "지갑 없이 매장에서 결제",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgKakaoPay),
ranking: 4,
title: "카카오페이",
subtitle: "마음 놓고 금융하다",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgNps),
ranking: 5,
title: "내 곁에 국민연금",
subtitle: "국민연금공단 내 곁에 국민연금 대국민 서비스 앱",
downloadState: .download
),
PopularApp(
appImage: Image(.imgKbPay),
ranking: 6,
title: "KB Pay",
subtitle: "모든 금융을 한번에, 한손에, 한눈에 담다",
downloadState: .paid(price: 2200)
),
PopularApp(
appImage: Image(.imgKbank),
ranking: 7,
title: "KB 스타뱅킹",
subtitle: "모바일신분증, 결제, 통신도 다 되는 은행",
downloadState: .download
),
PopularApp(
appImage: Image(.imgHana1Q),
ranking: 8,
title: "하나은행, 하나원큐는 돈 기운 가득한 은행 앱",
subtitle: "송금, 해외송금, 유학생송금",
downloadState: .download
),
PopularApp(
appImage: Image(.imgMonimo),
ranking: 9,
title: "monimo(모니모, 삼성 금융네트웍스)",
subtitle: "모이는 금융, 커지는 혜택!",
downloadState: .download
),
PopularApp(
appImage: Image(.imgNhBank),
ranking: 10,
title: "NH올원뱅크",
subtitle: "금융",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgTossIcon),
ranking: 11,
title: "토스",
subtitle: "금융이 쉬워진다",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgKbank),
ranking: 12,
title: "케이뱅크 (Kbank)",
subtitle: "make money",
downloadState: .download
),
PopularApp(
appImage: Image(.imgSol),
ranking: 13,
title: "신한 SOL 뱅크 - 신한은행 스마트폰 뱅킹",
subtitle: "금융",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgTravelWallet),
ranking: 14,
title: "트래블월렛 - Travel Pay",
subtitle: "페이에 세계를 담다",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgKakaoBank),
ranking: 15,
title: "카카오 뱅크",
subtitle: "이미 모두의 은행",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgSol),
ranking: 16,
title: "신한 SOL 페이 - 신한카드 대표플랫폼",
subtitle: "결제부터 자산관리",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgV3),
ranking: 17,
title: "V3 Mobile Plus",
subtitle: "코스콤 통합인증 / 알림장 메시지 서비스",
downloadState: .paid(price: 14000)
),
PopularApp(
appImage: Image(.imgHyundaiCard),
ranking: 18,
title: "현대카드",
subtitle: "금융",
downloadState: .download
),
PopularApp(
appImage: Image(.imgSol),
ranking: 19,
title: "신한 슈퍼SOL - 신한 유니버설 금융 앱",
subtitle: "금융",
downloadState: .installed
),
PopularApp(
appImage: Image(.imgUp),
ranking: 20,
title: "업비트 - 가장 신뢰받는 디지털 자산 거래소",
subtitle: "금융",
downloadState: .download
)
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// PopularCharView.swift
// 35th-Sopt-Seminar
//
// Created by 예삐 on 11/28/24.
//

import SwiftUI

struct PopularChartView: View {
let popularAppList = PopularApp.popularAppList

var body: some View {
List(popularAppList) { popularApp in
PopularCharViewCell(popularApp: popularApp)
.listRowInsets(EdgeInsets(top: 10, leading: 0, bottom: 10, trailing: 0))
}
.navigationTitle("인기차트")
.listStyle(.plain)
.scrollContentBackground(.hidden)
.scrollIndicators(.hidden)
.background(Color.white)
}
}

struct PopularCharViewCell: View {
let popularApp: PopularApp

var body: some View {
HStack {
appImage
textInfo
Spacer()
downloadButton
}
.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20))
}

var appImage: some View {
popularApp.appImage
.resizable()
.frame(width: 62, height: 62)
.clipShape(RoundedRectangle(cornerRadius: 16))
.overlay {
RoundedRectangle(cornerRadius: 16)
.fill(.clear)
.stroke(Color(.systemGray4), lineWidth: 1)
.frame(width: 62, height: 62)
}
}

var textInfo: some View {
HStack(alignment: .top) {
ranking
titleAndSubtitle
}
.padding(EdgeInsets(top: 0, leading: 4, bottom: 0, trailing: 0))
}

var ranking: some View {
Text(popularApp.ranking.description)
.font(.system(size: 16, weight: .semibold))
}

var titleAndSubtitle: some View {
VStack(alignment: .leading) {
Text(popularApp.title)
.font(.system(size: 16, weight: .regular))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 4, trailing: 0))
.lineLimit(2)
Text(popularApp.subtitle)
.font(.system(size: 12, weight: .regular))
.foregroundStyle(Color(.systemGray))
.lineLimit(2)
}
}

var downloadButton: some View {
Button {

} label: {
Text(downloadButtonTitle)
.foregroundStyle(Color(.systemBlue))
.font(downloadButtonFont)
}
.frame(width: 80, height: 32)
.background(Color(.systemGray6))
.cornerRadius(16)
}

var downloadButtonTitle: String {
switch popularApp.downloadState {
case .installed:
return "열기"
case .update:
return "업데이트"
case .download:
return "받기"
case .paid(let price):
return "₩\(formatPrice(price))"
}
}

var downloadButtonFont: Font {
switch popularApp.downloadState {
case .paid(_):
return .system(size: 14, weight: .bold)
default:
return .system(size: 16, weight: .bold)
}
}

func formatPrice(_ price: Int) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
return formatter.string(from: NSNumber(value: price)) ?? "\(price)"
}
Comment on lines +104 to +117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 이 프로퍼티와 메소드는 여기에 없어도 될 것 같아요!

}