diff --git a/DSKit/Sources/DSKit/Appearances/DSKitAppearance.swift b/DSKit/Sources/DSKit/Appearances/DSKitAppearance.swift index 8a4207e..d1f7356 100644 --- a/DSKit/Sources/DSKit/Appearances/DSKitAppearance.swift +++ b/DSKit/Sources/DSKit/Appearances/DSKitAppearance.swift @@ -8,7 +8,7 @@ import UIKit -public struct DSKitAppearance: DSAppearance { +public struct LightBlueAppearance: DSAppearance { public var title: String public var primaryView: DSViewAppearanceProtocol @@ -27,7 +27,7 @@ public struct DSKitAppearance: DSAppearance { /// - Parameter brandColor: UIColor public init(brandColor: UIColor? = nil) { - self.title = "DSKit" + self.title = "Light Blue" // MARK: - Primary view diff --git a/DSKit/Sources/DSKit/Appearances/DarkAppearance.swift b/DSKit/Sources/DSKit/Appearances/DarkAppearance.swift index aadf5a9..309d56f 100644 --- a/DSKit/Sources/DSKit/Appearances/DarkAppearance.swift +++ b/DSKit/Sources/DSKit/Appearances/DarkAppearance.swift @@ -18,7 +18,7 @@ public class DarkAppearance: DSAppearance { public var tabBar: DSTabBarAppearanceProtocol public var navigationBar: DSNavigationBarAppearanceProtocol public var price: DSPriceAppearanceProtocol - public var fonts: DSFontsProtocol = DSFonts() + public var fonts: DSFontsProtocol = DSVerdanaFont() public var actionElementHeight: CGFloat = 44 public var screenMargins: CGFloat = 16 diff --git a/DSKit/Sources/DSKit/Appearances/PeachAppearance.swift b/DSKit/Sources/DSKit/Appearances/PeachAppearance.swift index 9b87856..44458ae 100644 --- a/DSKit/Sources/DSKit/Appearances/PeachAppearance.swift +++ b/DSKit/Sources/DSKit/Appearances/PeachAppearance.swift @@ -20,7 +20,7 @@ public class PeachAppearance: DSAppearance { public var tabBar: DSTabBarAppearanceProtocol public var navigationBar: DSNavigationBarAppearanceProtocol public var price: DSPriceAppearanceProtocol - public var fonts: DSFontsProtocol = DSFonts() + public var fonts: DSFontsProtocol = DSHelveticaNeueFont() public var actionElementHeight: CGFloat = 48 public var screenMargins: CGFloat = 16 diff --git a/DSKit/Sources/DSKit/Appearances/RetroAppearance.swift b/DSKit/Sources/DSKit/Appearances/RetroAppearance.swift index 899a152..ca3eabe 100644 --- a/DSKit/Sources/DSKit/Appearances/RetroAppearance.swift +++ b/DSKit/Sources/DSKit/Appearances/RetroAppearance.swift @@ -21,7 +21,7 @@ public final class RetroAppearance: DSAppearance { public var tabBar: DSTabBarAppearanceProtocol public var navigationBar: DSNavigationBarAppearanceProtocol public var price: DSPriceAppearanceProtocol - public var fonts: DSFontsProtocol = DSRetroFont() + public var fonts: DSFontsProtocol = DSFuturaFont() public var actionElementHeight: CGFloat = 45 public var screenMargins: CGFloat = 16 diff --git a/DSKit/Sources/DSKit/Designable/DSAppearance.swift b/DSKit/Sources/DSKit/Designable/DSAppearance.swift index 2dd22eb..0d30cdd 100644 --- a/DSKit/Sources/DSKit/Designable/DSAppearance.swift +++ b/DSKit/Sources/DSKit/Designable/DSAppearance.swift @@ -10,7 +10,7 @@ import SwiftUI import UIKit struct AppearanceEnvironment: EnvironmentKey { - static let defaultValue: DSAppearance = DSKitAppearance() + static let defaultValue: DSAppearance = LightBlueAppearance() } public extension EnvironmentValues { diff --git a/DSKit/Sources/DSKit/Fonts/RetroFont.swift b/DSKit/Sources/DSKit/Fonts/DSFuturaFont.swift similarity index 97% rename from DSKit/Sources/DSKit/Fonts/RetroFont.swift rename to DSKit/Sources/DSKit/Fonts/DSFuturaFont.swift index e8889ca..3fdcf4e 100644 --- a/DSKit/Sources/DSKit/Fonts/RetroFont.swift +++ b/DSKit/Sources/DSKit/Fonts/DSFuturaFont.swift @@ -7,7 +7,7 @@ import UIKit -public class DSRetroFont: DSFontsProtocol { +public class DSFuturaFont: DSFontsProtocol { public var body: UIFont { return regularFont(size: 17.0) } diff --git a/DSKit/Sources/DSKit/Fonts/DSHelveticaNeueFont.swift b/DSKit/Sources/DSKit/Fonts/DSHelveticaNeueFont.swift new file mode 100644 index 0000000..95b332e --- /dev/null +++ b/DSKit/Sources/DSKit/Fonts/DSHelveticaNeueFont.swift @@ -0,0 +1,69 @@ +// +// RetroFont.swift +// DSKit +// +// Created by Ivan Borinschi on 21.05.2024. +// + +import UIKit + +public class DSHelveticaNeueFont: DSFontsProtocol { + public var body: UIFont { + return regularFont(size: 17.0) + } + + public var callout: UIFont { + return regularFont(size: 16.0) + } + + public var caption1: UIFont { + return regularFont(size: 12.0) + } + + public var caption2: UIFont { + return regularFont(size: 11.0) + } + + public var footnote: UIFont { + return regularFont(size: 13.0) + } + + public var headline: UIFont { + return bolfFont(size: 17.0) + } + + public var subheadline: UIFont { + return regularFont(size: 15.0) + } + + public var largeTitle: UIFont { + return regularFont(size: 34.0) + } + + public var title1: UIFont { + return regularFont(size: 28.0) + } + + public var title2: UIFont { + return regularFont(size: 22.0) + } + + public var title3: UIFont { + return regularFont(size: 20.0) + } + + public init() {} + + private func regularFont(size: CGFloat) -> UIFont { + scaledFont(for: "HelveticaNeue", textStyle: .body, defaultSize: size) + } + + private func bolfFont(size: CGFloat) -> UIFont { + scaledFont(for: "HelveticaNeue-Bold", textStyle: .body, defaultSize: size) + } + + private func scaledFont(for fontName: String, textStyle: UIFont.TextStyle, defaultSize: CGFloat) -> UIFont { + let font = UIFont(name: fontName, size: defaultSize) ?? UIFont(name: "Georgia", size: defaultSize) ?? UIFont.systemFont(ofSize: defaultSize) + return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: font) + } +} diff --git a/DSKit/Sources/DSKit/Fonts/DSVerdanaFont.swift b/DSKit/Sources/DSKit/Fonts/DSVerdanaFont.swift new file mode 100644 index 0000000..d83bd2b --- /dev/null +++ b/DSKit/Sources/DSKit/Fonts/DSVerdanaFont.swift @@ -0,0 +1,69 @@ +// +// RetroFont.swift +// DSKit +// +// Created by Ivan Borinschi on 21.05.2024. +// + +import UIKit + +public class DSVerdanaFont: DSFontsProtocol { + public var body: UIFont { + return regularFont(size: 17.0) + } + + public var callout: UIFont { + return regularFont(size: 16.0) + } + + public var caption1: UIFont { + return regularFont(size: 12.0) + } + + public var caption2: UIFont { + return regularFont(size: 11.0) + } + + public var footnote: UIFont { + return regularFont(size: 13.0) + } + + public var headline: UIFont { + return bolfFont(size: 17.0) + } + + public var subheadline: UIFont { + return regularFont(size: 15.0) + } + + public var largeTitle: UIFont { + return regularFont(size: 34.0) + } + + public var title1: UIFont { + return regularFont(size: 28.0) + } + + public var title2: UIFont { + return regularFont(size: 22.0) + } + + public var title3: UIFont { + return regularFont(size: 20.0) + } + + public init() {} + + private func regularFont(size: CGFloat) -> UIFont { + scaledFont(for: "Verdana", textStyle: .body, defaultSize: size) + } + + private func bolfFont(size: CGFloat) -> UIFont { + scaledFont(for: "Verdana-Bold", textStyle: .body, defaultSize: size) + } + + private func scaledFont(for fontName: String, textStyle: UIFont.TextStyle, defaultSize: CGFloat) -> UIFont { + let font = UIFont(name: fontName, size: defaultSize) ?? UIFont(name: "Georgia", size: defaultSize) ?? UIFont.systemFont(ofSize: defaultSize) + return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: font) + } +} diff --git a/DSKit/Sources/DSKit/Modifiers/DSPreviewForEachAppearance.swift b/DSKit/Sources/DSKit/Modifiers/DSPreviewForEachAppearance.swift index 3496c9e..765c1a0 100644 --- a/DSKit/Sources/DSKit/Modifiers/DSPreviewForEachAppearance.swift +++ b/DSKit/Sources/DSKit/Modifiers/DSPreviewForEachAppearance.swift @@ -29,7 +29,7 @@ public struct DSPreviewForEachAppearance: View { } fileprivate let appearances: [(title: String, appearance: DSAppearance)] = [ - ("DSKit", DSKitAppearance()), + ("Light Blue", LightBlueAppearance()), ("Dark", DarkAppearance()), ("Blue", BlueAppearance()), ("Retro", RetroAppearance()), diff --git a/DSKitExplorer.xcodeproj/project.pbxproj b/DSKitExplorer.xcodeproj/project.pbxproj index 1478ec4..05ff3e4 100644 --- a/DSKitExplorer.xcodeproj/project.pbxproj +++ b/DSKitExplorer.xcodeproj/project.pbxproj @@ -171,7 +171,9 @@ 60D46A092BCAF16600A6F7FC /* DSKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60D46A082BCAF16600A6F7FC /* DSKitTests.swift */; }; 60D46A192BCAF25A00A6F7FC /* AssertSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60D46A182BCAF25A00A6F7FC /* AssertSnapshot.swift */; }; 60D46A1B2BCAF29600A6F7FC /* AssertSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60D46A1A2BCAF29600A6F7FC /* AssertSnapshot.swift */; }; - 90FB4ACE2BFCB1FE008178DF /* RetroFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90FB4ACC2BFCB1FE008178DF /* RetroFont.swift */; }; + 90FB4ACE2BFCB1FE008178DF /* DSFuturaFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90FB4ACC2BFCB1FE008178DF /* DSFuturaFont.swift */; }; + 90FB4AD02BFCDD20008178DF /* DSHelveticaNeueFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90FB4ACF2BFCDD20008178DF /* DSHelveticaNeueFont.swift */; }; + 90FB4AD22BFCDECD008178DF /* DSVerdanaFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90FB4AD12BFCDECD008178DF /* DSVerdanaFont.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -390,7 +392,9 @@ 60D46A082BCAF16600A6F7FC /* DSKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSKitTests.swift; sourceTree = ""; }; 60D46A182BCAF25A00A6F7FC /* AssertSnapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssertSnapshot.swift; sourceTree = ""; }; 60D46A1A2BCAF29600A6F7FC /* AssertSnapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssertSnapshot.swift; sourceTree = ""; }; - 90FB4ACC2BFCB1FE008178DF /* RetroFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RetroFont.swift; sourceTree = ""; }; + 90FB4ACC2BFCB1FE008178DF /* DSFuturaFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSFuturaFont.swift; sourceTree = ""; }; + 90FB4ACF2BFCDD20008178DF /* DSHelveticaNeueFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSHelveticaNeueFont.swift; sourceTree = ""; }; + 90FB4AD12BFCDECD008178DF /* DSVerdanaFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSVerdanaFont.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -719,7 +723,9 @@ 90FB4ACD2BFCB1FE008178DF /* Fonts */ = { isa = PBXGroup; children = ( - 90FB4ACC2BFCB1FE008178DF /* RetroFont.swift */, + 90FB4ACC2BFCB1FE008178DF /* DSFuturaFont.swift */, + 90FB4ACF2BFCDD20008178DF /* DSHelveticaNeueFont.swift */, + 90FB4AD12BFCDECD008178DF /* DSVerdanaFont.swift */, ); name = Fonts; path = Sources/DSKit/Fonts; @@ -943,6 +949,7 @@ 604EEDDB2BD23E1B009E3278 /* DSSHadowModifier.swift in Sources */, 604EEE0A2BD23E1B009E3278 /* DSBottomContainer.swift in Sources */, 604EEE0C2BD23E1B009E3278 /* DSChevronView.swift in Sources */, + 90FB4AD22BFCDECD008178DF /* DSVerdanaFont.swift in Sources */, 604EEDD22BD23E1B009E3278 /* DSKeyboardAwareModifier.swift in Sources */, 604EEE172BD23E1B009E3278 /* DSQuantityPicker.swift in Sources */, 604EEDD12BD23E1B009E3278 /* DSHideKeyboardWhenTappedModifier.swift in Sources */, @@ -957,7 +964,7 @@ 604EEE0B2BD23E1B009E3278 /* DSButton.swift in Sources */, 604EEDE22BD23E1B009E3278 /* UIColor+Conveniences.swift in Sources */, 604EEDD02BD23E1B009E3278 /* DSHeightModifier.swift in Sources */, - 90FB4ACE2BFCB1FE008178DF /* RetroFont.swift in Sources */, + 90FB4ACE2BFCB1FE008178DF /* DSFuturaFont.swift in Sources */, 604EEDFA2BD23E1B009E3278 /* DSKitAppearance.swift in Sources */, 604EEE152BD23E1B009E3278 /* DSPreview.swift in Sources */, 604EEE122BD23E1B009E3278 /* DSHScroll.swift in Sources */, @@ -982,6 +989,7 @@ 604EEDDE2BD23E1B009E3278 /* DSWidthModifier.swift in Sources */, 604EEDF62BD23E1B009E3278 /* DSViewAppearance.swift in Sources */, 604EEE1C2BD23E1B009E3278 /* DSSFSymbolButton.swift in Sources */, + 90FB4AD02BFCDD20008178DF /* DSHelveticaNeueFont.swift in Sources */, 604EEE022BD23E1B009E3278 /* DSTextfieldValidator.swift in Sources */, 604EEDD62BD23E1B009E3278 /* DSPreviewForEachAppearance.swift in Sources */, 604EEDF02BD23E1B009E3278 /* DSSize.swift in Sources */, diff --git a/DSKitExplorer/AppearanceSelectionView.swift b/DSKitExplorer/AppearanceSelectionView.swift index d93258b..44d362b 100644 --- a/DSKitExplorer/AppearanceSelectionView.swift +++ b/DSKitExplorer/AppearanceSelectionView.swift @@ -79,7 +79,7 @@ struct IdentifiableDesignable: Identifiable { } fileprivate let appearances: [DSAppearance] = [ - DSKitAppearance(), + LightBlueAppearance(), DarkAppearance(), BlueAppearance(), RetroAppearance(), diff --git a/DSKitExplorer/ScreensView.swift b/DSKitExplorer/ScreensView.swift index 1e18df4..d524226 100644 --- a/DSKitExplorer/ScreensView.swift +++ b/DSKitExplorer/ScreensView.swift @@ -57,5 +57,5 @@ fileprivate struct CustomActionView: View { } #Preview { - ScreensView(appearance: DSKitAppearance()) + ScreensView(appearance: LightBlueAppearance()) } diff --git a/DSKitExplorerTests/AssertSnapshot.swift b/DSKitExplorerTests/AssertSnapshot.swift index 46be1d9..3192ed5 100644 --- a/DSKitExplorerTests/AssertSnapshot.swift +++ b/DSKitExplorerTests/AssertSnapshot.swift @@ -36,7 +36,7 @@ extension XCTestCase { .safeAreaInset(edge: .bottom) { Spacer().frame(height: 34) } - }.dsAppearance(DSKitAppearance()) + }.dsAppearance(LightBlueAppearance()) SnapshotTesting.assertSnapshot( of: testView, @@ -63,7 +63,7 @@ extension XCTestCase { } fileprivate let appearances: [(title: String, appearance: DSAppearance)] = [ - ("DSKit", DSKitAppearance()), + ("Light Blue", LightBlueAppearance()), ("Blue", BlueAppearance()), ("Dark", DarkAppearance()), ("Retro", RetroAppearance()),