-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notifications Refresh (Phase 1) (#22524)
- Loading branch information
Showing
65 changed files
with
2,258 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 2 additions & 59 deletions
61
Modules/Sources/DesignSystem/Components/Modifiers/Text+DesignSystem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,11 @@ | ||
import SwiftUI | ||
|
||
// MARK: - SwiftUI.Font: TextStyle | ||
extension TextStyle { | ||
var font: Font { | ||
switch self { | ||
case .heading1: | ||
return Font.DS.heading1 | ||
|
||
case .heading2: | ||
return Font.DS.heading2 | ||
|
||
case .heading3: | ||
return Font.DS.heading3 | ||
|
||
case .heading4: | ||
return Font.DS.heading4 | ||
|
||
case .bodySmall(let weight): | ||
switch weight { | ||
case .regular: | ||
return Font.DS.Body.small | ||
case .emphasized: | ||
return Font.DS.Body.Emphasized.small | ||
} | ||
|
||
case .bodyMedium(let weight): | ||
switch weight { | ||
case .regular: | ||
return Font.DS.Body.medium | ||
case .emphasized: | ||
return Font.DS.Body.Emphasized.medium | ||
} | ||
|
||
case .bodyLarge(let weight): | ||
switch weight { | ||
case .regular: | ||
return Font.DS.Body.large | ||
case .emphasized: | ||
return Font.DS.Body.Emphasized.large | ||
} | ||
|
||
case .footnote: | ||
return Font.DS.footnote | ||
|
||
case .caption: | ||
return Font.DS.caption | ||
} | ||
} | ||
|
||
var `case`: Text.Case? { | ||
switch self { | ||
case .caption: | ||
return .uppercase | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
// MARK: - SwiftUI.Text | ||
public extension Text { | ||
@ViewBuilder | ||
func style(_ style: TextStyle) -> some View { | ||
self.font(style.font) | ||
let font = Font.DS.font(style) | ||
self.font(font) | ||
.textCase(style.case) | ||
} | ||
} |
111 changes: 4 additions & 107 deletions
111
Modules/Sources/DesignSystem/Components/Modifiers/UILabel+DesignSystem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,11 @@ | ||
import UIKit | ||
|
||
// MARK: - UIKit.UIFont: TextStyle | ||
public extension TextStyle { | ||
var uiFont: UIFont { | ||
switch self { | ||
case .heading1: | ||
return UIFont.DS.heading1 | ||
|
||
case .heading2: | ||
return UIFont.DS.heading2 | ||
|
||
case .heading3: | ||
return UIFont.DS.heading3 | ||
|
||
case .heading4: | ||
return UIFont.DS.heading4 | ||
|
||
case .bodySmall(let weight): | ||
switch weight { | ||
case .regular: | ||
return UIFont.DS.Body.small | ||
case .emphasized: | ||
return UIFont.DS.Body.Emphasized.small | ||
} | ||
|
||
case .bodyMedium(let weight): | ||
switch weight { | ||
case .regular: | ||
return UIFont.DS.Body.medium | ||
case .emphasized: | ||
return UIFont.DS.Body.Emphasized.medium | ||
} | ||
|
||
case .bodyLarge(let weight): | ||
switch weight { | ||
case .regular: | ||
return UIFont.DS.Body.large | ||
case .emphasized: | ||
return UIFont.DS.Body.Emphasized.large | ||
} | ||
|
||
case .footnote: | ||
return UIFont.DS.footnote | ||
|
||
case .caption: | ||
return UIFont.DS.caption | ||
} | ||
} | ||
} | ||
|
||
// MARK: - SwiftUI.Text | ||
public extension UILabel { | ||
func setStyle(_ style: TextStyle) { | ||
self.font = style.uiFont | ||
extension UILabel { | ||
func style(_ style: TextStyle) -> Self { | ||
self.font = UIFont.DS.font(style) | ||
if style.case == .uppercase { | ||
self.text = self.text?.uppercased() | ||
} | ||
} | ||
} | ||
|
||
// MARK: - UIKit.UIFont | ||
fileprivate extension UIFont { | ||
enum DS { | ||
static let heading1 = DynamicFontHelper.fontForTextStyle(.largeTitle, fontWeight: .bold) | ||
static let heading2 = DynamicFontHelper.fontForTextStyle(.title1, fontWeight: .bold) | ||
static let heading3 = DynamicFontHelper.fontForTextStyle(.title2, fontWeight: .bold) | ||
static let heading4 = DynamicFontHelper.fontForTextStyle(.title3, fontWeight: .semibold) | ||
|
||
enum Body { | ||
static let small = DynamicFontHelper.fontForTextStyle(.subheadline, fontWeight: .regular) | ||
static let medium = DynamicFontHelper.fontForTextStyle(.callout, fontWeight: .regular) | ||
static let large = DynamicFontHelper.fontForTextStyle(.body, fontWeight: .regular) | ||
|
||
enum Emphasized { | ||
static let small = DynamicFontHelper.fontForTextStyle(.subheadline, fontWeight: .semibold) | ||
static let medium = DynamicFontHelper.fontForTextStyle(.callout, fontWeight: .semibold) | ||
static let large = DynamicFontHelper.fontForTextStyle(.body, fontWeight: .semibold) | ||
} | ||
} | ||
|
||
static let footnote = DynamicFontHelper.fontForTextStyle(.footnote, fontWeight: .regular) | ||
static let caption = DynamicFontHelper.fontForTextStyle(.caption1, fontWeight: .regular) | ||
} | ||
} | ||
|
||
private enum DynamicFontHelper { | ||
static func fontForTextStyle(_ style: UIFont.TextStyle, fontWeight weight: UIFont.Weight) -> UIFont { | ||
/// WORKAROUND: Some font weights scale up well initially but they don't scale up well if dynamic type | ||
/// is changed in real time. Creating a scaled font offers an alternative solution that works well | ||
/// even in real time. | ||
let weightsThatNeedScaledFont: [UIFont.Weight] = [.black, .bold, .heavy, .semibold] | ||
|
||
guard !weightsThatNeedScaledFont.contains(weight) else { | ||
return scaledFont(for: style, weight: weight) | ||
} | ||
|
||
var fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style) | ||
|
||
let traits = [UIFontDescriptor.TraitKey.weight: weight] | ||
fontDescriptor = fontDescriptor.addingAttributes([.traits: traits]) | ||
|
||
return UIFont(descriptor: fontDescriptor, size: CGFloat(0.0)) | ||
} | ||
|
||
static func scaledFont(for style: UIFont.TextStyle, weight: UIFont.Weight, design: UIFontDescriptor.SystemDesign = .default) -> UIFont { | ||
let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style) | ||
let fontDescriptorWithDesign = fontDescriptor.withDesign(design) ?? fontDescriptor | ||
let traits = [UIFontDescriptor.TraitKey.weight: weight] | ||
let finalDescriptor = fontDescriptorWithDesign.addingAttributes([.traits: traits]) | ||
|
||
return UIFont(descriptor: finalDescriptor, size: finalDescriptor.pointSize) | ||
return self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import UIKit | ||
import SwiftUI | ||
|
||
/// `Icon` provides a namespace for icon identifiers. | ||
/// | ||
/// The naming convention follows the SF Symbols guidelines, enhancing consistency and readability. | ||
/// Each icon name is a dot-syntax representation of the icon's hierarchy and style. | ||
/// | ||
/// For example, `ellipsis.vertical` represents a vertical ellipsis icon. | ||
public enum IconName: String, CaseIterable { | ||
case ellipsisHorizontal = "ellipsis.horizontal" | ||
case checkmark | ||
case gearshapeFill = "gearshape.fill" | ||
case blockShare = "block.share" | ||
case starFill = "star.fill" | ||
case starOutline = "star.outline" | ||
} | ||
|
||
// MARK: - Load Image | ||
|
||
public extension UIImage { | ||
enum DS { | ||
public static func icon(named name: IconName, with configuration: UIImage.Configuration? = nil) -> UIImage? { | ||
return UIImage(named: name.rawValue, in: .module, with: configuration) | ||
} | ||
} | ||
} | ||
|
||
public extension Image { | ||
enum DS { | ||
public static func icon(named name: IconName) -> Image { | ||
return Image(name.rawValue, bundle: .module) | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/block.share.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "block-share.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+2 KB
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/block.share.imageset/block-share.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/checkmark.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "checkmark.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+911 Bytes
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/checkmark.imageset/checkmark.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
...Sources/DesignSystem/Foundation/Icons.xcassets/ellipsis.horizontal.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "more-horizontal-mobile.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...undation/Icons.xcassets/ellipsis.horizontal.imageset/more-horizontal-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions
16
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/gearshape.fill.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "cog.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+3.58 KB
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/gearshape.fill.imageset/cog.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/star/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/star/star.fill.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "star-fill.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+1.54 KB
Modules/Sources/DesignSystem/Foundation/Icons.xcassets/star/star.fill.imageset/star-fill.pdf
Binary file not shown.
Oops, something went wrong.