Skip to content

Commit

Permalink
feat: Create icon modifier for Navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingyuuu0108 committed Apr 1, 2024
1 parent 77d31d2 commit 982df00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 76 deletions.
24 changes: 23 additions & 1 deletion Source/DDS/Component/NavigationBar/NavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ public struct DodamNavigationBar: View {

private let title: String
private let font: Font
private let icon: DodamIconography?
private let verticalSpacing: CGFloat?
private let showBackButton: Bool
private let subView: AnyView?
private let buttons: [DodamNavigationBarButton]

private init(
title: String,
title: String = "",
font: Font = .headline(.small),
icon: DodamIconography? = nil,
verticalSpacing: CGFloat? = nil,
showBackButton: Bool = true,
subView: AnyView? = nil,
buttons: [DodamNavigationBarButton] = .init()
) {
self.title = title
self.font = font
self.icon = icon
self.verticalSpacing = verticalSpacing
self.showBackButton = showBackButton
self.subView = subView
Expand All @@ -33,6 +36,13 @@ public struct DodamNavigationBar: View {
)
}

public static func icon(icon: DodamIconography) -> Self {
.init(
icon: icon,
showBackButton: false
)
}

public static func small(title: String) -> Self {
.init(
title: title,
Expand Down Expand Up @@ -61,6 +71,7 @@ public struct DodamNavigationBar: View {
.init(
title: self.title,
font: self.font,
icon: self.icon,
verticalSpacing: self.verticalSpacing,
showBackButton: self.showBackButton,
subView: AnyView(content()),
Expand All @@ -75,6 +86,7 @@ public struct DodamNavigationBar: View {
.init(
title: self.title,
font: self.font,
icon: self.icon,
verticalSpacing: self.verticalSpacing,
showBackButton: self.showBackButton,
subView: self.subView,
Expand Down Expand Up @@ -108,6 +120,13 @@ public struct DodamNavigationBar: View {
}
.dodamColor(.onSurface)
}
if let icon = icon {
Dodam.icon(icon)
.resizable()
.frame(width: 88, height: 22)
.dodamColor(.primary)
.padding(.leading, 16)
}
if verticalSpacing == nil {
text
.padding(
Expand Down Expand Up @@ -157,6 +176,9 @@ public struct DodamNavigationBar: View {
.button(icon: .plus) { }
.button(icon: .bell) { }
Divider()
DodamNavigationBar.icon(icon: .logo)
.button(icon: .bell) { }
Divider()
DodamNavigationBar.small(title: "Small")
.button(icon: .plus) { }
.button(icon: .bell) { }
Expand Down
74 changes: 0 additions & 74 deletions Source/DDS/Component/OldScrollView/OldScrollView.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "gear.svg",
"filename" : "Gear.svg",
"idiom" : "universal",
"scale" : "1x"
},
Expand Down

0 comments on commit 982df00

Please sign in to comment.