feat(theme): 디자인 토큰을 추가한다
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// KoreanFontModifier.swift
|
||||
// FontModifier.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 1/23/26.
|
||||
@@ -7,6 +7,52 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum SodaTypography {
|
||||
case heading1
|
||||
case heading2
|
||||
case heading3
|
||||
case heading4
|
||||
case body1
|
||||
case body2
|
||||
case body3
|
||||
case body4
|
||||
case body5
|
||||
case body6
|
||||
case caption1
|
||||
case caption2
|
||||
case caption3
|
||||
|
||||
var size: CGFloat {
|
||||
switch self {
|
||||
case .heading1:
|
||||
return 24
|
||||
case .heading2:
|
||||
return 22
|
||||
case .heading3:
|
||||
return 20
|
||||
case .heading4:
|
||||
return 18
|
||||
case .body1, .body2, .body3:
|
||||
return 16
|
||||
case .body4, .body5, .body6:
|
||||
return 14
|
||||
case .caption1, .caption2, .caption3:
|
||||
return 12
|
||||
}
|
||||
}
|
||||
|
||||
var weight: SwiftUI.Font.Weight {
|
||||
switch self {
|
||||
case .heading1, .heading2, .heading3, .heading4, .body1, .body4, .caption1:
|
||||
return .bold
|
||||
case .body2, .body5, .caption2:
|
||||
return .medium
|
||||
case .body3, .body6, .caption3:
|
||||
return .regular
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func resolvedLanguageCode(currentLocale: Locale) -> String? {
|
||||
if let raw = UserDefaults.standard.string(forKey: "app.language"),
|
||||
let option = LanguageOption(rawValue: raw),
|
||||
@@ -42,7 +88,7 @@ private func japaneseFontName(for weight: SwiftUI.Font.Weight) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
struct KoreanFontModifier: ViewModifier {
|
||||
struct FontModifier: ViewModifier {
|
||||
@Environment(\.locale) private var locale
|
||||
let size: CGFloat
|
||||
let weight: SwiftUI.Font.Weight
|
||||
@@ -63,7 +109,11 @@ struct KoreanFontModifier: ViewModifier {
|
||||
|
||||
extension View {
|
||||
func appFont(size: CGFloat, weight: SwiftUI.Font.Weight = .regular) -> some View {
|
||||
self.modifier(KoreanFontModifier(size: size, weight: weight))
|
||||
self.modifier(FontModifier(size: size, weight: weight))
|
||||
}
|
||||
|
||||
func appFont(_ typography: SodaTypography) -> some View {
|
||||
appFont(size: typography.size, weight: typography.weight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +129,8 @@ extension Text {
|
||||
|
||||
return self.font(.system(size: size, weight: weight))
|
||||
}
|
||||
|
||||
func appFont(_ typography: SodaTypography) -> Text {
|
||||
appFont(size: typography.size, weight: typography.weight)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user