Skip to content
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

설정 화면 - 공지 화면 구현 #88

Merged
merged 2 commits into from
Mar 7, 2024
Merged
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
12 changes: 12 additions & 0 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BA05640B2B6248EA003D6DC7 /* HomeAPISupport in Frameworks */ = {isa = PBXBuildFile; productRef = BA05640A2B6248EA003D6DC7 /* HomeAPISupport */; };
BA05640D2B6248EA003D6DC7 /* Network in Frameworks */ = {isa = PBXBuildFile; productRef = BA05640C2B6248EA003D6DC7 /* Network */; };
BA0623D82B68E51400A0A3B2 /* Log in Frameworks */ = {isa = PBXBuildFile; productRef = BA0623D72B68E51400A0A3B2 /* Log */; };
BA1688E02B99B85500A8F462 /* NoticeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1688DF2B99B85500A8F462 /* NoticeView.swift */; };
BA28F17C2B6155450052855E /* PyeonHaeng_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28F17B2B6155450052855E /* PyeonHaeng_iOSTests.swift */; };
BA28F1852B6155810052855E /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28F1842B6155810052855E /* OnboardingView.swift */; };
BA28F1882B6155910052855E /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28F1872B6155910052855E /* HomeView.swift */; };
Expand Down Expand Up @@ -80,6 +81,7 @@
BA0564022B62179A003D6DC7 /* Core */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Core; sourceTree = "<group>"; };
BA0564032B6219D4003D6DC7 /* APIService */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = APIService; sourceTree = "<group>"; };
BA0564052B624646003D6DC7 /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Shared.xcconfig; path = XCConfig/Shared.xcconfig; sourceTree = SOURCE_ROOT; };
BA1688DF2B99B85500A8F462 /* NoticeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeView.swift; sourceTree = "<group>"; };
BA28F1792B6155450052855E /* PyeonHaeng-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "PyeonHaeng-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
BA28F17B2B6155450052855E /* PyeonHaeng_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PyeonHaeng_iOSTests.swift; sourceTree = "<group>"; };
BA28F1842B6155810052855E /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -171,6 +173,14 @@
name = Frameworks;
sourceTree = "<group>";
};
BA1688EB2B99D0B700A8F462 /* Notice */ = {
isa = PBXGroup;
children = (
BA1688DF2B99B85500A8F462 /* NoticeView.swift */,
);
path = Notice;
sourceTree = "<group>";
};
BA28F1702B6152E90052855E /* Resources */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -260,6 +270,7 @@
BA28F18C2B6155EC0052855E /* SettingsScene */ = {
isa = PBXGroup;
children = (
BA1688EB2B99D0B700A8F462 /* Notice */,
BA28F18D2B6156420052855E /* SettingsView.swift */,
);
path = SettingsScene;
Expand Down Expand Up @@ -578,6 +589,7 @@
9CE4B4712B6F0B57002DC446 /* OnboardingPage.swift in Sources */,
E52F371B2B947DC8000EBAD5 /* SearchViewModel.swift in Sources */,
BAE159DE2B663A9A002DCF94 /* HomeProductSorterView.swift in Sources */,
BA1688E02B99B85500A8F462 /* NoticeView.swift in Sources */,
BAE159D82B65FA6F002DCF94 /* HomeProductDetailSelectionView.swift in Sources */,
E50176262B6A204F0098D1BE /* ProductInfoLineGraphView.swift in Sources */,
BAB5CF252B6B7C5A008B24BF /* AppRootComponent.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// NoticeView.swift
// PyeonHaeng-iOS
//
// Created by 홍승현 on 3/7/24.
//

import DesignSystem
import SwiftUI

struct NoticeView: View {
var body: some View {
NavigationStack {
List(0 ..< 10) { _ in
VStack(alignment: .leading, spacing: 2) {
Text(verbatim: "2023.10.18")
.foregroundStyle(.gray200)
.font(.c4)
Text(verbatim: "프로토 타입 완성, 전기 자동차로 해양을 가로지르는 세계 최장 다리 건설 예정")
.lineLimit(1)
.foregroundStyle(.gray900)
.font(.body2)
}
.padding(.top, 8)
.padding(.bottom, 12)
}
.navigationTitle("Announcements")
.navigationBarTitleDisplayMode(.inline)
.listStyle(.plain)
.padding(.vertical, 8)
}
}
}

#Preview {
NoticeView()
}
112 changes: 68 additions & 44 deletions PyeonHaeng-iOS/Sources/Scenes/SettingsScene/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ private enum SettingsItem: LocalizedStringKey, CaseIterable {
case leaveReview = "Leave a Review"
case versionInfo = "Version Info"
case credits = "Credits"

var iconName: Image {
switch self {
case .notifications:
.bell
case .announcements:
.speaker
case .contacts:
.notePencil
case .leaveReview:
.appstore
case .versionInfo:
.infoCircle
case .credits:
.faceWinking
}
}
}

// MARK: - SettingsView
Expand All @@ -42,33 +25,7 @@ struct SettingsView: View {
var body: some View {
List {
ForEach(SettingsItem.allCases, id: \.self) { item in
switch item {
case .notifications:
// TODO: 알림 설정 추가해야 합니다.
Toggle(isOn: .constant(false)) {
HStack {
item.iconName
Text(item.rawValue)
}
}

case .versionInfo:
HStack {
item.iconName
Text(item.rawValue)
Spacer()
Text(verbatim: .version ?? "-")
.font(.c2)
}

default:
HStack {
NavigationLink {} label: {
item.iconName
Text(item.rawValue)
}
}
}
SettingsRow(item: item)
}
.frame(height: Metrics.itemHeight)
.padding(.vertical, Metrics.itemVerticalPadding)
Expand All @@ -87,6 +44,73 @@ private extension String {
}
}

// MARK: - SettingsRow

private struct SettingsRow: View {
private let item: SettingsItem

init(item: SettingsItem) {
self.item = item
}

var body: some View {
switch item {
case .notifications:
// TODO: 알림 설정 추가해야 합니다.
Toggle(isOn: .constant(false)) {
subject
}

case .versionInfo:
HStack {
subject
Spacer()
Text(verbatim: .version ?? "-")
.font(.c2)
}

case .announcements:
NavigationLink {
NoticeView()
.toolbarRole(.editor)
} label: {
subject
}

default:
NavigationLink {} label: {
subject
}
}
}

private var subject: some View {
HStack {
image(from: item)
.renderingMode(.template)
.foregroundStyle(.gray900)
Text(item.rawValue)
}
}

private func image(from item: SettingsItem) -> Image {
switch item {
case .notifications:
.bell
case .announcements:
.speaker
case .contacts:
.notePencil
case .leaveReview:
.appstore
case .versionInfo:
.infoCircle
case .credits:
.faceWinking
}
}
}

// MARK: - SettingsView.Metrics

private extension SettingsView {
Expand Down