diff --git a/Package.resolved b/Package.resolved index 9c2b8f4..7231a39 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher", "state" : { - "revision" : "c1f60c63f356d364f4284ba82961acbe7de79bcc", - "version" : "7.8.1" + "revision" : "add0a87ec4e31e2ca2a0b2085f0559201e4f5918", + "version" : "7.10.1" } }, { @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/airbnb/lottie-ios", "state" : { - "revision" : "d6feea26a370019b4d3a85f5984cb95a2734776f", - "version" : "4.2.0" + "revision" : "3f1202f254ad5d71f6c5b518ed2d6b9e2abe6969", + "version" : "4.3.4" } }, { diff --git a/Sources/SDSKit/Component/NavigationBar/SDSNavigationView.swift b/Sources/SDSKit/Component/NavigationBar/SDSNavigationView.swift new file mode 100644 index 0000000..8c0dcb8 --- /dev/null +++ b/Sources/SDSKit/Component/NavigationBar/SDSNavigationView.swift @@ -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) + } + } +}