diff --git a/Projects/App/Sources/ContentView.swift b/Projects/App/Sources/ContentView.swift index 33d4ea3..d45a981 100644 --- a/Projects/App/Sources/ContentView.swift +++ b/Projects/App/Sources/ContentView.swift @@ -2,30 +2,23 @@ import SwiftUI import CoreKit import NetworkKit import ComponentsKit -import DesignSystemKit +import DesignCore import Main public struct ContentView: View { public init() {} public var body: some View { - VStack { + VStack(spacing: 20) { Text("Hello, World!") .padding() + .pretendard(weight: ._300, size: 20) + .robotoSlab(size: 12) MainView() SampleComponent() - .foregroundStyle(Color.tempColor) - } - .onAppear { - Task { - do { - try await AuthEndpoint.requestSMSVerification(phone: "010-4602-2274") - } catch { - print(error) - } - } + .foregroundStyle(DesignCore.red300) } } } diff --git a/Projects/App/Sources/DesignPreviewView.swift b/Projects/App/Sources/DesignPreviewView.swift new file mode 100644 index 0000000..e45ddbd --- /dev/null +++ b/Projects/App/Sources/DesignPreviewView.swift @@ -0,0 +1,115 @@ +// +// DesignPreviewView.swift +// App +// +// Created by 김지수 on 9/14/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI +import DesignCore + +struct DesignPreviewView: View { + + let blackColors = [ + DesignCore.black, + DesignCore.grey500, + DesignCore.grey400, + DesignCore.grey300, + DesignCore.grey200, + DesignCore.grey100 + ] + + let tintColors = [ + DesignCore.red300, + DesignCore.blue300 + ] + + let pastelColors = [ + DesignCore.darkGreen, + DesignCore.darkPink, + DesignCore.darkBlue, + DesignCore.lightYellow, + DesignCore.lightGreen, + DesignCore.lightPink, + DesignCore.lightBlue, + ] + + var colorGroups: [[Color]] { + return [ + blackColors, + tintColors, + pastelColors + ] + } + + var body: some View { + NavigationStack { + ScrollView { + VStack(spacing: 24) { + VStack(spacing: 12) { + ForEach(colorGroups, id: \.self) { group in + HStack { + ForEach(group, id: \.self) { + RoundedRectangle(cornerRadius: 4) + .frame(width: 24, height: 24) + .foregroundStyle($0) + } + } + } + + RoundedRectangle(cornerRadius: 5) + .frame(height: 36) + .padding(.horizontal, 36) + .foregroundStyle(LinearGradient.gradientA) + } + Divider() + + Text("HOME / en-medium-20") + .typography(.en_medium_20) + .foregroundStyle(DesignCore.black) + Text("Introduction / en-medium-16") + .typography(.en_medium_16) + .foregroundStyle(DesignCore.grey400) + Text("새 메시지 3개 / semibold-14") + .typography(.semibold_14) + .foregroundStyle(DesignCore.grey500) + Text("안녕하세요? 이것은 샘플 화면입니다...\nUI를 잡아보는 중인데 글자 수가 얼마... / regular-15") + .typography(.regular_15) + .foregroundStyle(Color(hex: 0x474638)) + Text("28분 전 / regular-12") + .typography(.regular_12) + .foregroundStyle(Color(hex: 0x534C44, opacity: 0.5)) + Text("이지혜 / semibold-28") + .typography(.semibold_28) + .foregroundStyle(DesignCore.black) + Text("1998년생 / medium-14") + .typography(.medium_14) + .foregroundStyle(DesignCore.grey200) + Text("직업 / medium-14") + .typography(.medium_14) + .foregroundStyle(DesignCore.darkGreen) + Text("초등학교 교사 / medium-16") + .typography(.medium_16) + .foregroundStyle(DesignCore.darkGreen) + Text("취미 / semibold-24") + .typography(.semibold_24) + .foregroundStyle(Color(hex: 0x15394B)) + Text("연락한 지 2일차 / medium-18") + .typography(.medium_18) + .foregroundStyle(Color(hex: 0x534C44)) + Text("3일차까지 10시간 24분 43초 남았어요 / regular-14") + .typography(.regular_14) + .foregroundStyle(Color(hex: 0x534C44)) + } + .padding(.vertical, 20) + } + .navigationTitle("three-days DesignSystem") + .toolbarTitleDisplayMode(.inline) + } + } +} + +#Preview { + DesignPreviewView() +} diff --git a/Projects/App/Sources/Weave2IOSApp.swift b/Projects/App/Sources/Weave2IOSApp.swift index 87e3a3d..3426b04 100644 --- a/Projects/App/Sources/Weave2IOSApp.swift +++ b/Projects/App/Sources/Weave2IOSApp.swift @@ -4,7 +4,7 @@ import SwiftUI struct Weave2IOSApp: App { var body: some Scene { WindowGroup { - ContentView() + DesignPreviewView() } } } diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json new file mode 100644 index 0000000..1a2c47a --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "238", + "green" : "241", + "red" : "245" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json new file mode 100644 index 0000000..1065377 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "31", + "green" : "31", + "red" : "31" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json new file mode 100644 index 0000000..e6b32a4 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "255", + "green" : "140", + "red" : "64" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json new file mode 100644 index 0000000..6088172 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "143", + "green" : "109", + "red" : "96" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json new file mode 100644 index 0000000..b3d3146 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "84", + "green" : "102", + "red" : "91" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json new file mode 100644 index 0000000..743f8d4 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "112", + "green" : "100", + "red" : "132" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json new file mode 100644 index 0000000..f2bdf5c --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "172", + "green" : "139", + "red" : "255" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json new file mode 100644 index 0000000..327be8d --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "255", + "green" : "193", + "red" : "152" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json new file mode 100644 index 0000000..3846726 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "197", + "green" : "199", + "red" : "202" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json new file mode 100644 index 0000000..ae747c6 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "160", + "green" : "160", + "red" : "160" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json new file mode 100644 index 0000000..662dd4f --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "132", + "green" : "132", + "red" : "132" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json new file mode 100644 index 0000000..de6d36e --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "94", + "green" : "94", + "red" : "94" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json new file mode 100644 index 0000000..3b47458 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "69", + "green" : "69", + "red" : "69" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json new file mode 100644 index 0000000..cf80284 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "246", + "green" : "241", + "red" : "235" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json new file mode 100644 index 0000000..4a0f0c0 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "235", + "green" : "246", + "red" : "240" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json new file mode 100644 index 0000000..4bdf8fd --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "239", + "green" : "235", + "red" : "246" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json new file mode 100644 index 0000000..c0340c6 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "237", + "green" : "253", + "red" : "254" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json new file mode 100644 index 0000000..83f4db6 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "127", + "green" : "89", + "red" : "242" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Black.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Black.otf new file mode 100644 index 0000000..a0d849e Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Black.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Bold.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Bold.otf new file mode 100644 index 0000000..8e5e30a Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Bold.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraBold.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraBold.otf new file mode 100644 index 0000000..388f3ca Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraBold.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraLight.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraLight.otf new file mode 100644 index 0000000..40c8b69 Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-ExtraLight.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Light.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Light.otf new file mode 100644 index 0000000..228679e Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Light.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Medium.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Medium.otf new file mode 100644 index 0000000..0575069 Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Medium.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Regular.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Regular.otf new file mode 100644 index 0000000..08bf4cf Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Regular.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-SemiBold.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-SemiBold.otf new file mode 100644 index 0000000..e7e36ab Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-SemiBold.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Thin.otf b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Thin.otf new file mode 100644 index 0000000..77e792d Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/Pretendard-Thin.otf differ diff --git a/Projects/DesignSystem/DesignCore/Resources/Fonts/RobotoSlab-Medium.ttf b/Projects/DesignSystem/DesignCore/Resources/Fonts/RobotoSlab-Medium.ttf new file mode 100755 index 0000000..4437720 Binary files /dev/null and b/Projects/DesignSystem/DesignCore/Resources/Fonts/RobotoSlab-Medium.ttf differ diff --git a/Projects/DesignSystem/DesignCore/Sources/Color+Ext.swift b/Projects/DesignSystem/DesignCore/Sources/Color+Ext.swift new file mode 100644 index 0000000..45f0459 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/Color+Ext.swift @@ -0,0 +1,19 @@ +// +// Color+Ext.swift +// DesignCore +// +// Created by 김지수 on 9/14/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI + +extension Color { + public init(hex: Int, opacity: Double = 1.0) { + let red = Double((hex >> 16) & 0xff) / 255 + let green = Double((hex >> 8) & 0xff) / 255 + let blue = Double((hex >> 0) & 0xff) / 255 + + self.init(.sRGB, red: red, green: green, blue: blue, opacity: opacity) + } +} diff --git a/Projects/DesignSystem/DesignCore/Sources/Font+Ext.swift b/Projects/DesignSystem/DesignCore/Sources/Font+Ext.swift new file mode 100644 index 0000000..56e0bb8 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/Font+Ext.swift @@ -0,0 +1,31 @@ +// +// Font+Ext.swift +// DesignSystemKit +// +// Created by 김지수 on 9/13/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI +import UIKit + +public extension Font { + init(uiFont: UIFont) { + self = Font(uiFont as CTFont) + } +} + +extension DesignCoreFontConvertible { + public func uiFont(size: CGFloat) -> UIFont { + guard let uiFont = UIFont(font: self, size: size) else { + fatalError("Unable to initialize font name: '\(name)', family: \(family)") + } + return uiFont + } + public func font(size: CGFloat) -> Font { + guard let font = UIFont(font: self, size: size) else { + fatalError("Unable to initialize font name: '\(name)', family: \(family)") + } + return Font(uiFont: font) + } +} diff --git a/Projects/DesignSystem/DesignCore/Sources/LinearGradient+Ext.swift b/Projects/DesignSystem/DesignCore/Sources/LinearGradient+Ext.swift new file mode 100644 index 0000000..f22fdf3 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/LinearGradient+Ext.swift @@ -0,0 +1,17 @@ +// +// LinearGradient+Ext.swift +// ComponentsKit +// +// Created by 김지수 on 9/13/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI + +extension LinearGradient { + public static let gradientA = LinearGradient( + colors: [DesignCore.gradientA0, DesignCore.gradientA1], + startPoint: .leading, + endPoint: .trailing + ) +} diff --git a/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift b/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift new file mode 100644 index 0000000..bcaf83b --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift @@ -0,0 +1,86 @@ +// +// Pretendard.swift +// DesignCore +// +// Created by 김지수 on 9/13/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI +import UIKit + +public enum PretendardWeight { + case _100 + case _200 + case _300 + case _400 + case _500 + case _600 + case _700 + case _800 + case _900 + + public var font: DesignCoreFontConvertible { + switch self { + case ._100: + return DesignCoreFontFamily.Pretendard.thin + case ._200: + return DesignCoreFontFamily.Pretendard.extraLight + case ._300: + return DesignCoreFontFamily.Pretendard.light + case ._400: + return DesignCoreFontFamily.Pretendard.regular + case ._500: + return DesignCoreFontFamily.Pretendard.medium + case ._600: + return DesignCoreFontFamily.Pretendard.semiBold + case ._700: + return DesignCoreFontFamily.Pretendard.bold + case ._800: + return DesignCoreFontFamily.Pretendard.extraBold + case ._900: + return DesignCoreFontFamily.Pretendard.black + } + } +} + +public extension UIFont { + static func pretendard(_ weight: PretendardWeight, size: CGFloat) -> UIFont { + return .init(font: weight.font, size: size)! + } +} + +internal struct PretendardModifier: ViewModifier { + let weight: PretendardWeight + let size: CGFloat + var lineHeight: CGFloat? = nil + + func body(content: Content) -> some View { + if let lineHeight { + let uifont = weight.font.uiFont(size: size) + content + .font(Font(uiFont: uifont)) + .lineSpacing(lineHeight - uifont.lineHeight) + .padding(.vertical, (lineHeight - uifont.lineHeight)) + } else { + content + .font(Font(uiFont: weight.font.uiFont(size: size))) + } + } +} + +public extension View { + func pretendard( + weight: PretendardWeight, + size: CGFloat, + lineHeight: CGFloat? = nil + ) -> some View { + return modifier( + PretendardModifier( + weight: weight, + size: size, + lineHeight: lineHeight + ) + ) + } +} diff --git a/Projects/DesignSystem/DesignCore/Sources/RobotoSlab.swift b/Projects/DesignSystem/DesignCore/Sources/RobotoSlab.swift new file mode 100644 index 0000000..3253572 --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/RobotoSlab.swift @@ -0,0 +1,54 @@ +// +// RobotoSlab.swift +// DesignCore +// +// Created by 김지수 on 9/14/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI +import UIKit + +public extension Font { + static func robotoSlab(size: CGFloat) -> Font { + return DesignCoreFontFamily.RobotoSlab.medium.font(size: size) + } +} + +public extension UIFont { + static func robotoSlab(size: CGFloat) -> UIFont { + return .init(font: DesignCoreFontFamily.RobotoSlab.medium, size: size)! + } +} + +private struct RobotoSlabModifier: ViewModifier { + let size: CGFloat + var lineHeight: CGFloat? = nil + + func body(content: Content) -> some View { + if let lineHeight { + let uifont = UIFont.robotoSlab(size: size) + content + .font(Font(uiFont: uifont)) + .lineSpacing(lineHeight - uifont.lineHeight) + .padding(.vertical, (lineHeight - uifont.lineHeight)) + } else { + content + .font(.robotoSlab(size: size)) + } + } +} + +public extension View { + func robotoSlab( + size: CGFloat, + lineHeight: CGFloat? = nil + ) -> some View { + return modifier( + RobotoSlabModifier( + size: size, + lineHeight: lineHeight + ) + ) + } +} diff --git a/Projects/DesignSystem/DesignCore/Sources/Typography.swift b/Projects/DesignSystem/DesignCore/Sources/Typography.swift new file mode 100644 index 0000000..27f662c --- /dev/null +++ b/Projects/DesignSystem/DesignCore/Sources/Typography.swift @@ -0,0 +1,106 @@ +// +// Typography.swift +// DesignCore +// +// Created by 김지수 on 9/14/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI + +public enum Typography: CaseIterable { + // EN - Medium + case en_medium_20 + case en_medium_16 + + // Pretendard - semibold + case semibold_28 + case semibold_24 + case semibold_20 + case semibold_14 + + // Pretendard - medium + case medium_18 + case medium_16 + case medium_14 + + // Pretendard - regular + case regular_15 + case regular_14 + case regular_12 +} + +extension Typography { + var fontSize: CGFloat { + switch self { + case .en_medium_20: return 20 + case .en_medium_16: return 16 + case .semibold_28: return 28 + case .semibold_24: return 24 + case .semibold_20: return 20 + case .semibold_14: return 14 + case .medium_18: return 18 + case .medium_16: return 16 + case .medium_14: return 14 + case .regular_15: return 15 + case .regular_14: return 14 + case .regular_12: return 12 + } + } + + var lineHeight: CGFloat { + switch self { + case .en_medium_20: return 20 + case .en_medium_16: return 16 + default: return fontSize * 1.5 + } + } +} + +extension Typography { + var pretendardWeight: PretendardWeight? { + switch self { + case .en_medium_20, .en_medium_16: + return nil + + case .semibold_28, .semibold_24, .semibold_20, .semibold_14: + return ._600 + + case .medium_18, .medium_16, .medium_14: + return ._500 + + case .regular_15, .regular_14, .regular_12: + return ._400 + } + } +} + +private struct TypographyViewModifier: ViewModifier { + let typography: Typography + + func body(content: Content) -> some View { + switch typography { + case .en_medium_16, .en_medium_20: + content + .robotoSlab( + size: typography.fontSize, + lineHeight: typography.lineHeight + ) + default: + content + .pretendard( + weight: typography.pretendardWeight!, + size: typography.fontSize, + lineHeight: typography.lineHeight + ) + } + } +} + +public extension View { + func typography(_ typograpy: Typography) -> some View { + return modifier( + TypographyViewModifier(typography: typograpy) + ) + } +} diff --git a/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift b/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift new file mode 100644 index 0000000..061c98c --- /dev/null +++ b/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift @@ -0,0 +1,46 @@ +// +// DesignCoreTest.swift +// DesignCore-UnitTest +// +// Created by 김지수 on 9/14/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import XCTest +@testable import DesignCore + +final class DesignCoreTest: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testFontImport() { + let pretendard = UIFont.pretendard(._600, size: 20) + XCTAssertEqual(pretendard.familyName, "Pretendard") + let robotoSlab = UIFont.robotoSlab(size: 20) + XCTAssertEqual(robotoSlab.familyName, "Roboto Slab") + } + + func testTypography() { + /// en-typo 는 pretendardWeight 를 가져선 안됨 + let enTypo = [Typography.en_medium_16, Typography.en_medium_20] + let enPretendardWeight = enTypo + .compactMap { $0.pretendardWeight } + XCTAssertEqual(enPretendardWeight, []) + + /// pretendard typo 는 pretendardWeight 를 항상 가지고 있어야 함 + let pretendardTypos = Typography.allCases + .filter { typo in + !enTypo.contains { $0 == typo } + } + .compactMap { $0.pretendardWeight } + + let pretendardCount = Typography.allCases.count - enTypo.count + XCTAssertEqual(pretendardTypos.count, pretendardCount) + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json new file mode 100644 index 0000000..1a2c47a --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Background.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "238", + "green" : "241", + "red" : "245" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json new file mode 100644 index 0000000..1065377 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Black.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "31", + "green" : "31", + "red" : "31" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json new file mode 100644 index 0000000..e6b32a4 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Blue300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "255", + "green" : "140", + "red" : "64" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json new file mode 100644 index 0000000..6088172 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkBlue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "143", + "green" : "109", + "red" : "96" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json new file mode 100644 index 0000000..b3d3146 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkGreen.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "84", + "green" : "102", + "red" : "91" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json new file mode 100644 index 0000000..743f8d4 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/DarkPink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "112", + "green" : "100", + "red" : "132" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json new file mode 100644 index 0000000..f2bdf5c --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA0.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "172", + "green" : "139", + "red" : "255" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json new file mode 100644 index 0000000..327be8d --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/GradientA1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "255", + "green" : "193", + "red" : "152" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json new file mode 100644 index 0000000..3846726 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey100.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "197", + "green" : "199", + "red" : "202" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json new file mode 100644 index 0000000..ae747c6 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey200.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "160", + "green" : "160", + "red" : "160" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json new file mode 100644 index 0000000..662dd4f --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "132", + "green" : "132", + "red" : "132" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json new file mode 100644 index 0000000..de6d36e --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey400.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "94", + "green" : "94", + "red" : "94" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json new file mode 100644 index 0000000..3b47458 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Grey500.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "69", + "green" : "69", + "red" : "69" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json new file mode 100644 index 0000000..cf80284 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightBlue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "246", + "green" : "241", + "red" : "235" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json new file mode 100644 index 0000000..4a0f0c0 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightGreen.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "235", + "green" : "246", + "red" : "240" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json new file mode 100644 index 0000000..4bdf8fd --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightPink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "239", + "green" : "235", + "red" : "246" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json new file mode 100644 index 0000000..c0340c6 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/LightYellow.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "237", + "green" : "253", + "red" : "254" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json new file mode 100644 index 0000000..83f4db6 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Resources/Colors/Colors.xcassets/Red300.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "127", + "green" : "89", + "red" : "242" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/DesignSystem/DesignSystemKit/Sources/LinearGradient+Ext.swift b/Projects/DesignSystem/DesignSystemKit/Sources/LinearGradient+Ext.swift new file mode 100644 index 0000000..b2290b8 --- /dev/null +++ b/Projects/DesignSystem/DesignSystemKit/Sources/LinearGradient+Ext.swift @@ -0,0 +1,17 @@ +// +// LinearGradient+Ext.swift +// ComponentsKit +// +// Created by 김지수 on 9/13/24. +// Copyright © 2024 com.studentcenter. All rights reserved. +// + +import SwiftUI + +extension LinearGradient { + public static let gradientA = LinearGradient( + colors: [DesignSystemKit.gradientA0, DesignSystemKit.gradientA1], + startPoint: .leading, + endPoint: .trailing + ) +} diff --git a/Projects/DesignSystem/DesignSystemKit/Sources/temp.swift b/Projects/DesignSystem/DesignSystemKit/Sources/temp.swift deleted file mode 100644 index aaa1e63..0000000 --- a/Projects/DesignSystem/DesignSystemKit/Sources/temp.swift +++ /dev/null @@ -1,14 +0,0 @@ -import SwiftUI - -public extension Color { - static var tempColor: Color { - return Color( - uiColor: .init( - red: 0.5, - green: 0.5, - blue: 0.5, - alpha: 1 - ) - ) - } -} diff --git a/Projects/DesignSystem/Project.swift b/Projects/DesignSystem/Project.swift index 9fb9e23..87efb20 100644 --- a/Projects/DesignSystem/Project.swift +++ b/Projects/DesignSystem/Project.swift @@ -5,15 +5,22 @@ let project: Project = .make( name: "DesignSystem", targets: [ .make( - target: .designSystemKit, + target: .DesignCore, + useResource: true, dependencies: [ .external(.nuke) ] ), + .makeUnitTest( + target: .DesignCore, + dependencies: [ + .target(name: .DesignCore) + ] + ), .make( target: .componentsKit, dependencies: [ - .target(name: .designSystemKit) + .target(name: .DesignCore) ] ) ] diff --git a/Projects/Features/Main/Sources/MainView.swift b/Projects/Features/Main/Sources/MainView.swift index cf60965..1b8ab7e 100644 --- a/Projects/Features/Main/Sources/MainView.swift +++ b/Projects/Features/Main/Sources/MainView.swift @@ -6,7 +6,7 @@ // import SwiftUI -import DesignSystemKit +import DesignCore public struct MainView: View { @@ -14,7 +14,8 @@ public struct MainView: View { public var body: some View { Text("This is Main View in Main Feature!") - .foregroundStyle(Color.tempColor) + .foregroundStyle(Color.red) + .background(LinearGradient.gradientA) } } diff --git a/Tuist/ProjectDescriptionHelpers/Target+extensions.swift b/Tuist/ProjectDescriptionHelpers/Target+extensions.swift index b3c1464..f9ecf01 100644 --- a/Tuist/ProjectDescriptionHelpers/Target+extensions.swift +++ b/Tuist/ProjectDescriptionHelpers/Target+extensions.swift @@ -71,6 +71,7 @@ extension Target { public static func make( target: TargetName, product: Product = .staticLibrary, + useResource: Bool = false, dependencies: [TargetDependency] = [] ) -> Target { return .make( @@ -78,6 +79,7 @@ extension Target { product: product, bundleId: "com.studentcenter.weave2-\(target.name)", sources: ["\(target.sources)"], + resources: useResource ? ["\(target.resources)"] : nil, dependencies: dependencies ) } diff --git a/Tuist/ProjectDescriptionHelpers/TargetConfiguration.swift b/Tuist/ProjectDescriptionHelpers/TargetConfiguration.swift index 7ddc9fa..b1edec2 100644 --- a/Tuist/ProjectDescriptionHelpers/TargetConfiguration.swift +++ b/Tuist/ProjectDescriptionHelpers/TargetConfiguration.swift @@ -13,7 +13,7 @@ public enum TargetName: String { case coreKit = "CoreKit" case model = "Model" case networkKit = "NetworkKit" - case designSystemKit = "DesignSystemKit" + case DesignCore = "DesignCore" case componentsKit = "ComponentsKit" case main = "Main" } @@ -25,7 +25,7 @@ public extension TargetName { return .app case .coreKit, .networkKit, .model: return .core - case .designSystemKit, .componentsKit: + case .DesignCore, .componentsKit: return .designSystem case .main: return .feature diff --git a/Tuist/ResourceSynthesizers/Assets.stencil b/Tuist/ResourceSynthesizers/Assets.stencil new file mode 100755 index 0000000..1c38b28 --- /dev/null +++ b/Tuist/ResourceSynthesizers/Assets.stencil @@ -0,0 +1,221 @@ +// swiftlint:disable all +// swift-format-ignore-file +// swiftformat:disable all +// Generated using tuist — https://github.com/tuist/tuist +{% if catalogs %} +{% set enumName %}{{param.name}}{% endset %} +{% set arResourceGroupType %}{{param.name}}ARResourceGroup{% endset %} +{% set colorType %}{{param.name}}Colors{% endset %} +{% set dataType %}{{param.name}}Data{% endset %} +{% set imageType %}{{param.name}}Images{% endset %} +{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %} +{% set bundleToken %}{{param.name}}Resources{% endset %} +{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} + +{% if resourceCount.arresourcegroup > 0 %} + import ARKit +{% endif %} +import UIKit +import SwiftUI + +// swiftlint:disable superfluous_disable_command file_length implicit_return +// MARK: - Asset Catalogs +{% macro enumBlock assets %} + {% call casesBlock assets %} + {% if param.allValues %} + // swiftlint:disable trailing_comma + {% if resourceCount.arresourcegroup > 0 %} + {{accessModifier}} static let allResourceGroups: [{{arResourceGroupType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "arresourcegroup" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.color > 0 %} + {{accessModifier}} static let allColors: [{{colorType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "color" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.data > 0 %} + {{accessModifier}} static let allDataAssets: [{{dataType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "data" "" %}{% endfilter %} + ] + {% endif %} + {% if resourceCount.image > 0 %} + {{accessModifier}} static let allImages: [{{imageType}}] = [ + {% filter indent:2 %}{% call allValuesBlock assets "image" "" %}{% endfilter %} + ] + {% endif %} + // swiftlint:enable trailing_comma + {% endif %} +{% endmacro %} +{% macro casesBlock assets %} + {% for asset in assets %} + {% if asset.type == "arresourcegroup" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{arResourceGroupType}}(name: "{{asset.value}}") + {% elif asset.type == "color" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = Color("{{asset.value}}", bundle: {{bundleToken}}.bundle) + {% elif asset.type == "data" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{dataType}}(name: "{{asset.value}}") + {% elif asset.type == "image" %} + {{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = ImageAsset(name: "{{asset.value}}") + {% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %} + {{accessModifier}} enum {{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { + {% filter indent:2 %}{% call casesBlock asset.items %}{% endfilter %} + } + {% elif asset.items %} + {% call casesBlock asset.items %} + {% endif %} + {% endfor %} +{% endmacro %} +{% macro allValuesBlock assets filter prefix %} + {% for asset in assets %} + {% if asset.type == filter %} + {{prefix}}{{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}, + {% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %} + {% set prefix2 %}{{prefix}}{{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.{% endset %} + {% call allValuesBlock asset.items filter prefix2 %} + {% elif asset.items %} + {% call allValuesBlock asset.items filter prefix %} + {% endif %} + {% endfor %} +{% endmacro %} +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +{{accessModifier}} enum {{enumName}} { + {% if catalogs.count > 1 or param.forceFileNameEnum %} + {% for catalog in catalogs %} + {{accessModifier}} enum {{catalog.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { + {% filter indent:2 %}{% call enumBlock catalog.assets %}{% endfilter %} + } + {% endfor %} + {% else %} + {% call enumBlock catalogs.first.assets %} + {% endif %} +} +{% if resourceCount.arresourcegroup > 0 %} +{{accessModifier}} struct {{arResourceGroupType}} { + {{accessModifier}} fileprivate(set) var name: String + #if os(iOS) + @available(iOS 11.3, *) + {{accessModifier}} var referenceImages: Set { + return ARReferenceImage.referenceImages(in: self) + } + @available(iOS 12.0, *) + {{accessModifier}} var referenceObjects: Set { + return ARReferenceObject.referenceObjects(in: self) + } + #endif +} +#if os(iOS) +@available(iOS 11.3, *) +{{accessModifier}} extension ARReferenceImage { + static func referenceImages(in asset: {{arResourceGroupType}}) -> Set { + let bundle = .bundle + return referenceImages(inGroupNamed: asset.name, bundle: bundle) ?? Set() + } +} +@available(iOS 12.0, *) +{{accessModifier}} extension ARReferenceObject { + static func referenceObjects(in asset: {{arResourceGroupType}}) -> Set { + let bundle = {{bundleToken}}.bundle + return referenceObjects(inGroupNamed: asset.name, bundle: bundle) ?? Set() + } +} +{% endif %} +{% if resourceCount.data > 0 %} +{{accessModifier}} struct {{dataType}} { + {{accessModifier}} fileprivate(set) var name: String + #if os(iOS) || os(tvOS) || os(macOS) + @available(iOS 9.0, macOS 10.11, *) + {{accessModifier}} var data: NSDataAsset { + guard let data = NSDataAsset(asset: self) else { + fatalError("Unable to load data asset named \\(name).") + } + return data + } + #endif +} +#if os(iOS) || os(tvOS) || os(macOS) +@available(iOS 9.0, macOS 10.11, *) +{{accessModifier}} extension NSDataAsset { + convenience init?(asset: {{dataType}}) { + let bundle = {{bundleToken}}.bundle + #if os(iOS) || os(tvOS) + self.init(name: asset.name, bundle: bundle) + #elseif os(macOS) + self.init(name: NSDataAsset.Name(asset.name), bundle: bundle) + #endif + } +} +#endif +{% endif %} + +{% if resourceCount.image > 0 %} +{{accessModifier}} struct ImageAsset { + {{accessModifier}} fileprivate(set) var name: String + + {{accessModifier}} init(name: String) { + self.name = name + } + + #if os(macOS) + {{accessModifier}} typealias Image = NSImage + #elseif os(iOS) || os(tvOS) || os(watchOS) + {{accessModifier}} typealias Image = UIImage + #endif + + {{accessModifier}} var uiImage: Image? { + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + #if os(iOS) || os(tvOS) + let image = Image(named: name, in: bundle, compatibleWith: nil) + #elseif os(macOS) + let name = NSImage.Name(self.name) + let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name) + #elseif os(watchOS) + let image = Image(named: name) + #endif + if image == nil { + // assert(image != nil, "🔥\(name) 로드 실패") + } + return image + } + + {{accessModifier}} var image: SwiftUI.Image? { + guard let uiImage else { return nil } + return SwiftUI.Image(uiImage: uiImage) + } +} + +{{accessModifier}} extension ImageAsset.Image { + @available(macOS, deprecated, + message: "This initializer is unsafe on macOS, please use the ImageAsset.image property") + convenience init?(asset: ImageAsset) { + #if os(iOS) || os(tvOS) + let bundle = {{param.bundle|default:"BundleToken.bundle"}} + self.init(named: asset.name, in: bundle, compatibleWith: nil) + #elseif os(macOS) + self.init(named: NSImage.Name(asset.name)) + #elseif os(watchOS) + self.init(named: asset.name) + #endif + } +} +{% endif %} +{% if not param.bundle %} + +// swiftlint:disable convenience_type +private final class BundleToken { + static let bundle: Bundle = { + #if SWIFT_PACKAGE + return Bundle.module + #else + return Bundle(for: BundleToken.self) + #endif + }() +} +// swiftlint:enable convenience_type +{% endif %} + +{% else %} +// No assets found +{% endif %} +// swiftlint:enable all +// swiftformat:enable all diff --git a/Tuist/ResourceSynthesizers/Fonts.stencil b/Tuist/ResourceSynthesizers/Fonts.stencil new file mode 100755 index 0000000..a703309 --- /dev/null +++ b/Tuist/ResourceSynthesizers/Fonts.stencil @@ -0,0 +1,78 @@ +// swiftlint:disable all +// swift-format-ignore-file +// swiftformat:disable all +// Generated using tuist — https://github.com/tuist/tuist +{% if families %} +{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} +{% set fontType %}{{param.name}}FontConvertible{% endset %} +import UIKit.UIFont +import SwiftUI + +// swiftlint:disable superfluous_disable_command +// swiftlint:disable file_length +// MARK: - Fonts +// swiftlint:disable identifier_name line_length type_body_length +{% macro transformPath path %}{% filter removeNewlines %} + {% if param.preservePath %} + {{path}} + {% else %} + {{path|basename}} + {% endif %} +{% endfilter %}{% endmacro %} +{{accessModifier}} enum {{param.name}}FontFamily { + {% for family in families %} + {{accessModifier}} enum {{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { + {% for font in family.fonts %} + {{accessModifier}} static let {{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{fontType}}(name: "{{font.name}}", family: "{{family.name}}", path: "{% call transformPath font.path %}") + {% endfor %} + {{accessModifier}} static let all: [{{fontType}}] = [{% for font in family.fonts %}{{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{{ ", " if not forloop.last }}{% endfor %}] + } + {% endfor %} + {{accessModifier}} static let allCustomFonts: [{{fontType}}] = [{% for family in families %}{{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.all{{ ", " if not forloop.last }}{% endfor %}].flatMap { $0 } + {{accessModifier}} static func registerAllCustomFonts() { + allCustomFonts.forEach { $0.register() } + } +} +// swiftlint:enable identifier_name line_length type_body_length +// MARK: - Implementation Details +{{accessModifier}} struct {{fontType}} { + {{accessModifier}} let name: String + {{accessModifier}} let family: String + {{accessModifier}} let path: String + + {{accessModifier}} func register() { + // swiftlint:disable:next conditional_returns_on_newline + guard let url = url else { return } + CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil) + } + fileprivate var url: URL? { + // swiftlint:disable:next implicit_return + {% if param.lookupFunction %} + return {{param.lookupFunction}}(name, family, path) + {% else %} + return {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil) + {% endif %} + } +} +{{accessModifier}} extension UIFont { + convenience init?(font: {{fontType}}, size: CGFloat) { + if !UIFont.fontNames(forFamilyName: font.family).contains(font.name) { + font.register() + } + self.init(name: font.name, size: size) + } +} +{% if not param.bundle and not param.lookupFunction %} +// swiftlint:disable convenience_type +private final class BundleToken { + static let bundle: Bundle = { + Bundle(for: BundleToken.self) + }() +} +// swiftlint:enable convenience_type +{% endif %} +{% else %} +// No fonts found +{% endif %} +// swiftlint:enable all +// swiftformat:enable all diff --git a/Tuist/ResourceSynthesizers/JSON.stencil b/Tuist/ResourceSynthesizers/JSON.stencil new file mode 100755 index 0000000..dc52cdf --- /dev/null +++ b/Tuist/ResourceSynthesizers/JSON.stencil @@ -0,0 +1,114 @@ +// swiftlint:disable all +// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen + +{% if files %} +{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} +import Foundation + +// swiftlint:disable superfluous_disable_command +// swiftlint:disable file_length + +// MARK: - JSON Files +{% macro fileBlock file %} + {% call documentBlock file file.document %} +{% endmacro %} +{% macro documentBlock file document %} + {% set rootType %}{% call typeBlock document.metadata %}{% endset %} + {% if document.metadata.type == "Array" %} + {{accessModifier}} static let items: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}") + {% elif document.metadata.type == "Dictionary" %} + + public static let name = "{% call transformPath file.path %}" + + private static let _document = JSONDocument(path: "{% call transformPath file.path %}") + {% for key,value in document.metadata.properties %} + {{accessModifier}} {%+ call propertyBlock key value %} + {% endfor %} + {% else %} + {{accessModifier}} static let value: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}") + {% endif %} +{% endmacro %} +{% macro typeBlock metadata %} + {%- if metadata.type == "Array" -%} + [{% call typeBlock metadata.element %}] + {%- elif metadata.type == "Dictionary" -%} + [String: Any] + {%- elif metadata.type == "Optional" -%} + Any? + {%- else -%} + {{metadata.type}} + {%- endif -%} +{% endmacro %} +{% macro propertyBlock key metadata %} + {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%} + {%- set propertyType %}{% call typeBlock metadata %}{% endset -%} + static let {{propertyName}}: {{propertyType}} = _document["{{key}}"] +{% endmacro %} +{% macro transformPath path %} + {%- if param.preservePath -%} + {{path}} + {%- else -%} + {{path|basename}} + {%- endif -%} +{% endmacro %} + +// swiftlint:disable identifier_name line_length type_body_length +{{accessModifier}} enum {{param.enumName|default:"JSONFiles"}} { + {% if files.count > 1 or param.forceFileNameEnum %} + {% for file in files %} + {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { + {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %} + } + {% endfor %} + {% else %} + {% call fileBlock files.first %} + {% endif %} +} +// swiftlint:enable identifier_name line_length type_body_length + +// MARK: - Implementation Details + +private func objectFromJSON(at path: String) -> T { + {% if param.lookupFunction %} + guard let url = {{param.lookupFunction}}(path), + {% else %} + guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil), + {% endif %} + let json = try? JSONSerialization.jsonObject(with: Data(contentsOf: url), options: []), + let result = json as? T else { + fatalError("Unable to load JSON at path: \(path)") + } + return result +} + +private struct JSONDocument { + let data: [String: Any] + + init(path: String) { + self.data = objectFromJSON(at: path) + } + + subscript(key: String) -> T { + guard let result = data[key] as? T else { + fatalError("Property '\(key)' is not of type \(T.self)") + } + return result + } +} +{% if not param.bundle and not param.lookupFunction %} + +// swiftlint:disable convenience_type +private final class BundleToken { + static let bundle: Bundle = { + #if SWIFT_PACKAGE + return Bundle.module + #else + return Bundle(for: BundleToken.self) + #endif + }() +} +// swiftlint:enable convenience_type +{% endif %} +{% else %} +// No files found +{% endif %} diff --git a/Workspace.swift b/Workspace.swift index 7ca8d0d..9884bde 100644 --- a/Workspace.swift +++ b/Workspace.swift @@ -49,6 +49,12 @@ let workspace = Workspace( target: TargetName.coreKit.unitTestName ) ), + .testableTarget( + target: .project( + path: "./\(ProjectPath.designSystem.rawValue)", + target: TargetName.DesignCore.unitTestName + ) + ) ] ) ),