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 35-Seminar/35-Seminar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
D66B11792CC7F6330029E065 /* Date+.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66B11782CC7F6330029E065 /* Date+.swift */; };
D66B117B2CC7F9400029E065 /* ToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66B117A2CC7F9400029E065 /* ToastView.swift */; };
D66B117F2CC824820029E065 /* AppDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66B117E2CC824820029E065 /* AppDetailViewController.swift */; };
D6DD55792CFA024D00C81965 /* AppRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD55782CFA024D00C81965 /* AppRowView.swift */; };
D6DD557B2CFA027A00C81965 /* AppListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD557A2CFA027A00C81965 /* AppListView.swift */; };
D6EAD33E2CD60793001EFA45 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = D6EAD33D2CD60793001EFA45 /* Alamofire */; };
D6EAD3412CD608F5001EFA45 /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6EAD3402CD608F5001EFA45 /* Environment.swift */; };
D6EAD3432CD60905001EFA45 /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6EAD3422CD60905001EFA45 /* NetworkError.swift */; };
Expand Down Expand Up @@ -130,6 +132,8 @@
D66B11782CC7F6330029E065 /* Date+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+.swift"; sourceTree = "<group>"; };
D66B117A2CC7F9400029E065 /* ToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastView.swift; sourceTree = "<group>"; };
D66B117E2CC824820029E065 /* AppDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDetailViewController.swift; sourceTree = "<group>"; };
D6DD55782CFA024D00C81965 /* AppRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppRowView.swift; sourceTree = "<group>"; };
D6DD557A2CFA027A00C81965 /* AppListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListView.swift; sourceTree = "<group>"; };
D6EAD33F2CD60855001EFA45 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
D6EAD3402CD608F5001EFA45 /* Environment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = "<group>"; };
D6EAD3422CD60905001EFA45 /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -248,6 +252,7 @@
D62C4E3E2CC4262300394B45 /* Presentation */ = {
isa = PBXGroup;
children = (
D6DD55752CFA017500C81965 /* week6 */,
D62C4E352CC4262300394B45 /* Extensions */,
D6EAD43A2CDD7091001EFA45 /* week4 */,
D6EAD34A2CD60DB6001EFA45 /* week23 */,
Expand Down Expand Up @@ -448,6 +453,15 @@
path = Entity;
sourceTree = "<group>";
};
D6DD55752CFA017500C81965 /* week6 */ = {
isa = PBXGroup;
children = (
D6DD55782CFA024D00C81965 /* AppRowView.swift */,
D6DD557A2CFA027A00C81965 /* AppListView.swift */,
);
path = week6;
sourceTree = "<group>";
};
D6EAD3482CD60A88001EFA45 /* Data */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -760,7 +774,9 @@
D6EAD3452CD6092C001EFA45 /* RegisterRequest.swift in Sources */,
D62C4E4F2CC4262300394B45 /* SceneDelegate.swift in Sources */,
D66B11792CC7F6330029E065 /* Date+.swift in Sources */,
D6DD55792CFA024D00C81965 /* AppRowView.swift in Sources */,
D6EAD4312CDD55E4001EFA45 /* TokenManager.swift in Sources */,
D6DD557B2CFA027A00C81965 /* AppListView.swift in Sources */,
D6642F502CD3E6EE008218DA /* Banner.swift in Sources */,
D6EAD3472CD60949001EFA45 /* UserService.swift in Sources */,
D66B11612CC576250029E065 /* AppPreviewView.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

final class MainTabBarController: UITabBarController {

Expand Down Expand Up @@ -45,14 +46,15 @@ final class MainTabBarController: UITabBarController {
selectedImage: "arcade.stick.console"
)

let searchVC = configureNavigationController(
with: configureDetailVC(title: "검색"),
title: "검색",
image: "magnifyingglass",
selectedImage: "magnifyingglass"
let appListView = AppListView()
let hostingController = UIHostingController(rootView: appListView)
hostingController.tabBarItem = UITabBarItem(
title: "앱",
image: UIImage(systemName: "square.grid.2x2"),
selectedImage: UIImage(systemName: "square.grid.2x2.fill")
)

self.viewControllers = [todayVC, gameVC, appVC, arcadeVC, searchVC]
self.viewControllers = [todayVC, gameVC, appVC, arcadeVC, hostingController]

self.tabBar.tintColor = .systemBlue
self.tabBar.backgroundColor = .systemBackground
Expand Down
29 changes: 29 additions & 0 deletions 35-Seminar/35-Seminar/Presentation/week6/AppListView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// AppListView.swift
// 35-Seminar
//
// Created by 조호근 on 11/29/24.
//

import SwiftUI

struct AppListView: View {

let essentialApps: [AppItem] = AppItem.sampleEssentialDatas

var body: some View {
List {
Section(header: Text("필수 앱").font(.headline)) {
ForEach(essentialApps, id: \.id) { app in
AppRowView(app: app)
}
}
}
.listStyle(GroupedListStyle())
}

}

#Preview {
AppListView()
}
71 changes: 71 additions & 0 deletions 35-Seminar/35-Seminar/Presentation/week6/AppRowView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// AppRowView.swift
// 35-Seminar
//
// Created by 조호근 on 11/29/24.
//

import SwiftUI

struct AppRowView: View {
let app: AppItem

var body: some View {
HStack {
Image(app.appImage)
.resizable()
.frame(width: 60, height: 60)
.cornerRadius(12)

VStack(alignment: .leading) {
Text(app.title)
.font(.system(size: 16, weight: .medium))
Text(app.subtitle)
.font(.system(size: 14))
.foregroundColor(.gray)
}

Spacer()

DownloadButtonView(downloadState: app.downloadState)
}
.padding(.vertical, 4)
}
}

struct DownloadButtonView: View {
let downloadState: DownloadState

var body: some View {
Group {
switch downloadState {
case .download:
Text("받기")
.foregroundColor(.blue)
case .update:
Text("업데이트")
.foregroundColor(.blue)
case .installed:
Text("설치됨")
.foregroundColor(.gray)
case .paid(let price):
Text("₩\(price)")
.foregroundColor(.blue)
}
}
Comment on lines +39 to +55
Copy link
Member

Choose a reason for hiding this comment

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

  • Group을 사용한 이유는 무엇인가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

각 텍스트에 동일한 속성을 설정하고 싶었는데, 처음에 VStack으로 묶어서 한번에 공통적인 속성을 설정할려다가 비록 컴포넌트 하나뿐이지만 레이아웃에 영향이 미친다고 판단해서,

Group으로 레이아웃에 영향없이 단순히 뷰를 묶고, 공통 스타일 설정할 수 있는 것이 지금 상황에 적합하다고 생각해서 사용하게 되었습니다.

.frame(width: 70, height: 30)
.background(Color(.systemGray6))
.cornerRadius(15)
}
}

#Preview {
AppRowView(app: AppItem(
id: "com.sample.app",
rank: 1,
title: "샘플 앱",
subtitle: "미리보기용 샘플 앱입니다",
appImage: "blind",
downloadState: .download
))
}