-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨[FEAT] : SwiftUI NavigationView 디자인시스템 추가
- Loading branch information
1 parent
56ad30e
commit 1d71c82
Showing
2 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
Sources/SDSKit/Component/NavigationBar/SDSNavigationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |