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

디자인시스템 모듈화 및 font 메서드 수정 #8

Merged
merged 7 commits into from
Jan 27, 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
2 changes: 1 addition & 1 deletion .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Code Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Swiftformat
run: brew install swiftformat
- name: Run Swiftformat
Expand Down
45 changes: 9 additions & 36 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
BA0563FB2B61EAD5003D6DC7 /* .gitkeep in Resources */ = {isa = PBXBuildFile; fileRef = BA0563FA2B61EAD5003D6DC7 /* .gitkeep */; };
BA0564062B624646003D6DC7 /* Shared.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = BA0564052B624646003D6DC7 /* Shared.xcconfig */; };
BA0564092B6248EA003D6DC7 /* HomeAPI in Frameworks */ = {isa = PBXBuildFile; productRef = BA0564082B6248EA003D6DC7 /* HomeAPI */; };
BA05640B2B6248EA003D6DC7 /* HomeAPISupport in Frameworks */ = {isa = PBXBuildFile; productRef = BA05640A2B6248EA003D6DC7 /* HomeAPISupport */; };
Expand All @@ -28,12 +27,11 @@
BA28F1A42B61572A0052855E /* Pretendard-ExtraBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = BA28F19A2B61572A0052855E /* Pretendard-ExtraBold.otf */; };
BA28F1A52B61572A0052855E /* Pretendard-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = BA28F19B2B61572A0052855E /* Pretendard-Light.otf */; };
BA28F1A62B61572A0052855E /* Pretendard-Black.otf in Resources */ = {isa = PBXBuildFile; fileRef = BA28F19C2B61572A0052855E /* Pretendard-Black.otf */; };
BA28F1AD2B616E600052855E /* FontStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28F1AC2B616E600052855E /* FontStyles.swift */; };
BA28F1AF2B6173B60052855E /* Text+textStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28F1AE2B6173B60052855E /* Text+textStyle.swift */; };
BAA4D9AD2B5A1795005999F8 /* PyeonHaengApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA4D9AC2B5A1795005999F8 /* PyeonHaengApp.swift */; };
BAA4D9AF2B5A1795005999F8 /* SplashView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAA4D9AE2B5A1795005999F8 /* SplashView.swift */; };
BAA4D9B12B5A1796005999F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BAA4D9B02B5A1796005999F8 /* Assets.xcassets */; };
BAA4D9B42B5A1796005999F8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BAA4D9B32B5A1796005999F8 /* Preview Assets.xcassets */; };
BAB569612B639F3000D1E0F9 /* DesignSystem in Frameworks */ = {isa = PBXBuildFile; productRef = BAB569602B639F3000D1E0F9 /* DesignSystem */; };
BAF2BEB32B61236100931AF0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = BAF2BEB22B61236100931AF0 /* Localizable.xcstrings */; };
/* End PBXBuildFile section */

