Skip to content

Commit

Permalink
✨[FEAT] : SwiftUI NavigationView 디자인시스템 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuchanghwi committed Dec 22, 2023
1 parent 56ad30e commit 1d71c82
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Kingfisher",
"state" : {
"revision" : "c1f60c63f356d364f4284ba82961acbe7de79bcc",
"version" : "7.8.1"
"revision" : "add0a87ec4e31e2ca2a0b2085f0559201e4f5918",
"version" : "7.10.1"
}
},
{
"identity" : "lottie-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-ios",
"state" : {
"revision" : "d6feea26a370019b4d3a85f5984cb95a2734776f",
"version" : "4.2.0"
"revision" : "3f1202f254ad5d71f6c5b518ed2d6b9e2abe6969",
"version" : "4.3.4"
}
},
{
Expand Down
139 changes: 139 additions & 0 deletions Sources/SDSKit/Component/NavigationBar/SDSNavigationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#if canImport(SwiftUI)
import SwiftUI
#endif

public enum SDSNavigationStyle {
case leftTitleRightDismissButton(title: String, dismissImage: Image, action: () -> Void)
case leftPopButtonMiddleTitle(title: String, action: () -> Void)
case titleRightDismissButton(title: String, dismissImage: Image, action: () -> Void)
case leftPopButtonMiddleTitleRightDismissButton(title: String, dismissImage: Image, popAction: () -> Void, dismissAction: () -> Void)
case leftPopButtonMiddleTitleRightCustomButton(title: String, customButtonTitle: String, popAction: () -> Void, dismissAction: () -> Void)
}

public struct SDSNavigationView: View {
let style: SDSNavigationStyle
public init(style: SDSNavigationStyle) {
self.style = style
}
public var body: some View {
switch style {
case .leftTitleRightDismissButton(title: let title, dismissImage: let dismissImage, action: let action):
HStack(alignment: .center) {
Text(title)
.foregroundColor(Color(uiColor: .gray600))
.font(Font(SDSFont.title1.font))
.padding(.leading, 20)
Spacer()
Button {
action()
} label: {
dismissImage
.resizable()
.frame(width: 36, height: 36)
}
.padding(.trailing, 10)
}
.frame(maxWidth: .infinity)
.frame(height: 52)
case .leftPopButtonMiddleTitle(title: let title, action: let action):
HStack(alignment: .center) {
Button {
action()
} label: {
Image(uiImage: SDSIcon.icNavigationBarLeft)
.resizable()
.frame(width: 24, height: 24)
}
.padding(.leading, 10)
Spacer()
Text(title)
.font(Font(SDSFont.subTitle.font))
.foregroundColor(Color(uiColor: .gray600))
Spacer()
Rectangle()
.foregroundColor(.clear)
.frame(width: 24, height: 24)
.padding(.trailing, 10)
}
.frame(maxWidth: .infinity)
.frame(height: 52)
case .titleRightDismissButton(title: let title, dismissImage: let dismissImage, action: let action):
HStack(alignment: .center) {
Rectangle()
.foregroundColor(.clear)
.frame(width: 36, height: 36)
.padding(.leading, 10)
Spacer()
Text(title)
.font(Font(SDSFont.subTitle.font))
.foregroundColor(Color(uiColor: .gray600))
Spacer()
Button {
action()
} label: {
dismissImage
.resizable()
.frame(width: 36, height: 36)
}
.padding(.trailing, 10)
}
.frame(maxWidth: .infinity)
.frame(height: 52)
case .leftPopButtonMiddleTitleRightDismissButton(title: let title, dismissImage: let dismissImage, popAction: let popAction, dismissAction: let dismissAction):
HStack(alignment: .center) {
Button {
popAction()
} label: {
Image(uiImage: SDSIcon.icNavigationBarLeft)
.resizable()
.frame(width: 24, height: 24)
}
.padding(.trailing, 12)
.padding(.leading, 10)
Spacer()
Text(title)
.font(Font(SDSFont.subTitle.font))
.foregroundColor(Color(uiColor: .gray600))
Spacer()
Button {
dismissAction()
} label: {
dismissImage
.resizable()
.frame(width: 36, height: 36)
}
.padding(.trailing, 10)
}
.frame(maxWidth: .infinity)
.frame(height: 52)
case .leftPopButtonMiddleTitleRightCustomButton(title: let title, customButtonTitle: let customButtonTitle, popAction: let popAction, dismissAction: let dismissAction):
HStack(alignment: .center) {
Button {
popAction()
} label: {
Image(uiImage: SDSIcon.icNavigationBarLeft)
.resizable()
.frame(width: 24, height: 24)
}
.padding(.trailing, 20)
.padding(.leading, 10)
Spacer()
Text(title)
.font(Font(SDSFont.subTitle.font))
.foregroundColor(Color(uiColor: .gray600))
Spacer()
Button {
dismissAction()
} label: {
Text(customButtonTitle)
.foregroundColor(Color(uiColor: .lightBlue600))
.font(Font(SDSFont.btn2.font))
.padding(.horizontal, 10)
}
.padding(.trailing, 10)
}
.frame(maxWidth: .infinity)
.frame(height: 52)
}
}
}

0 comments on commit 1d71c82

Please sign in to comment.