diff --git a/Example/Shared/ComponentsList.swift b/Example/Shared/ComponentsList.swift index d225155..ef29bd5 100644 --- a/Example/Shared/ComponentsList.swift +++ b/Example/Shared/ComponentsList.swift @@ -124,10 +124,6 @@ struct SegmentedControlPreview: View { Spacer() }.padding() } -// .navigationBar("Title", style: .fixed) { -// BarButton(type: .back) -// } trailingBar: {} bottomBar: {} - .scrollWithNavigationBar("App", style: .fixed($offset), background: Color.backgroundSecondary) { BarButton(type: .back) } trailingBar: {} bottomBar: {} diff --git a/Sources/OversizeUI/Controls/Button/Button.swift b/Sources/OversizeUI/Controls/Button/Button.swift index 48ac83f..74c6c7a 100644 --- a/Sources/OversizeUI/Controls/Button/Button.swift +++ b/Sources/OversizeUI/Controls/Button/Button.swift @@ -46,7 +46,7 @@ public struct OversizeButtonStyle: ButtonStyle { @ViewBuilder func background(for role: ButtonRole?) -> some View { - if type != .tertiary { + if type != .quaternary { switch controlBorderShape { case .capsule: Capsule() diff --git a/Sources/OversizeUI/Controls/NavigationBar/ModalNavigationBar.swift b/Sources/OversizeUI/Controls/NavigationBar/ModalNavigationBar.swift index 2988305..95af704 100644 --- a/Sources/OversizeUI/Controls/NavigationBar/ModalNavigationBar.swift +++ b/Sources/OversizeUI/Controls/NavigationBar/ModalNavigationBar.swift @@ -5,7 +5,6 @@ import SwiftUI -@available(iOS 14.0, *) public struct ModalNavigationBar: View { private let leadingBar: () -> LeadingBar? private let trailingBar: () -> TrailingBar? diff --git a/Sources/OversizeUI/Controls/Notice/NoticeView.swift b/Sources/OversizeUI/Controls/Notice/NoticeView.swift new file mode 100644 index 0000000..bc8f568 --- /dev/null +++ b/Sources/OversizeUI/Controls/Notice/NoticeView.swift @@ -0,0 +1,133 @@ +// +// Copyright © 2022 Alexander Romanov +// NoticeView.swift +// + +import SwiftUI + +public struct NoticeView: View where A: View { + let image: Image? + let title: String + let subtitle: String? + let actions: Group? + let closeAction: (() -> Void)? + + public init(_ title: String, + subtitle: String? = nil, + image: Image? = nil, + @ViewBuilder actions: @escaping () -> A, + closeAction: (() -> Void)? = nil) + { + self.image = image + self.title = title + self.subtitle = subtitle + self.actions = Group { actions() } + self.closeAction = closeAction + } + + public var body: some View { + Surface { + VStack(alignment: .leading, spacing: .xxSmall) { + HStack { + image.map { + $0 + .resizable() + .frame(width: 32, height: 32) + } + + Text(title) + .headline(.bold) + .foregroundOnSurfaceHighEmphasis() + .multilineTextAlignment(.leading) + .padding(.trailing, closeAction != nil ? .medium : .zero) + } + + subtitle.map { text in + Text(text) + .body(.medium) + .foregroundOnSurfaceMediumEmphasis() + .multilineTextAlignment(.leading) + } + + if actions != nil { + HStack(spacing: .xSmall) { + actions + .buttonStyle(.primary) + .controlSize(.mini) + } + .padding(.top, .xxSmall) + } + } + .frame(maxWidth: .infinity, alignment: .leading) + } + .overlay(alignment: .topTrailing) { + if closeAction != nil { + Button { + closeAction?() + } label: { + Icon(.xMini, color: .onSurfaceHighEmphasis) + } + .buttonStyle(.tertiary(infinityWidth: false)) + .controlBorderShape(.capsule) + .padding(.xSmall) + .controlSize(.mini) + } + } + } +} + +public extension NoticeView where A == EmptyView { + init(_ title: String, + subtitle: String? = nil, + image: Image? = nil, + closeAction: (() -> Void)? = nil) + { + self.image = image + self.title = title + self.subtitle = subtitle + actions = nil + self.closeAction = closeAction + } +} + +struct NoticeView_Previews: PreviewProvider { + static var previews: some View { + + + VStack(spacing: .small) { + + NoticeView("Title") + + NoticeView("Title", subtitle: "Subtitle") + + NoticeView("Title", subtitle: "Subtitle") { + print("Ok Action") + } + + NoticeView("Title") { + Button { + print("Ok") + } label: { + Text("Primay") + } + .accent() + } + + NoticeView("Title", subtitle: "Subtitle") { + Button("Primay") { + print("Ok") + } + Button("Primay") { + print("Ok") + } + .buttonStyle(.tertiary) + + } closeAction: { + print("Close") + } + } + .padding() + .background { Color.backgroundSecondary.ignoresSafeArea(.all) } + + } +} diff --git a/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControl.swift b/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControl.swift index 632748b..a6ec8b3 100644 --- a/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControl.swift +++ b/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControl.swift @@ -5,11 +5,7 @@ import SwiftUI -public struct SegmentedPickerSelector: View - where - Content: View, - Selection: View -{ +public struct SegmentedPickerSelector: View where Content: View, Selection: View { @Environment(\.theme) private var theme: ThemeSettings @Environment(\.segmentedControlStyle) private var style @Environment(\.controlRadius) var controlRadius: Radius