diff --git a/Sources/OversizeUI/Controls/DateField/DateField.swift b/Sources/OversizeUI/Controls/DateField/DateField.swift
index 0e6092e..2033480 100644
--- a/Sources/OversizeUI/Controls/DateField/DateField.swift
+++ b/Sources/OversizeUI/Controls/DateField/DateField.swift
@@ -46,7 +46,7 @@ public struct DateField: View {
HStack {
Text(label)
.subheadline(.medium)
- .foregroundColor(.onSurfaceHighEmphasis)
+ .foregroundColor(.onSurfacePrimary)
Spacer()
}
}
@@ -58,7 +58,7 @@ public struct DateField: View {
Text(label)
.font(.subheadline)
.fontWeight(.semibold)
- .onSurfaceDisabledForegroundColor()
+ .onSurfaceTertiaryForeground()
}
HStack {
diff --git a/Sources/OversizeUI/Controls/HUD/HUD.swift b/Sources/OversizeUI/Controls/HUD/HUD.swift
index 6366a2d..81e9b21 100644
--- a/Sources/OversizeUI/Controls/HUD/HUD.swift
+++ b/Sources/OversizeUI/Controls/HUD/HUD.swift
@@ -48,7 +48,7 @@ public struct HUD
: View where Title: View, Icon: View {
#if os(macOS)
.foregroundColor(Color.onPrimary)
#else
- .foregroundColor(Color.onSurfaceHighEmphasis)
+ .foregroundColor(Color.onSurfacePrimary)
#endif
diff --git a/Sources/OversizeUI/Controls/IconPicker/IconPicker.swift b/Sources/OversizeUI/Controls/IconPicker/IconPicker.swift
index c5314e9..ba5562d 100644
--- a/Sources/OversizeUI/Controls/IconPicker/IconPicker.swift
+++ b/Sources/OversizeUI/Controls/IconPicker/IconPicker.swift
@@ -45,13 +45,13 @@ public struct IconPicker: View {
} label: {
HStack(spacing: .xxSmall) {
Text(label)
- .onSurfaceHighEmphasisForegroundColor()
+ .onSurfacePrimaryForeground()
Spacer()
if let image = selection {
image
}
- IconDeprecated(.chevronDown, color: .onSurfaceHighEmphasis)
+ IconDeprecated(.chevronDown, color: .onSurfacePrimary)
}
}
.buttonStyle(.field)
diff --git a/Sources/OversizeUI/Controls/Notice/NoticeView.swift b/Sources/OversizeUI/Controls/Notice/NoticeView.swift
index 18a2523..71ecae7 100644
--- a/Sources/OversizeUI/Controls/Notice/NoticeView.swift
+++ b/Sources/OversizeUI/Controls/Notice/NoticeView.swift
@@ -83,7 +83,7 @@ public struct NoticeView: View where A: View {
Button {
closeAction?()
} label: {
- IconDeprecated(.xMini, color: .onSurfaceHighEmphasis)
+ IconDeprecated(.xMini, color: .onSurfacePrimary)
}
.buttonStyle(subtitle != nil ? .tertiary(infinityWidth: false) : .quaternary(infinityWidth: false))
.controlBorderShape(.capsule)
diff --git a/Sources/OversizeUI/Controls/Row/Row.swift b/Sources/OversizeUI/Controls/Row/Row.swift
index 9656ae8..74ae464 100644
--- a/Sources/OversizeUI/Controls/Row/Row.swift
+++ b/Sources/OversizeUI/Controls/Row/Row.swift
@@ -26,8 +26,8 @@ public struct Row: View where LeadingLabel: View, T
private let leadingLabel: LeadingLabel?
private let trailingLabel: TrailingLabel?
- private var leadingType: RowLeadingType?
- private var trallingType: RowTrailingType?
+// private var leadingType: RowLeadingType?
+// private var trallingType: RowTrailingType?
private let action: (() -> Void)?
@@ -66,16 +66,16 @@ public struct Row: View where LeadingLabel: View, T
@available(*, deprecated, message: "Use leading: {} and tralling: {}")
public init(_ title: String,
subtitle: String? = nil,
- leadingType: RowLeadingType? = nil,
- trallingType: RowTrailingType? = nil,
+// leadingType: RowLeadingType? = nil,
+// trallingType: RowTrailingType? = nil,
paddingHorizontal _: Space = .medium,
paddingVertical _: Space = .small,
action: (() -> Void)? = nil)
{
self.title = title
self.subtitle = subtitle
- self.leadingType = leadingType
- self.trallingType = trallingType
+// self.leadingType = leadingType
+// self.trallingType = trallingType
self.action = action
leadingLabel = nil
trailingLabel = nil
@@ -246,20 +246,20 @@ public extension Row {
control.textColor = color
return control
}
-
- @available(*, deprecated, message: "Use leading: {} and tralling: {}")
- func rowLeading(_ leading: RowLeadingType?) -> Row {
- var control = self
- control.leadingType = leading
- return control
- }
-
- @available(*, deprecated, message: "Use leading: {} and tralling: {}")
- func rowTrailing(_ trailing: RowTrailingType?) -> Row {
- var control = self
- control.trallingType = trailing
- return control
- }
+//
+// @available(*, deprecated, message: "Use leading: {} and tralling: {}")
+// func rowLeading(_ leading: RowLeadingType?) -> Row {
+// var control = self
+// control.leadingType = leading
+// return control
+// }
+//
+// @available(*, deprecated, message: "Use leading: {} and tralling: {}")
+// func rowTrailing(_ trailing: RowTrailingType?) -> Row {
+// var control = self
+// control.trallingType = trailing
+// return control
+// }
}
public extension View {
diff --git a/Sources/OversizeUI/Controls/Surface/Surface.swift b/Sources/OversizeUI/Controls/Surface/Surface.swift
index c598465..3b4982e 100644
--- a/Sources/OversizeUI/Controls/Surface/Surface.swift
+++ b/Sources/OversizeUI/Controls/Surface/Surface.swift
@@ -283,7 +283,7 @@ struct Surface_Previews: PreviewProvider {
static var previews: some View {
VStack {
Surface {
- RowDeprecated("Title") {}
+ Row("Title") {}
}
.surfaceStyle(.primary)
.previewLayout(.fixed(width: 414, height: 300))
diff --git a/Sources/OversizeUI/Deprecated/BlurView.swift b/Sources/OversizeUI/Deprecated/BlurView.swift
deleted file mode 100644
index 7eec056..0000000
--- a/Sources/OversizeUI/Deprecated/BlurView.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// BlurView.swift, created on 11.09.2021
-//
-
-import Foundation
-import SwiftUI
-
-// swiftlint:disable all
-#if os(iOS)
-public struct BlurView: UIViewRepresentable {
- public init(_ style: UIBlurEffect.Style = .light) {
- self.style = style
- }
-
- public let style: UIBlurEffect.Style
-
- public func makeUIView(context _: UIViewRepresentableContext) -> UIView {
- let view: UIView = .init(frame: .zero)
- view.backgroundColor = .clear
- let blurEffect: UIBlurEffect = .init(style: style)
- let blurView: UIVisualEffectView = .init(effect: blurEffect)
- blurView.translatesAutoresizingMaskIntoConstraints = false
- view.insertSubview(blurView, at: 0)
- NSLayoutConstraint.activate([
- blurView.heightAnchor.constraint(equalTo: view.heightAnchor),
- blurView.widthAnchor.constraint(equalTo: view.widthAnchor),
- ])
- return view
- }
-
- public func updateUIView(_: UIView,
- context _: UIViewRepresentableContext) {}
-}
-#endif
diff --git a/Sources/OversizeUI/Deprecated/ButtonLegacy.swift b/Sources/OversizeUI/Deprecated/ButtonLegacy.swift
deleted file mode 100644
index c4b97c0..0000000
--- a/Sources/OversizeUI/Deprecated/ButtonLegacy.swift
+++ /dev/null
@@ -1,299 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// ButtonLegacy.swift, created on 11.09.2021
-//
-
-import SwiftUI
-
-public enum LegacyButtonType: Int, CaseIterable {
- case accent
- case primary
- case secondary
- case gray
- case text
- case link
- case deleteLink
-}
-
-public enum ButtonSize {
- case large
- case medium
-}
-
-public enum ButtonRounded {
- case full
- case medium
- case small
- case none
-}
-
-public enum ButtonWidth {
- case full
- case round
- case standart
-}
-
-// swiftlint:disable all
-public struct ButtonStyleExtended: ButtonStyle {
- @Environment(\.theme) private var theme: ThemeSettings
-
- var style: LegacyButtonType
- var size: ButtonSize = .large
- var rounded: ButtonRounded = .medium
- var width: ButtonWidth = .full
- var shadow: Bool = true
-
- private enum Constants {
- /// Size
- static var heightL: CGFloat { Space.xLarge.rawValue + Space.xxSmall.rawValue }
- static var heightM: CGFloat { Space.large.rawValue + Space.xxSmall.rawValue }
-
- /// Radius
- static var radiusM: CGFloat { Radius.medium.rawValue }
- static var radiusS: CGFloat { Radius.small.rawValue }
- }
-
- @ViewBuilder
- public func makeBody(configuration: ButtonStyle.Configuration) -> some View {
- switch style {
- case .primary:
- PrimaryButton(size: size, rounded: rounded, width: width, shadow: shadow, isBordered: theme.borderButtons, borderLineWidth: CGFloat(theme.borderSize), configuration: configuration)
- case .secondary:
- SecondaryButton(size: size, rounded: rounded, width: width, shadow: shadow, isBordered: theme.borderButtons, borderLineWidth: CGFloat(theme.borderSize), configuration: configuration)
- case .gray:
- GrayButton(size: size, rounded: rounded, width: width, shadow: shadow, isBordered: theme.borderButtons, borderLineWidth: CGFloat(theme.borderSize), configuration: configuration)
- case .text:
- TextButton(size: size, rounded: rounded, width: width, configuration: configuration)
- case .link:
- LinkButton(size: size, rounded: rounded, width: width, shadow: shadow, configuration: configuration)
- case .deleteLink:
- DeleteButton(size: size, rounded: rounded, width: width, shadow: shadow, configuration: configuration)
- case .accent:
- AccentButton(size: size, rounded: rounded, width: width, shadow: shadow, configuration: configuration, isBordered: theme.borderButtons, borderLineWidth: CGFloat(theme.borderSize))
- }
- }
-
- struct AccentButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- let configuration: ButtonStyle.Configuration
- var isBordered: Bool
- var borderLineWidth: CGFloat
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .onPrimary : .onPrimaryTertiary)
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .background(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .fill(isEnabled ? Color.accent : Color.accent.opacity(0.9))
- .overlay(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .stroke(isBordered
- ? Color.border
- : isEnabled ? Color.accent : Color.accent.opacity(0.9), lineWidth: 1)
- )
- )
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- // .animation(.spring())
- .shadowElevaton(shadow ? .z2 : .z0, color: Color.accent)
- }
- }
-
- struct PrimaryButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- var isBordered: Bool
- var borderLineWidth: CGFloat
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? Color.backgroundPrimary : .onPrimaryTertiary)
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .background(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .fill(isEnabled ? Color.primary : Color.primary.opacity(0.9))
- .overlay(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .stroke(isBordered
- ? Color.border
- : isEnabled ? Color.primary : Color.primary.opacity(0.9), lineWidth: 1)
- )
- )
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- .shadowElevaton(shadow ? .z2 : .z0, color: Color.primary)
- }
- }
-
- struct SecondaryButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- var isBordered: Bool
- var borderLineWidth: CGFloat
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .onSurfacePrimary : .onSurfaceTertiary)
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .background(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .fill(isEnabled ? Color.surfacePrimary : Color.surfaceSecondary.opacity(0.9))
- .overlay(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .stroke(isBordered
- ? Color.border
- : isEnabled ? Color.surfacePrimary : Color.surfaceSecondary.opacity(0.9), lineWidth: 1)
- )
- )
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- .shadowElevaton(shadow ? .z2 : .z0)
- }
- }
-
- struct GrayButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- var isBordered: Bool
- var borderLineWidth: CGFloat
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .onBackgroundPrimary : .onBackgroundTertiary)
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .background(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .fill(isEnabled ? Color.surfaceSecondary : Color.surfaceSecondary.opacity(0.9))
- .overlay(
- RoundedRectangle(cornerRadius: rounded == .none ? 0 : rounded == .medium ? ButtonStyleExtended.Constants.radiusM : rounded == .small ? ButtonStyleExtended.Constants.radiusS :
- size == .large ? ButtonStyleExtended.Constants.heightL / 2 : ButtonStyleExtended.Constants.heightM / 2,
- style: .continuous)
- .stroke(isBordered
- ? Color.border
- : isEnabled ? Color.surfaceSecondary : Color.surfaceSecondary.opacity(0.9), lineWidth: 1)
- )
- )
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- .shadowElevaton(shadow ? .z2 : .z0)
- }
- }
-
- struct TextButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .onSurfacePrimary : .onSurfaceTertiary)
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- }
- }
-
- struct LinkButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .accent : Color.accent.opacity(0.7))
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- }
- }
-
- struct DeleteButton: View {
- var size: ButtonSize
- var rounded: ButtonRounded
- var width: ButtonWidth
- var shadow: Bool
- let configuration: ButtonStyle.Configuration
- @Environment(\.isEnabled) private var isEnabled: Bool
- var body: some View {
- configuration.label
- .body(true)
- .padding(.horizontal, Space.small)
- .foregroundColor(isEnabled ? .error : Color.error.opacity(0.7))
- .frame(maxWidth: width == .full ? .infinity : width == .standart ? nil : size == .large ? Constants.heightL : Constants.heightM,
- minHeight: size == .large ? ButtonStyleExtended.Constants.heightL : ButtonStyleExtended.Constants.heightM)
- .opacity(configuration.isPressed ? 0.9 : 1)
- .scaleEffect(configuration.isPressed ? 0.95 : 1)
- }
- }
-}
-
-public extension Button {
- /// Changes the appearance of the button
- @MainActor @available(*, deprecated, message: "Use native buttonStyle", renamed: "buttonStyle")
- func style(_ style: LegacyButtonType) -> some View {
- buttonStyle(ButtonStyleExtended(style: style))
- }
-
- @MainActor @available(*, deprecated, message: "Use native buttonStyle", renamed: "buttonStyle")
- func style(_ style: LegacyButtonType, size: ButtonSize) -> some View {
- buttonStyle(ButtonStyleExtended(style: style, size: size))
- }
-
- @MainActor @available(*, deprecated, message: "Use native buttonStyle", renamed: "buttonStyle")
- func style(_ style: LegacyButtonType, size: ButtonSize, shadow: Bool) -> some View {
- buttonStyle(ButtonStyleExtended(style: style, size: size, shadow: shadow))
- }
-
- @MainActor @available(*, deprecated, message: "Use native buttonStyle", renamed: "buttonStyle")
- func style(_ style: LegacyButtonType, size: ButtonSize, rounded: ButtonRounded, width: ButtonWidth = .standart, shadow: Bool) -> some View {
- buttonStyle(ButtonStyleExtended(style: style, size: size, rounded: rounded, width: width, shadow: shadow))
- }
-}
diff --git a/Sources/OversizeUI/Deprecated/HUDDeprecated.swift b/Sources/OversizeUI/Deprecated/HUDDeprecated.swift
deleted file mode 100644
index c6aab44..0000000
--- a/Sources/OversizeUI/Deprecated/HUDDeprecated.swift
+++ /dev/null
@@ -1,236 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// HUD.swift, created on 26.04.2021
-//
-
-import SwiftUI
-
-public enum HUDType {
- case hud, alert
-}
-
-public class HUDDeprecated: ObservableObject {
- @Published public var isPresented: Bool = false
- public var title: String
- public var icon: IconsNames?
- public var image: Image?
- @Published public var type: HUDType = .hud
-
- public init(title: String = "") {
- self.title = title
- type = .hud
- }
-
- public init(title: String = "", icon: IconsNames) {
- self.title = title
- self.icon = icon
- type = .hud
- }
-
- public init(title: String = "", image: Image) {
- self.title = title
- self.image = image
- type = .alert
- }
-
- public func show(title: String) {
- self.title = title
- type = .hud
- withAnimation {
- isPresented = true
- }
- }
-
- public func show(title: String, icon: IconsNames, type: HUDType = .hud) {
- self.title = title
- self.icon = icon
- self.type = type
- withAnimation {
- isPresented = true
- }
- }
-
- public func show(title: String, image: Image, type: HUDType = .hud) {
- self.title = title
- self.image = image
- self.type = type
- withAnimation {
- isPresented = true
- }
- }
-}
-
-public extension View {
- func hudDeprecated(isPresented: Binding,
- type: Binding,
- @ViewBuilder content: () -> some View) -> some View
- {
- ZStack(alignment: type.wrappedValue == .hud ? .top : .center) {
- self
- // .blur(radius: type.wrappedValue == .alert && isPresented.wrappedValue ? 10 : 0)
-
- if isPresented.wrappedValue {
- HUDSurfaceView(type: type, content: content)
- .transition(
- type.wrappedValue == .hud
- ? AnyTransition.move(edge: .top).combined(with: .opacity)
- : AnyTransition.opacity.animation(.default)
- )
- .onAppear {
- DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
- withAnimation {
- isPresented.wrappedValue = false
- }
- }
- }
- .zIndex(1)
- }
- }
- }
-}
-
-public struct HUDSurfaceView: View {
- public let content: Content
- @Binding public var type: HUDType
-
- public init(type: Binding, @ViewBuilder content: () -> Content) {
- _type = type
- self.content = content()
- }
-
- public var body: some View {
- #if os(iOS)
- if #available(iOS 15.0, *) {
- content
- .padding(.top, topPadding)
- .padding(.horizontal, horizontalPadding)
- .padding(.bottom, bottomPadding)
- .background(backgroundMaterial(type: type),
- in: backgroundShape(type: type))
- .shadowElevaton(type == .hud ? .z2 : .z0)
- } else {
- content
- .padding(.top, topPadding)
- .padding(.horizontal, horizontalPadding)
- .padding(.bottom, bottomPadding)
- .background(background(type: type))
- }
- #else
- content
- .padding(.top, topPadding)
- .padding(.horizontal, horizontalPadding)
- .padding(.bottom, bottomPadding)
- .background(background(type: type))
- #endif
- }
-
- #if os(iOS)
- @available(iOS 15.0, *)
- private func backgroundMaterial(type: HUDType) -> Material {
- switch type {
- case .hud:
- .regular
- case .alert:
- .ultraThinMaterial
- }
- }
- #endif
-
- private func backgroundShape(type: HUDType) -> AnyShape {
- switch type {
- case .hud:
- AnyShape(Capsule())
-
- case .alert:
- AnyShape(RoundedRectangle(cornerRadius: Radius.medium, style: .continuous))
- }
- }
-
- @ViewBuilder
- private func background(type: HUDType) -> some View {
- switch type {
- case .hud:
- Capsule()
- .foregroundColor(Color.surfacePrimary)
- .shadowElevaton(.z2)
- case .alert:
- RoundedRectangle(cornerRadius: 20, style: .continuous)
- .foregroundColor(Color.surfacePrimary)
- .shadowElevaton(.z4)
- }
- }
-
- var horizontalPadding: Space {
- switch type {
- case .hud:
- .medium
- case .alert:
- .medium
- }
- }
-
- var topPadding: Space {
- switch type {
- case .hud:
- .small
- case .alert:
- .xLarge
- }
- }
-
- var bottomPadding: Space {
- switch type {
- case .hud:
- .small
- case .alert:
- .xLarge
- }
- }
-}
-
-public struct HUDContent: View {
- public var title: String
- // public var icon: Icons?
- public var image: Image?
- public var type: HUDType
-
- public init(title: String, image: Image?, type: HUDType = .hud) {
- self.title = title
- self.image = image
- self.type = type
- }
-
- public var body: some View {
- // Text(title)
- // background(background(type: type))
- background
- }
-
- private var background: some View {
- Group {
- switch type {
- case .hud:
- HStack {
-// if let icon = hudState.icon {
-// IconDeprecated(icon, color: .onSurfacePrimary)
-// }
-
- Text(title)
- .body()
- .onSurfacePrimaryForeground()
- }
- case .alert:
- VStack(spacing: .large) {
- if let image {
- image
- }
-
- Text(title)
- .title3()
- .onSurfacePrimaryForeground()
- }
- .frame(minWidth: 225)
- }
- }
- }
-}
diff --git a/Sources/OversizeUI/Deprecated/RowDeprecated.swift b/Sources/OversizeUI/Deprecated/RowDeprecated.swift
deleted file mode 100644
index 564ecb0..0000000
--- a/Sources/OversizeUI/Deprecated/RowDeprecated.swift
+++ /dev/null
@@ -1,270 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// RowDeprecated.swift, created on 11.09.2021
-//
-
-import SwiftUI
-
-public struct RowDeprecated: View {
- @Environment(\.elevation) private var elevation: Elevation
- @Environment(\.controlRadius) var controlRadius: Radius
- @Environment(\.rowContentMargins) var controlPadding: EdgeSpaceInsets
- @Environment(\.multilineTextAlignment) var multilineTextAlignment
- @Environment(\.isPremium) var premiumStatus
- @Environment(\.isAccent) var isAccent
- @Environment(\.isLoading) var isLoading
-
- private let title: String
- private let subtitle: String?
-
- private var leadingType: RowLeadingType?
- private var trallingType: RowTrailingType?
-
- private let action: (() -> Void)?
-
- private var isPremiumOption: Bool = false
- private var isShowArrowIcon: Bool = false
-
- private var iconBackgroundColor: Color?
-
- private var сlearButtonStyle: RowClearIconStyle = .default
- private var сlearAction: (() -> Void)?
-
- private var isShowSubtitle: Bool {
- (subtitle?.isEmpty) != nil
- }
-
- public init(_ title: String,
- subtitle: String? = nil,
- action: (() -> Void)? = nil)
- {
- self.title = title
- self.subtitle = subtitle
- self.action = action
- }
-
- @available(*, deprecated, message: "Use leading: {} and tralling: {}")
- public init(_ title: String,
- subtitle: String? = nil,
- leadingType: RowLeadingType? = nil,
- trallingType: RowTrailingType? = nil,
- paddingHorizontal _: Space = .medium,
- paddingVertical _: Space = .small,
- action: (() -> Void)? = nil)
- {
- self.title = title
- self.subtitle = subtitle
- self.leadingType = leadingType
- self.trallingType = trallingType
- self.action = action
- }
-
- public var body: some View {
- if action != nil {
- Button {
- if isPremiumOption == false || (isPremiumOption && premiumStatus) {
- action?()
- }
- } label: {
- content(multilineTextAlignment)
- }
- .buttonStyle(.row)
- } else {
- content(multilineTextAlignment)
- }
- }
-
- @ViewBuilder
- private func content(_ textAlignment: TextAlignment) -> some View {
- VStack(alignment: .leading) {
- HStack(spacing: .zero) {
- if let leadingType {
- RowLeading(leadingType, isShowSubtitle: isShowSubtitle, iconBackgroundColor: iconBackgroundColor)
- .padding(.trailing, .small)
- }
-
- if textAlignment == .trailing || textAlignment == .center {
- Spacer()
- }
-
- text
-
- premiumLabel
-
- if textAlignment == .leading || textAlignment == .center {
- Spacer()
- }
-
- if isLoading {
- ProgressView()
- .padding(.trailing, .xSmall)
- }
-
- сlearButton
-
- if let trallingType {
- RowTrailing(trallingType, isPremiumOption: isPremiumOption)
- .padding(.leading, .xxSmall)
- }
-
- if isShowArrowIcon {
- IconDeprecated(.chevronRight, color: .onSurfaceTertiary)
- }
- }
- }
- .padding(
- EdgeInsets(top: controlPadding.top,
- leading: controlPadding.leading,
- bottom: controlPadding.bottom,
- trailing: controlPadding.trailing)
- )
- }
-
- private var text: some View {
- VStack(alignment: textAlignment, spacing: .xxxSmall) {
- Text(title)
- .headline(.semibold)
- .foregroundColor(.onSurfacePrimary)
- if let subtitle, !subtitle.isEmpty {
- Text(subtitle)
- .subheadline()
- .foregroundColor(.onSurfaceSecondary)
- }
- }
- .multilineTextAlignment(multilineTextAlignment)
- }
-
- @ViewBuilder
- private var сlearButton: some View {
- if сlearAction != nil {
- Button {
- сlearAction?()
- } label: {
- ZStack {
- IconDeprecated(.xMini, color: .onSurfaceTertiary)
- .background(
- RoundedRectangle(cornerRadius: .small, style: .continuous)
- .fillSurfaceSecondary()
- .opacity(сlearButtonStyle == .onSurface ? 1 : 0)
- )
- }
- }
- }
- }
-
- @ViewBuilder
- private var premiumLabel: some View {
- if isPremiumOption, premiumStatus == false {
- PremiumLabel(text: "Pro", size: .small)
- .padding(.leading, .small)
- }
- }
-
- private var textAlignment: HorizontalAlignment {
- switch multilineTextAlignment {
- case .leading:
- .leading
- case .center:
- .center
- case .trailing:
- .trailing
- }
- }
-}
-
-// MARK: - Modificators
-
-public extension RowDeprecated {
- func premium(_ premium: Bool = true) -> RowDeprecated {
- var control = self
- control.isPremiumOption = premium
- return control
- }
-
- func rowArrow(_ showArrowIcon: Bool = true) -> RowDeprecated {
- var control = self
- control.isShowArrowIcon = showArrowIcon
- return control
- }
-
- func rowIconBackgroundColor(_ color: Color?) -> RowDeprecated {
- var control = self
- control.iconBackgroundColor = color
- return control
- }
-
- func rowClearButton(style: RowClearIconStyle = .default, action: (() -> Void)?) -> RowDeprecated {
- var control = self
- control.сlearButtonStyle = style
- control.сlearAction = action
- return control
- }
-
- @available(*, deprecated, message: "Use leading: {} and tralling: {}")
- func rowLeading(_ leading: RowLeadingType?) -> RowDeprecated {
- var control = self
- control.leadingType = leading
- return control
- }
-
- @available(*, deprecated, message: "Use leading: {} and tralling: {}")
- func rowTrailing(_ trailing: RowTrailingType?) -> RowDeprecated {
- var control = self
- control.trallingType = trailing
- return control
- }
-}
-
-// public extension View {
-// func rowOnSurface(_ elevation: Elevation = .z4, backgroundColor: Color? = nil) -> some View {
-// Surface {
-// self.rowContentInset(.zero)
-// }
-// .surfaceBackgroundColor(backgroundColor)
-// .elevation(elevation)
-// }
-// }
-
-// MARK: - Preview
-
-// swiftlint:disable all
-struct ListRowDeprecated_Previews: PreviewProvider {
- static var previews: some View {
- VStack(spacing: .medium) {
- Row("Title")
-
- Row("Title", subtitle: "Subtitle")
-
- Row("Title", subtitle: "Subtitle") {
- IconDeprecated(.calendar)
- }
-
- Radio(isOn: true, label: {
- Row("Title", subtitle: "Subtitle") {
- IconDeprecated(.calendar)
- }
- })
-
- Checkbox(isOn: .constant(true), label: {
- Row("Title", subtitle: "Subtitle") {
- IconDeprecated(.calendar)
- }
- .rowOnSurface()
- })
-
-// Row("Title", subtitle: "Subtitle")
-// .rowLeading(.avatar(AvatarView(firstName: "Name")))
-// .rowTrailing(.text("Text"))
-
-// Row("Title")
-// .rowTrailing(.toggleWithArrowButton(isOn: .constant(true), action: nil))
-//
-// Row("Title", subtitle: "Subtitle")
-// .rowTrailing(.button("Button", action: {}))
-
- Row("Title", subtitle: "Red")
- .premium()
- }
- .previewLayout(.fixed(width: 375, height: 70))
- }
-}
diff --git a/Sources/OversizeUI/Deprecated/RowLeading.swift b/Sources/OversizeUI/Deprecated/RowLeading.swift
deleted file mode 100644
index 1fc1433..0000000
--- a/Sources/OversizeUI/Deprecated/RowLeading.swift
+++ /dev/null
@@ -1,76 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// RowLeading.swift, created on 23.12.2022
-//
-
-import SwiftUI
-
-public enum RowLeadingType {
- case icon(_ name: IconsNames)
- case iconOnSurface(_ name: IconsNames)
- case image(_ image: Image, color: Color? = .onSurfacePrimary)
- case imageOnSurface(_ image: Image, color: Color? = nil)
- case systemImage(_ imageName: String)
- case avatar(_ avatar: Avatar)
-
- @available(*, deprecated, message: "Use leading: {}")
- case view(_ view: AnyView)
-}
-
-struct RowLeading: View {
- private let type: RowLeadingType
- private let isShowSubtitle: Bool
- private let iconBackgroundColor: Color?
-
- init(_ type: RowLeadingType, isShowSubtitle: Bool = false, iconBackgroundColor: Color? = nil) {
- self.type = type
- self.isShowSubtitle = isShowSubtitle
- self.iconBackgroundColor = iconBackgroundColor
- }
-
- var body: some View {
- switch type {
- case let .icon(icon):
- IconDeprecated(icon)
-
- case let .image(image, color):
- image
- .renderingMode(color != nil ? .template : .original)
- .resizable()
- .scaledToFill()
- .foregroundColor(color)
- .frame(width: isShowSubtitle ? 48 : 24, height: isShowSubtitle ? 48 : 24)
- .cornerRadius(isShowSubtitle ? 4 : 2)
-
- case let .avatar(avatar):
- avatar
-
- case let .iconOnSurface(icon):
- Surface {
- IconDeprecated(icon)
- }
- .surfaceStyle(.secondary)
- .surfaceBackgroundColor(iconBackgroundColor)
- .surfaceContentMargins(.xxSmall)
-
- case let .imageOnSurface(image, color):
- Surface {
- image
- .renderingMode(.template)
- .foregroundColor(color)
- }
- .surfaceStyle(.secondary)
- .surfaceBackgroundColor(iconBackgroundColor)
- .surfaceContentMargins(.xxSmall)
-
- case let .systemImage(systemImage):
- Image(systemName: systemImage)
- .foregroundColor(Color.onBackgroundPrimary)
- .font(.system(size: 24))
- .frame(width: 24, height: 24, alignment: .center)
-
- case let .view(view):
- view
- }
- }
-}
diff --git a/Sources/OversizeUI/Deprecated/RowTrailing.swift b/Sources/OversizeUI/Deprecated/RowTrailing.swift
deleted file mode 100644
index dfc60dc..0000000
--- a/Sources/OversizeUI/Deprecated/RowTrailing.swift
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// RowTrailing.swift, created on 23.12.2022
-//
-
-import SwiftUI
-
-import SwiftUI
-
-public enum RowTrailingType {
- @available(*, deprecated, message: "Use Radio")
- case radio(isOn: Binding)
- @available(*, deprecated, message: "Use Checkbox")
- case checkbox(isOn: Binding)
- @available(*, deprecated, message: "Use Toogle")
- case toggle(isOn: Binding)
- @available(*, deprecated, message: "Use Toogle")
- case toggleWithArrowButton(isOn: Binding, action: (() -> Void)? = nil)
- @available(watchOS, unavailable)
- case timePicker(date: Binding)
- case arrowIcon
- case text(_ text: String)
- @available(tvOS, unavailable)
- case button(_ text: String, action: () -> Void)
-}
-
-struct RowTrailing: View {
- @Environment(\.isPremium) var premiumStatus
-
- private let type: RowTrailingType
- private let isPremiumOption: Bool
-
- init(_ type: RowTrailingType, isPremiumOption: Bool = false) {
- self.type = type
- self.isPremiumOption = isPremiumOption
- }
-
- // swiftlint:disable function_body_length
- var body: some View {
- switch type {
- case let .toggle(isOn):
- Toggle(isOn: isOn) {}
- .labelsHidden()
- .disabled(isPremiumOption && premiumStatus == false)
-
- case let .radio(isOn: isOn):
- ZStack {
- Circle()
- .stroke(Color.onSurfaceTertiary, lineWidth: 4)
- .frame(width: 24, height: 24)
- .cornerRadius(12)
- .opacity(isOn.wrappedValue ? 0 : 1)
-
- Circle().fill(Color.accent)
- .frame(width: 24, height: 24)
- .cornerRadius(12)
- .opacity(isOn.wrappedValue ? 1 : 0)
-
- Circle().fill(Color.white).frame(width: 8, height: 8)
- .cornerRadius(4)
- .opacity(isOn.wrappedValue ? 1 : 0)
- }
-
- case let .checkbox(isOn: isOn):
- ZStack {
- RoundedRectangle(cornerRadius: Radius.small, style: .continuous)
- .strokeBorder(Color.onSurfaceTertiary, lineWidth: 2.5)
- .frame(width: 24, height: 24)
- .opacity(isOn.wrappedValue ? 0 : 1)
-
- RoundedRectangle(cornerRadius: Radius.small, style: .continuous).fill(Color.accent)
- .frame(width: 24, height: 24)
- .opacity(isOn.wrappedValue ? 1 : 0)
-
- Image(systemName: "checkmark")
- .font(.caption.weight(.black))
- .foregroundColor(.onPrimary)
- .opacity(isOn.wrappedValue ? 1 : 0)
- }
-
- case let .toggleWithArrowButton(isOn: isOn, action: action):
- HStack {
- Toggle(isOn: isOn) {}
- .labelsHidden()
-
- Button(action: action ?? {}, label: {
- IconDeprecated(.chevronRight, color: .onSurfaceTertiary)
- })
- }
- .disabled(isPremiumOption && premiumStatus == false)
-
- case .arrowIcon:
- IconDeprecated(.chevronRight, color: .onSurfaceTertiary)
-
- case let .timePicker(date: date):
- #if os(watchOS)
- EmptyView()
- #elseif os(iOS)
- DatePicker("", selection: date, displayedComponents: .hourAndMinute)
- .labelsHidden()
- #endif
- case let .text(text):
- Text(text)
- .subheadline()
- .foregroundColor(.onSurfaceSecondary)
-
- case let .button(text, action: action):
- #if os(tvOS)
- EmptyView()
- #else
- Button(text, action: action)
- .buttonStyle(.tertiary)
- .controlBorderShape(.capsule)
- .controlSize(.small)
- .disabled(isPremiumOption && premiumStatus == false)
- #endif
- }
- }
-}
diff --git a/Sources/OversizeUI/Extensions/View/View+NavigationView.swift b/Sources/OversizeUI/Deprecated/View+NavigationView.swift
similarity index 100%
rename from Sources/OversizeUI/Extensions/View/View+NavigationView.swift
rename to Sources/OversizeUI/Deprecated/View+NavigationView.swift
diff --git a/Sources/OversizeUI/Deprecated/View+ScrollViewOffset.swift b/Sources/OversizeUI/Deprecated/View+ScrollViewOffset.swift
deleted file mode 100644
index 95dcaff..0000000
--- a/Sources/OversizeUI/Deprecated/View+ScrollViewOffset.swift
+++ /dev/null
@@ -1,18 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// View+ScrollViewOffset.swift, created on 22.03.2022
-//
-
-import SwiftUI
-
-public extension View {
- func scrollOffset(name: String = "", onChange: @escaping (CGFloat) -> Void) -> some View {
- overlay(
- GeometryReader {
- Color.clear
- .preference(key: ViewOffsetKey.self,
- value: -$0.frame(in: name == "" ? .global : .named(name)).origin.y)
- })
- .onPreferenceChange(ViewOffsetKey.self, perform: onChange)
- }
-}
diff --git a/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift b/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift
deleted file mode 100644
index d46c314..0000000
--- a/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// ViewOffsetKey.swift, created on 22.03.2022
-//
-
-import SwiftUI
-
-public struct ViewOffsetKey: PreferenceKey {
- public static let defaultValue = CGFloat.zero
- public static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
- value += nextValue()
- }
-}
diff --git a/Sources/OversizeUI/Extensions/View/View+Navigationable.swift b/Sources/OversizeUI/Extensions/View/View+Navigationable.swift
deleted file mode 100644
index 3af643c..0000000
--- a/Sources/OversizeUI/Extensions/View/View+Navigationable.swift
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// Copyright © 2021 Alexander Romanov
-// View+Navigationable.swift, created on 14.04.2022
-//
-
-import SwiftUI
-
-public extension View {
- @available(macOS, unavailable)
- @available(watchOS, unavailable)
- @available(tvOS, unavailable)
- func navigationable(_ navigationBarHidden: Bool = true) -> some View {
- NavigationView {
- self
- #if os(iOS)
- .navigationBarHidden(navigationBarHidden)
- #endif
- }
- }
-}