Expand All @@ -48,7 +46,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
BA0563FA2B61EAD5003D6DC7 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = "<group>"; };
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; };
Expand All @@ -70,13 +67,12 @@
BA28F19B2B61572A0052855E /* Pretendard-Light.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Light.otf"; sourceTree = "<group>"; };
BA28F19C2B61572A0052855E /* Pretendard-Black.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Black.otf"; sourceTree = "<group>"; };
BA28F1A72B6157E90052855E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA28F1AC2B616E600052855E /* FontStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontStyles.swift; sourceTree = "<group>"; };
BA28F1AE2B6173B60052855E /* Text+textStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Text+textStyle.swift"; sourceTree = "<group>"; };
BAA4D9A92B5A1795005999F8 /* PyeonHaeng-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PyeonHaeng-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
BAA4D9AC2B5A1795005999F8 /* PyeonHaengApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PyeonHaengApp.swift; sourceTree = "<group>"; };
BAA4D9AE2B5A1795005999F8 /* SplashView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashView.swift; sourceTree = "<group>"; };
BAA4D9B02B5A1796005999F8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BAA4D9B32B5A1796005999F8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
BABFEA6F2B6399C30084C0EC /* Shared */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Shared; sourceTree = "<group>"; };
BAF2BEB22B61236100931AF0 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -95,20 +91,13 @@
BA05640D2B6248EA003D6DC7 /* Network in Frameworks */,
BA05640B2B6248EA003D6DC7 /* HomeAPISupport in Frameworks */,
BA0564092B6248EA003D6DC7 /* HomeAPI in Frameworks */,
BAB569612B639F3000D1E0F9 /* DesignSystem in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
BA0563F92B61EABA003D6DC7 /* Components */ = {
isa = PBXGroup;
children = (
BA0563FA2B61EAD5003D6DC7 /* .gitkeep */,
);
path = Components;
sourceTree = "<group>";
};
BA0564042B624629003D6DC7 /* XCConfig */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -231,27 +220,10 @@
path = Fonts;
sourceTree = "<group>";
};
BA28F1AA2B616E2D0052855E /* DesignSystem */ = {
isa = PBXGroup;
children = (
BA0563F92B61EABA003D6DC7 /* Components */,
BA28F1AB2B616E540052855E /* Fonts */,
BA28F1AE2B6173B60052855E /* Text+textStyle.swift */,
);
path = DesignSystem;
sourceTree = "<group>";
};
BA28F1AB2B616E540052855E /* Fonts */ = {
isa = PBXGroup;
children = (
BA28F1AC2B616E600052855E /* FontStyles.swift */,
);
path = Fonts;
sourceTree = "<group>";
};
BAA4D9A02B5A1795005999F8 = {
isa = PBXGroup;
children = (
BABFEA6F2B6399C30084C0EC /* Shared */,
BA0564032B6219D4003D6DC7 /* APIService */,
BA0564022B62179A003D6DC7 /* Core */,
BAA4D9AA2B5A1795005999F8 /* Products */,
Expand All @@ -274,7 +246,6 @@
BAA4D9AB2B5A1795005999F8 /* PyeonHaeng-iOS */ = {
isa = PBXGroup;
children = (
BA28F1AA2B616E2D0052855E /* DesignSystem */,
BAA4D9B22B5A1796005999F8 /* Preview Content */,
BA28F1702B6152E90052855E /* Resources */,
BA28F1712B6152EE0052855E /* Sources */,
Expand Down Expand Up @@ -330,6 +301,7 @@
BA0564082B6248EA003D6DC7 /* HomeAPI */,
BA05640A2B6248EA003D6DC7 /* HomeAPISupport */,
BA05640C2B6248EA003D6DC7 /* Network */,
BAB569602B639F3000D1E0F9 /* DesignSystem */,
);
productName = "PyeonHaeng-iOS";
productReference = BAA4D9A92B5A1795005999F8 /* PyeonHaeng-iOS.app */;
Expand Down Expand Up @@ -401,7 +373,6 @@
BA0564062B624646003D6DC7 /* Shared.xcconfig in Resources */,
BAF2BEB32B61236100931AF0 /* Localizable.xcstrings in Resources */,
BA28F1A22B61572A0052855E /* Pretendard-Medium.otf in Resources */,
BA0563FB2B61EAD5003D6DC7 /* .gitkeep in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -464,11 +435,9 @@
BA28F1852B6155810052855E /* OnboardingView.swift in Sources */,
BA28F1882B6155910052855E /* HomeView.swift in Sources */,
BA28F18B2B6155BD0052855E /* ProductInfoView.swift in Sources */,
BA28F1AF2B6173B60052855E /* Text+textStyle.swift in Sources */,
BA28F1912B61566E0052855E /* ProductSearchView.swift in Sources */,
BA28F18E2B6156420052855E /* SettingsView.swift in Sources */,
BAA4D9AF2B5A1795005999F8 /* SplashView.swift in Sources */,
BA28F1AD2B616E600052855E /* FontStyles.swift in Sources */,
BAA4D9AD2B5A1795005999F8 /* PyeonHaengApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -754,6 +723,10 @@
isa = XCSwiftPackageProductDependency;
productName = Network;
};
BAB569602B639F3000D1E0F9 /* DesignSystem */ = {
isa = XCSwiftPackageProductDependency;
productName = DesignSystem;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BAA4D9A12B5A1795005999F8 /* Project object */;
Expand Down
1 change: 0 additions & 1 deletion PyeonHaeng-iOS/DesignSystem/Components/.gitkeep

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x20",
"green" : "0x20",
"red" : "0x20"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xDE",
"green" : "0xDE",
"red" : "0xDE"
}
},
"idiom" : "universal"
}
],
Expand Down
13 changes: 0 additions & 13 deletions PyeonHaeng-iOS/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,5 @@
<dict>
<key>BaseURL</key>
<string>$(BASE_URL)</string>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Thin.otf</string>
<string>Pretendard-SemiBold.otf</string>
<string>Pretendard-Regular.otf</string>
<string>Pretendard-Medium.otf</string>
<string>Pretendard-Light.otf</string>
<string>Pretendard-ExtraLight.otf</string>
<string>Pretendard-ExtraBold.otf</string>
<string>Pretendard-Bold.otf</string>
<string>Pretendard-Black.otf</string>
<string>EF_jejudoldam.otf</string>
</array>
</dict>
</plist>
5 changes: 5 additions & 0 deletions PyeonHaeng-iOS/Sources/PyeonHaengApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
// Created by 홍승현 on 1/19/24.
//

import DesignSystem
import SwiftUI

@main
struct PyeonHaengApp: App {
init() {
Fonts.registerFonts() // 앱을 실행하기 전에 폰트를 로드합니다.
}

var body: some Scene {
WindowGroup {
SplashView()
Expand Down
8 changes: 8 additions & 0 deletions Shared/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
21 changes: 21 additions & 0 deletions Shared/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Shared",
platforms: [.iOS(.v17)],
products: [
.library(
name: "DesignSystem",
targets: ["DesignSystem"]
),
],
targets: [
.target(
name: "DesignSystem",
resources: [.process("Resources")]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
44 changes: 44 additions & 0 deletions Shared/Sources/DesignSystem/Sources/Fonts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Fonts.swift
//
//
// Created by 홍승현 on 1/26/24.
//

import CoreText
import Foundation

// MARK: - Fonts

/// `Fonts` 열거형은 커스텀 폰트를 등록하는 데 사용됩니다.
public enum Fonts {
/// 이 메서드는 `Pretendard`와 `DolDam` 폰트를 등록합니다.
/// 각각의 폰트 이름을 순회하면서 `registerFont` 메서드를 호출하여 폰트를 등록합니다.
public static func registerFonts() {
// Pretendard 폰트 등록
for fontName in Pretendard.allCases.map(\.rawValue) {
registerFont(bundle: .module, fontName: fontName, fontExtension: "otf")
}

// DolDam 폰트 등록
for fontName in DolDam.allCases.map(\.rawValue) {
registerFont(bundle: .module, fontName: fontName, fontExtension: "otf")
}
}

/// 주어진 폰트 이름과 확장자를 사용하여 폰트를 동적으로 등록합니다.
/// - Parameters:
/// - bundle: 폰트 파일을 포함하고 있는 번들.
/// - fontName: 등록할 폰트의 이름.
/// - fontExtension: 폰트 파일의 확장자.
private static func registerFont(bundle: Bundle, fontName: String, fontExtension: String) {
guard let fontURL = bundle.url(forResource: fontName, withExtension: fontExtension),
let fontDataDriver = CGDataProvider(url: fontURL as CFURL),
let font = CGFont(fontDataDriver)
else {
return // 폰트 로딩에 실패할 경우 함수를 종료합니다.
}
// CoreText를 사용하여 폰트를 시스템에 등록합니다.
CTFontManagerRegisterGraphicsFont(font, nil)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//
// FontStyles.swift
// PyeonHaeng-iOS
// PyeonHaengFont.swift
//
// Created by 홍승현 on 1/25/24.
//

enum FontStyles {
public enum PyeonHaengFont {
/// Heading 1
case h1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// Text+textStyle.swift
// PyeonHaeng-iOS
// Text+pyeonhaengStyle.swift
//
// Created by 홍승현 on 1/25/24.
//
Expand All @@ -9,7 +8,7 @@ import SwiftUI

// MARK: - Pretendard

enum Pretendard: String {
enum Pretendard: String, CaseIterable {
/// black
case black = "Pretendard-Black"

Expand All @@ -34,12 +33,12 @@ enum Pretendard: String {

// MARK: - DolDam

private enum DolDam: String {
enum DolDam: String, CaseIterable {
case `default` = "EF_jejudoldam"
}

extension Text {
func textStyle(_ style: FontStyles) -> some View {
public extension Text {
func font(_ style: PyeonHaengFont) -> Text {
switch style {
case .h1:
font(.custom(Pretendard.bold.rawValue, size: 32))
Expand Down