Skip to content

Commit

Permalink
Add retro appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
imodeveloper committed May 21, 2024
1 parent e56c9cc commit 8ccac93
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
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 = DSFonts()
public var fonts: DSFontsProtocol = DSRetroFont()
public var actionElementHeight: CGFloat = 45
public var screenMargins: CGFloat = 16

Expand Down
69 changes: 69 additions & 0 deletions DSKit/Sources/DSKit/Fonts/RetroFont.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 DSRetroFont: 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: "Futura-Medium", textStyle: .body, defaultSize: size)
}

private func bolfFont(size: CGFloat) -> UIFont {
scaledFont(for: "Futura-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.systemFont(ofSize: defaultSize)
return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: font)
}
}
13 changes: 13 additions & 0 deletions DSKitExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
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 */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -389,6 +390,7 @@
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>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -434,6 +436,7 @@
604EED492BD23BE9009E3278 /* DSKit */ = {
isa = PBXGroup;
children = (
90FB4ACD2BFCB1FE008178DF /* Fonts */,
604EEDA02BD23E1A009E3278 /* Appearances */,
604EED982BD23E1A009E3278 /* Designable */,
604EED812BD23E1A009E3278 /* Helpers */,
Expand Down Expand Up @@ -713,6 +716,15 @@
name = Frameworks;
sourceTree = "<group>";
};
90FB4ACD2BFCB1FE008178DF /* Fonts */ = {
isa = PBXGroup;
children = (
90FB4ACC2BFCB1FE008178DF /* RetroFont.swift */,
);
name = Fonts;
path = Sources/DSKit/Fonts;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -945,6 +957,7 @@
604EEE0B2BD23E1B009E3278 /* DSButton.swift in Sources */,
604EEDE22BD23E1B009E3278 /* UIColor+Conveniences.swift in Sources */,
604EEDD02BD23E1B009E3278 /* DSHeightModifier.swift in Sources */,
90FB4ACE2BFCB1FE008178DF /* RetroFont.swift in Sources */,
604EEDFA2BD23E1B009E3278 /* DSKitAppearance.swift in Sources */,
604EEE152BD23E1B009E3278 /* DSPreview.swift in Sources */,
604EEE122BD23E1B009E3278 /* DSHScroll.swift in Sources */,
Expand Down

0 comments on commit 8ccac93

Please sign in to comment.