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

[iOS] MSUIKit 적용 #122

Merged
merged 7 commits into from
Nov 27, 2023
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
Binary file removed .DS_Store
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions iOS/MSUIKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import PackageDescription
extension String {
static let package = "MSUIKit"
static let designSystem = "MSDesignSystem"
static let components = "MSUIComponents"

static let uiKit = "MSUIKit"
var testTarget: String {
return self + "Tests"
}
Expand All @@ -24,15 +24,20 @@ let package = Package(
],
products: [
.library(name: .designSystem,
type: .static,
targets: [.designSystem]),
.library(name: .components,
targets: [.components])
.library(name: .uiKit,
targets: [.uiKit])
],
targets: [
// Codes
.target(name: .designSystem),
.target(name: .components,
dependencies: [.target(name: .designSystem)]),
.target(name: .designSystem,
resources: [
.process("../MSDesignSystem/Resources")
]),
.target(name: .uiKit,
dependencies: ["MSDesignSystem"]),

// Tests
.testTarget(name: .designSystem.testTarget,
dependencies: ["MSDesignSystem"])
Expand Down
30 changes: 30 additions & 0 deletions iOS/MSUIKit/Sources/MSDesignSystem/MSColor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// MSColor.swift
// MSUIKit
//
// Created by 이창준 on 11/19/23.
//

import UIKit

public enum MSColor: String {
case primaryBackground = "Background Primary"
case secondaryBackground = "Background Secondary"
case primaryButtonBackground = "Button Background Primary"
case secondaryButtonBackground = "Button Background Secondary"

case primaryTypo = "Typo Primary"
case primaryButtonTypo = "Button Typo Primary"
case secondaryTypo = "Typo Secondary"
case secondaryButtonTypo = "Button Typo Secondary"

case musicSpot = "MusicSpot"
}

extension UIColor {

public static func msColor(_ color: MSColor) -> UIColor {
return UIColor(named: color.rawValue, in: .module, compatibleWith: .current)!
}

}
8 changes: 0 additions & 8 deletions iOS/MSUIKit/Sources/MSDesignSystem/MSDesignSystem.swift

This file was deleted.

73 changes: 73 additions & 0 deletions iOS/MSUIKit/Sources/MSDesignSystem/MSFont.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// MSFont.swift
// MSUIKit
//
// Created by 이창준 on 11/19/23.
//

import UIKit

public enum MSFont {
case superTitle
case duperTitle
case headerTitle
case subtitle
case buttonTitle
case paragraph
case caption

// MARK: - Functions

private var fontDetails: (fontName: String, size: CGFloat) {
switch self {
case .superTitle: return ("Pretendard-Bold", 34.0)
case .duperTitle: return ("Pretendard-Bold", 28.0)
case .headerTitle: return ("Pretendard-Bold", 22.0)
case .subtitle: return ("Pretendard-Bold", 20.0)
case .buttonTitle: return ("Pretendard-SemiBold", 20.0)
case .paragraph: return ("Pretendard-Regular", 17.0)
case .caption: return ("Pretendard-Regular", 13.0)
}
}

internal func font() -> UIFont? {
let details = self.fontDetails
return UIFont(name: details.fontName, size: details.size)
}

fileprivate static func registerFont(bundle: Bundle, fontName: String, fontExtension: String) {
guard let fontURL = bundle.url(forResource: fontName, withExtension: fontExtension),
let fontDataProvider = CGDataProvider(url: fontURL as CFURL),
let font = CGFont(fontDataProvider) else {
print("Couldn't find font \(fontName)")
return
}

var error: Unmanaged<CFError>?
CTFontManagerRegisterGraphicsFont(font, &error)
}

public static func registerFonts() {
[
"Pretendard-Regular",
"Pretendard-SemiBold",
"Pretendard-Bold"
].forEach {
registerFont(bundle: .module, fontName: $0, fontExtension: "otf")
}
}

}

public extension UIFont {

static func msFont(_ font: MSFont) -> UIFont? {
if let font = font.font() {
return font
} else {
print("can't find msFont. use default font")
return nil
}
}

}
42 changes: 42 additions & 0 deletions iOS/MSUIKit/Sources/MSDesignSystem/MSIcon.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// MSIcon.swift
// MSUIKit
//
// Created by 이창준 on 11/19/23.
//

import UIKit

public enum MSIcon: String {
case check = "Check"
case close = "Close"

case arrowUp = "Up"
case arrowLeft = "Left"
case arrowDown = "Down"
case arrowRight = "Right"

case calendar = "Calendar"
case image = "Image"
case location = "Location"
case addLocation = "Location Add"
case lock = "Lock"
case map = "Map"
case message = "Message"
case setting = "Setting"
case userTag = "User Tag"

case pause = "Pause"
case play = "Play"
case voice = "Voice"
case volumeHigh = "Volume High"
case volumeOff = "Volume Off"
}

extension UIImage {

public static func msIcon(_ icon: MSIcon) -> UIImage? {
return UIImage(named: icon.rawValue, in: .module, compatibleWith: .current)?.withRenderingMode(.alwaysTemplate)
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF6",
"green" : "0xF6",
"red" : "0xF6"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF6",
"green" : "0xF6",
"red" : "0xF6"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x15",
"green" : "0x15",
"red" : "0x15"
}
},
"idiom" : "iphone"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF6",
"green" : "0xF6",
"red" : "0xF6"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.980",
"blue" : "0xFA",
"green" : "0xFA",
"red" : "0xFA"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.980",
"blue" : "0x23",
"green" : "0x23",
"red" : "0x23"
}
},
"idiom" : "iphone"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF6",
"green" : "0xF6",
"red" : "0xF6"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x23",
"green" : "0x23",
"red" : "0x23"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF6",
"green" : "0xF6",
"red" : "0xF6"
}
},
"idiom" : "iphone"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading