Skip to content

Commit

Permalink
Update appearances
Browse files Browse the repository at this point in the history
  • Loading branch information
imodeveloper committed May 21, 2024
1 parent 8ccac93 commit d741043
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 16 deletions.
4 changes: 2 additions & 2 deletions DSKit/Sources/DSKit/Appearances/DSKitAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public struct DSKitAppearance: DSAppearance {
public struct LightBlueAppearance: DSAppearance {

public var title: String
public var primaryView: DSViewAppearanceProtocol
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DSKit/Sources/DSKit/Appearances/DarkAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DSKit/Sources/DSKit/Appearances/PeachAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DSKit/Sources/DSKit/Appearances/RetroAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DSKit/Sources/DSKit/Designable/DSAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import UIKit

struct AppearanceEnvironment: EnvironmentKey {
static let defaultValue: DSAppearance = DSKitAppearance()
static let defaultValue: DSAppearance = LightBlueAppearance()
}

public extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

public class DSRetroFont: DSFontsProtocol {
public class DSFuturaFont: DSFontsProtocol {
public var body: UIFont {
return regularFont(size: 17.0)
}
Expand Down
69 changes: 69 additions & 0 deletions DSKit/Sources/DSKit/Fonts/DSHelveticaNeueFont.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
69 changes: 69 additions & 0 deletions DSKit/Sources/DSKit/Fonts/DSVerdanaFont.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct DSPreviewForEachAppearance<Content: View>: View {
}

fileprivate let appearances: [(title: String, appearance: DSAppearance)] = [
("DSKit", DSKitAppearance()),
("Light Blue", LightBlueAppearance()),
("Dark", DarkAppearance()),
("Blue", BlueAppearance()),
("Retro", RetroAppearance()),
Expand Down
16 changes: 12 additions & 4 deletions DSKitExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -390,7 +392,9 @@
60D46A082BCAF16600A6F7FC /* DSKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSKitTests.swift; sourceTree = "<group>"; };
60D46A182BCAF25A00A6F7FC /* AssertSnapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssertSnapshot.swift; sourceTree = "<group>"; };
60D46A1A2BCAF29600A6F7FC /* AssertSnapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssertSnapshot.swift; sourceTree = "<group>"; };
90FB4ACC2BFCB1FE008178DF /* RetroFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RetroFont.swift; sourceTree = "<group>"; };
90FB4ACC2BFCB1FE008178DF /* DSFuturaFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSFuturaFont.swift; sourceTree = "<group>"; };
90FB4ACF2BFCDD20008178DF /* DSHelveticaNeueFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSHelveticaNeueFont.swift; sourceTree = "<group>"; };
90FB4AD12BFCDECD008178DF /* DSVerdanaFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSVerdanaFont.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand All @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/AppearanceSelectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct IdentifiableDesignable: Identifiable {
}

fileprivate let appearances: [DSAppearance] = [
DSKitAppearance(),
LightBlueAppearance(),
DarkAppearance(),
BlueAppearance(),
RetroAppearance(),
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/ScreensView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ fileprivate struct CustomActionView: View {
}

#Preview {
ScreensView(appearance: DSKitAppearance())
ScreensView(appearance: LightBlueAppearance())
}
4 changes: 2 additions & 2 deletions DSKitExplorerTests/AssertSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension XCTestCase {
.safeAreaInset(edge: .bottom) {
Spacer().frame(height: 34)
}
}.dsAppearance(DSKitAppearance())
}.dsAppearance(LightBlueAppearance())

SnapshotTesting.assertSnapshot(
of: testView,
Expand All @@ -63,7 +63,7 @@ extension XCTestCase {
}

fileprivate let appearances: [(title: String, appearance: DSAppearance)] = [
("DSKit", DSKitAppearance()),
("Light Blue", LightBlueAppearance()),
("Blue", BlueAppearance()),
("Dark", DarkAppearance()),
("Retro", RetroAppearance()),
Expand Down

0 comments on commit d741043

Please sign in to comment.