Skip to content

Commit

Permalink
Merge pull request #372 from boostcampwm2023/iOS/task/SwiftUI-Components
Browse files Browse the repository at this point in the history
[iOS] MSButton SwiftUI 포팅
  • Loading branch information
SwiftyJunnos authored Feb 20, 2024
2 parents 8ac1187 + e7a851c commit c6fd4cc
Show file tree
Hide file tree
Showing 108 changed files with 416 additions and 172 deletions.
7 changes: 4 additions & 3 deletions iOS/Features/Home/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private enum Dependency {
static let msDomain = "MSDomain"
static let msData = "MSData"
static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"
static let msUserDefaults = "MSUserDefaults"
static let msLogger = "MSLogger"
static let msFoundation = "MSFoundation"
Expand All @@ -58,8 +59,8 @@ let package = Package(
path: Dependency.msDomain.fromRootPath),
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
Expand All @@ -85,7 +86,7 @@ let package = Package(
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msUserDefaults,
package: Dependency.msFoundation),
.product(name: Dependency.msLogger,
Expand Down
7 changes: 4 additions & 3 deletions iOS/Features/JourneyList/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private enum Dependency {
static let msData = "MSData"

static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"

static let msLogger = "MSLogger"
static let msFoundation = "MSFoundation"
Expand All @@ -46,16 +47,16 @@ let package = Package(
dependencies: [
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
targets: [
.target(name: Target.journeyList,
dependencies: [
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msLogger,
Expand Down
7 changes: 4 additions & 3 deletions iOS/Features/RewindJourney/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private enum Dependency {
static let combineCocoa = "CombineCocoa"
static let msDesignsystem = "MSDesignSystem"
static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"

static let msExtension = "MSExtension"
static let msLogger = "MSLogger"
Expand All @@ -56,8 +57,8 @@ let package = Package(
path: Dependency.msDomain.fromRootPath),
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
Expand All @@ -69,7 +70,7 @@ let package = Package(
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msLogger,
package: Dependency.msFoundation),
.product(name: Dependency.msExtension,
Expand Down
7 changes: 4 additions & 3 deletions iOS/Features/SaveJourney/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private enum Dependency {
static let msData = "MSData"

static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"

static let msExtension = "MSExtension"
static let msLogger = "MSLogger"
Expand All @@ -54,8 +55,8 @@ let package = Package(
path: Dependency.msDomain.fromRootPath),
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
Expand All @@ -67,7 +68,7 @@ let package = Package(
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msExtension,
package: Dependency.msFoundation),
.product(name: Dependency.msLogger,
Expand Down
7 changes: 4 additions & 3 deletions iOS/Features/SelectSong/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private enum Dependency {
static let combineCocoa = "CombineCocoa"
static let msDesignsystem = "MSDesignSystem"
static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"

static let msLogger = "MSLogger"
static let msFoundation = "MSFoundation"
Expand All @@ -55,8 +56,8 @@ let package = Package(
path: Dependency.msDomain.fromRootPath),
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
Expand All @@ -68,7 +69,7 @@ let package = Package(
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msLogger,
package: Dependency.msFoundation)
])
Expand Down
9 changes: 5 additions & 4 deletions iOS/Features/Spot/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ private enum Dependency {
// package
static let msData = "MSData"
static let msDomain = "MSDomain"
static let msUIKit = "MSUIKit"
static let msFusion = "MSFusion"
static let msFoundation = "MSFoundation"

// library
static let msLogger = "MSLogger"
static let msUIKit = "MSUIKit"

}

Expand All @@ -54,8 +55,8 @@ let package = Package(
path: Dependency.msDomain.fromRootPath),
.package(name: Dependency.msData,
path: Dependency.msData.fromRootPath),
.package(name: Dependency.msUIKit,
path: Dependency.msUIKit.fromRootPath),
.package(name: Dependency.msFusion,
path: Dependency.msFusion.fromRootPath),
.package(name: Dependency.msFoundation,
path: Dependency.msFoundation.fromRootPath)
],
Expand All @@ -67,7 +68,7 @@ let package = Package(
.product(name: Dependency.msData,
package: Dependency.msData),
.product(name: Dependency.msUIKit,
package: Dependency.msUIKit),
package: Dependency.msFusion),
.product(name: Dependency.msLogger,
package: Dependency.msFoundation)
])
Expand Down
9 changes: 8 additions & 1 deletion iOS/MSUIKit/Package.swift → iOS/MSFusion/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PackageDescription

extension String {

static let package = "MSUIKit"
static let package = "MSFusion"

var fromRootPath: String {
return "../" + self
Expand All @@ -18,6 +18,7 @@ extension String {
private enum Target {

static let msDesignSystem = "MSDesignSystem"
static let msSwiftUI = "MSSwiftUI"
static let msUIKit = "MSUIKit"
static let combineCocoa = "CombineCocoa"

Expand All @@ -41,6 +42,8 @@ let package = Package(
.iOS(.v15)
],
products: [
.library(name: Target.msSwiftUI,
targets: [Target.msSwiftUI]),
.library(name: Target.msUIKit,
targets: [Target.msUIKit])
],
Expand All @@ -56,6 +59,10 @@ let package = Package(
.process("../\(Target.msDesignSystem)/Resources")
]),
.target(name: Target.combineCocoa),
.target(name: Target.msSwiftUI,
dependencies: [
.target(name: Target.msDesignSystem)
]),
.target(name: Target.msUIKit,
dependencies: [
.target(name: Target.msDesignSystem),
Expand Down
26 changes: 26 additions & 0 deletions iOS/MSFusion/Sources/MSDesignSystem/Bundle+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Bundle+.swift
// MSDesignSystem
//
// Created by 이창준 on 2024.02.19.
//

import Foundation

public class MSBundle {
public static let bundle = Bundle(for: MSBundle.self)
}

extension Bundle {

#if SWIFT_PACKAGE
public static var msDesignSystem: Bundle {
return .module
}
#else
public static var msDesignSystem: Bundle {
return Bundle(for: MSBundle.self)
}
#endif

}
16 changes: 16 additions & 0 deletions iOS/MSFusion/Sources/MSDesignSystem/Color/MSColor+SwiftUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// MSColor+SwiftUI.swift
// MSDesignSystem
//
// Created by 이창준 on 2024.02.19.
//

import SwiftUI

extension Color {

public static func msColor(_ color: MSColor) -> Color {
return Color(color.rawValue, bundle: .msDesignSystem)
}

}
16 changes: 16 additions & 0 deletions iOS/MSFusion/Sources/MSDesignSystem/Color/MSColor+UIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// MSColor+UIKit.swift
// MSDesignSystem
//
// Created by 이창준 on 2024.02.19.
//

import UIKit

extension UIColor {

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

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//
// MSColor.swift
// MSUIKit
// MSDesignSystem
//
// 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"
Expand All @@ -26,12 +25,5 @@ public enum MSColor: String {
case textFieldTypo = "TextField Typo"

case musicSpot = "MusicSpot"
}

extension UIColor {

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

}
25 changes: 25 additions & 0 deletions iOS/MSFusion/Sources/MSDesignSystem/Font/MSFont+SwiftUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// MSFont+SwiftUI.swift
// MSDesignSystem
//
// Created by 이창준 on 2024.02.19.
//

import SwiftUI

extension MSFont {

fileprivate func font() -> Font? {
let details = self.fontDetails
return Font.custom(details.fontName, size: details.size)
}

}

public extension Font {

static func msFont(_ font: MSFont) -> Font? {
return font.font()
}

}
26 changes: 26 additions & 0 deletions iOS/MSFusion/Sources/MSDesignSystem/Font/MSFont+UIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// MSFont+UIKit.swift
// MSDesignSystem
//
// Created by 이창준 on 2024.02.19.
//

import UIKit

extension MSFont {

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

}

public extension UIFont {

static func msFont(_ font: MSFont) -> UIFont? {
return font.font()
}

}

Loading

0 comments on commit c6fd4cc

Please sign in to comment.