-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] SwiftUI로 UI짜기 기본편 #11
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
Open
mmaybei
wants to merge
6
commits into
main
Choose a base branch
from
feat/#10-week06
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
35th-Sopt-Seminar/Presentation/SwiftUIRefactoring/PopularApp.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) | ||
| ] | ||
| } |
118 changes: 118 additions & 0 deletions
118
35th-Sopt-Seminar/Presentation/SwiftUIRefactoring/PopularCharView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)" | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.