From 5d9b97e35405ea404e0a0891e3bf42eddeec5650 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 9 Dec 2024 10:53:28 +1100 Subject: [PATCH] Added Lucide as a dependency, added standard font styling --- Session.xcodeproj/project.pbxproj | 39 +++++++ .../xcshareddata/swiftpm/Package.resolved | 11 +- .../Settings.bundle/ThirdPartyLicenses.plist | 21 ++++ SessionUIKit/Style Guide/Fonts.swift | 107 ++++++++++++++++++ .../Utilities/Localization+Style.swift | 6 + 5 files changed, 183 insertions(+), 1 deletion(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 63a95bdad..18344d2c9 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -687,6 +687,8 @@ FD6A7A6D2818C61500035AC1 /* _002_SetupStandardJobs.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A7A6C2818C61500035AC1 /* _002_SetupStandardJobs.swift */; }; FD6C67242CF6E72E00B350A7 /* NoopSessionCallManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6C67232CF6E72900B350A7 /* NoopSessionCallManager.swift */; }; FD6C67262CF6EA2300B350A7 /* PushRegistrationManagerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6C67252CF6EA1E00B350A7 /* PushRegistrationManagerType.swift */; }; + FD6DA9CF2D015B440092085A /* Lucide in Frameworks */ = {isa = PBXBuildFile; productRef = FD6DA9CE2D015B440092085A /* Lucide */; }; + FD6DA9D22D0160F10092085A /* Lucide in Frameworks */ = {isa = PBXBuildFile; productRef = FD6DA9D12D0160F10092085A /* Lucide */; }; FD6DF00B2ACFE40D0084BA4C /* _005_AddSnodeReveivedMessageInfoPrimaryKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6DF00A2ACFE40D0084BA4C /* _005_AddSnodeReveivedMessageInfoPrimaryKey.swift */; }; FD6E4C8A2A1AEE4700C7C243 /* LegacyUnsubscribeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6E4C892A1AEE4700C7C243 /* LegacyUnsubscribeRequest.swift */; }; FD705A92278D051200F16121 /* ReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD705A91278D051200F16121 /* ReusableView.swift */; }; @@ -735,6 +737,8 @@ FD716E722850647600C96BF4 /* Data+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD859EF127BF6BA200510D0C /* Data+Utilities.swift */; }; FD72BD9A2BDF5EEA00CF6CF6 /* Message+Origin.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD72BD992BDF5EEA00CF6CF6 /* Message+Origin.swift */; }; FD756BEB2D0181D700BD7199 /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = FD756BEA2D0181D700BD7199 /* GRDB */; }; + FD756BF02D06686500BD7199 /* Lucide in Frameworks */ = {isa = PBXBuildFile; productRef = FD756BEF2D06686500BD7199 /* Lucide */; }; + FD756BF22D06687800BD7199 /* Lucide in Frameworks */ = {isa = PBXBuildFile; productRef = FD756BF12D06687800BD7199 /* Lucide */; }; FD7692F72A53A2ED000E4B70 /* SessionThreadViewModelSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7692F62A53A2ED000E4B70 /* SessionThreadViewModelSpec.swift */; }; FD7728962849E7E90018502F /* String+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7728952849E7E90018502F /* String+Utilities.swift */; }; FD7728982849E8110018502F /* UITableView+ReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7728972849E8110018502F /* UITableView+ReusableView.swift */; }; @@ -2170,6 +2174,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FD756BF22D06687800BD7199 /* Lucide in Frameworks */, FD2286712C38D43000BC06F7 /* DifferenceKit in Frameworks */, FD6A396B2C2D284500762359 /* YYImage in Frameworks */, FD37E9EF28A5ED70003AE748 /* SessionUtilitiesKit.framework in Frameworks */, @@ -2238,7 +2243,9 @@ 455A16DD1F1FEA0000F86704 /* Metal.framework in Frameworks */, 455A16DE1F1FEA0000F86704 /* MetalKit.framework in Frameworks */, 45847E871E4283C30080EAB3 /* Intents.framework in Frameworks */, + FD756BF02D06686500BD7199 /* Lucide in Frameworks */, 4520D8D51D417D8E00123472 /* Photos.framework in Frameworks */, + FD6DA9D22D0160F10092085A /* Lucide in Frameworks */, B6B226971BE4B7D200860F4D /* ContactsUI.framework in Frameworks */, FDEF572A2C3CF50B00131302 /* WebRTC in Frameworks */, 45BD60821DE9547E00A8F436 /* Contacts.framework in Frameworks */, @@ -2254,6 +2261,7 @@ A11CD70D17FA230600A2D1B1 /* QuartzCore.framework in Frameworks */, A163E8AB16F3F6AA0094D68B /* Security.framework in Frameworks */, A1C32D5117A06544000A904E /* AddressBook.framework in Frameworks */, + FD6DA9CF2D015B440092085A /* Lucide in Frameworks */, A1C32D5017A06538000A904E /* AddressBookUI.framework in Frameworks */, D2AEACDC16C426DA00C364C0 /* CFNetwork.framework in Frameworks */, C331FF222558F9D300070591 /* SessionUIKit.framework in Frameworks */, @@ -4694,6 +4702,7 @@ packageProductDependencies = ( FD6A396A2C2D284500762359 /* YYImage */, FD2286702C38D43000BC06F7 /* DifferenceKit */, + FD756BF12D06687800BD7199 /* Lucide */, ); productName = SessionUIKit; productReference = C331FF1B2558F9D300070591 /* SessionUIKit.framework */; @@ -4825,6 +4834,9 @@ FD6A39682C2D283A00762359 /* YYImage */, FD2286782C38D4FF00BC06F7 /* DifferenceKit */, FDEF57292C3CF50B00131302 /* WebRTC */, + FD6DA9CE2D015B440092085A /* Lucide */, + FD6DA9D12D0160F10092085A /* Lucide */, + FD756BEF2D06686500BD7199 /* Lucide */, ); productName = RedPhone; productReference = D221A089169C9E5E00537ABF /* Session.app */; @@ -5072,6 +5084,7 @@ FD6A39642C2D21E400762359 /* XCRemoteSwiftPackageReference "libwebp-Xcode" */, FD6A39672C2D283A00762359 /* XCRemoteSwiftPackageReference "session-ios-yyimage" */, FD6DA9D52D017F480092085A /* XCRemoteSwiftPackageReference "session-grdb-swift" */, + FD756BEE2D06686500BD7199 /* XCRemoteSwiftPackageReference "session-lucide" */, ); productRefGroup = D221A08A169C9E5E00537ABF /* Products */; projectDirPath = ""; @@ -8668,6 +8681,14 @@ minimumVersion = 106.29.3; }; }; + FD756BEE2D06686500BD7199 /* XCRemoteSwiftPackageReference "session-lucide" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/session-foundation/session-lucide.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.468.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -8799,11 +8820,29 @@ package = FD6A39672C2D283A00762359 /* XCRemoteSwiftPackageReference "session-ios-yyimage" */; productName = YYImage; }; + FD6DA9CE2D015B440092085A /* Lucide */ = { + isa = XCSwiftPackageProductDependency; + productName = Lucide; + }; + FD6DA9D12D0160F10092085A /* Lucide */ = { + isa = XCSwiftPackageProductDependency; + productName = Lucide; + }; FD756BEA2D0181D700BD7199 /* GRDB */ = { isa = XCSwiftPackageProductDependency; package = FD6DA9D52D017F480092085A /* XCRemoteSwiftPackageReference "session-grdb-swift" */; productName = GRDB; }; + FD756BEF2D06686500BD7199 /* Lucide */ = { + isa = XCSwiftPackageProductDependency; + package = FD756BEE2D06686500BD7199 /* XCRemoteSwiftPackageReference "session-lucide" */; + productName = Lucide; + }; + FD756BF12D06687800BD7199 /* Lucide */ = { + isa = XCSwiftPackageProductDependency; + package = FD756BEE2D06686500BD7199 /* XCRemoteSwiftPackageReference "session-lucide" */; + productName = Lucide; + }; FDEF57292C3CF50B00131302 /* WebRTC */ = { isa = XCSwiftPackageProductDependency; package = FD6A390E2C2A93CD00762359 /* XCRemoteSwiftPackageReference "WebRTC" */; diff --git a/Session.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Session.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index e7f20ae96..70222e3b9 100644 --- a/Session.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Session.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "702124fa8d79aa2cee4d496d60bf6b3ad2053e234bcb84c4df5b8f43e95fd8df", + "originHash" : "c57241b796915b0642f9c260463b2d6fd7d5198beafde785c590f3a7d80d31f5", "pins" : [ { "identity" : "cocoalumberjack", @@ -100,6 +100,15 @@ "version" : "1.1.0" } }, + { + "identity" : "session-lucide", + "kind" : "remoteSourceControl", + "location" : "https://github.com/session-foundation/session-lucide.git", + "state" : { + "revision" : "32fdd138a20e828eea376d01e53efb461cc19ebe", + "version" : "0.468.0" + } + }, { "identity" : "swift-log", "kind" : "remoteSourceControl", diff --git a/Session/Meta/Settings.bundle/ThirdPartyLicenses.plist b/Session/Meta/Settings.bundle/ThirdPartyLicenses.plist index 77921becb..1dcc5edf1 100644 --- a/Session/Meta/Settings.bundle/ThirdPartyLicenses.plist +++ b/Session/Meta/Settings.bundle/ThirdPartyLicenses.plist @@ -1022,6 +1022,27 @@ SOFTWARE. Title session-ios-yyimage + + License + ISC License + +Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Title + session-lucide + License diff --git a/SessionUIKit/Style Guide/Fonts.swift b/SessionUIKit/Style Guide/Fonts.swift index 8fd521324..4572cbf44 100644 --- a/SessionUIKit/Style Guide/Fonts.swift +++ b/SessionUIKit/Style Guide/Fonts.swift @@ -5,6 +5,8 @@ import UIKit import SwiftUI +// MARK: - UIKit + public enum Fonts { public static func spaceMono(ofSize size: CGFloat) -> UIFont { return UIFont(name: "SpaceMono-Regular", size: size)! @@ -15,6 +17,61 @@ public enum Fonts { } } +public extension Fonts { + enum Headings { + public static let H1: UIFont = .boldSystemFont(ofSize: CGFloat(36)) + public static let H2: UIFont = .boldSystemFont(ofSize: CGFloat(32)) + public static let H3: UIFont = .boldSystemFont(ofSize: CGFloat(29)) + public static let H4: UIFont = .boldSystemFont(ofSize: CGFloat(26)) + public static let H5: UIFont = .boldSystemFont(ofSize: CGFloat(23)) + public static let H6: UIFont = .boldSystemFont(ofSize: CGFloat(20)) + public static let H7: UIFont = .boldSystemFont(ofSize: CGFloat(18)) + public static let H8: UIFont = .boldSystemFont(ofSize: CGFloat(16)) + public static let H9: UIFont = .boldSystemFont(ofSize: CGFloat(14)) + + public static func custom(_ size: CGFloat) -> UIFont { + return .boldSystemFont(ofSize: size) + } + } + + enum Body { + public static let extraLargeRegular: UIFont = .systemFont(ofSize: CGFloat(18)) + public static let largeRegular: UIFont = .systemFont(ofSize: CGFloat(16)) + public static let baseRegular: UIFont = .systemFont(ofSize: CGFloat(14)) + public static let smallRegular: UIFont = .systemFont(ofSize: CGFloat(12)) + public static let extraSmallRegular: UIFont = .systemFont(ofSize: CGFloat(11)) + public static let finePrintRegular: UIFont = .systemFont(ofSize: CGFloat(9)) + public static let extraLargeBold: UIFont = .boldSystemFont(ofSize: CGFloat(18)) + public static let largeBold: UIFont = .boldSystemFont(ofSize: CGFloat(16)) + public static let baseBold: UIFont = .boldSystemFont(ofSize: CGFloat(14)) + public static let smallBold: UIFont = .boldSystemFont(ofSize: CGFloat(12)) + public static let extraSmallBold: UIFont = .boldSystemFont(ofSize: CGFloat(11)) + public static let finePrintBold: UIFont = .boldSystemFont(ofSize: CGFloat(9)) + + public static func custom(_ size: CGFloat, bold: Bool = false) -> UIFont { + switch bold { + case true: return .boldSystemFont(ofSize: size) + case false: return .systemFont(ofSize: size) + } + } + } + + enum Display { + public static let extraLarge: UIFont = Fonts.spaceMono(ofSize: CGFloat(18)) + public static let large: UIFont = Fonts.spaceMono(ofSize: CGFloat(16)) + public static let base: UIFont = Fonts.spaceMono(ofSize: CGFloat(14)) + public static let small: UIFont = Fonts.spaceMono(ofSize: CGFloat(12)) + public static let extraSmall: UIFont = Fonts.spaceMono(ofSize: CGFloat(11)) + public static let finePrint: UIFont = Fonts.spaceMono(ofSize: CGFloat(9)) + + public static func custom(_ size: CGFloat) -> UIFont { + return Fonts.spaceMono(ofSize: size) + } + } +} + +// MARK: - SwiftUI + public extension Font { static func spaceMono(size: CGFloat) -> Font { return Font.custom("SpaceMono-Regular", size: size) @@ -24,3 +81,53 @@ public extension Font { return Font.custom("SpaceMono-Bold", size: size) } } + +public extension Font { + enum Headings { + public static let H1: Font = .system(size: CGFloat(36)).bold() + public static let H2: Font = .system(size: CGFloat(32)).bold() + public static let H3: Font = .system(size: CGFloat(29)).bold() + public static let H4: Font = .system(size: CGFloat(26)).bold() + public static let H5: Font = .system(size: CGFloat(23)).bold() + public static let H6: Font = .system(size: CGFloat(20)).bold() + public static let H7: Font = .system(size: CGFloat(18)).bold() + public static let H8: Font = .system(size: CGFloat(16)).bold() + public static let H9: Font = .system(size: CGFloat(14)).bold() + + public static func custom(_ size: CGFloat) -> Font { + return .system(size: size).bold() + } + } + + enum Body { + public static let extraLargeRegular: Font = .system(size: CGFloat(18)) + public static let largeRegular: Font = .system(size: CGFloat(16)) + public static let baseRegular: Font = .system(size: CGFloat(14)) + public static let smallRegular: Font = .system(size: CGFloat(12)) + public static let extraSmallRegular: Font = .system(size: CGFloat(11)) + public static let finePrintRegular: Font = .system(size: CGFloat(9)) + public static let extraLargeBold: Font = .system(size: CGFloat(18)).bold() + public static let largeBold: Font = .system(size: CGFloat(16)).bold() + public static let baseBold: Font = .system(size: CGFloat(14)).bold() + public static let smallBold: Font = .system(size: CGFloat(12)).bold() + public static let extraSmallBold: Font = .system(size: CGFloat(11)).bold() + public static let finePrintBold: Font = .system(size: CGFloat(9)).bold() + + public static func custom(_ size: CGFloat, bold: Bool = false) -> Font { + return .system(size: size, weight: (bold ? .bold : .regular)) + } + } + + enum Display { + public static let extraLarge: Font = .spaceMono(size: CGFloat(18)) + public static let large: Font = .spaceMono(size: CGFloat(16)) + public static let base: Font = .spaceMono(size: CGFloat(14)) + public static let small: Font = .spaceMono(size: CGFloat(12)) + public static let extraSmall: Font = .spaceMono(size: CGFloat(11)) + public static let finePrint: Font = .spaceMono(size: CGFloat(9)) + + public static func custom(_ size: CGFloat) -> Font { + return .spaceMono(size: size) + } + } +} diff --git a/SessionUIKit/Utilities/Localization+Style.swift b/SessionUIKit/Utilities/Localization+Style.swift index 1da248a26..03bbfae34 100644 --- a/SessionUIKit/Utilities/Localization+Style.swift +++ b/SessionUIKit/Utilities/Localization+Style.swift @@ -4,6 +4,7 @@ import UIKit import SessionUtilitiesKit +import Lucide public extension NSAttributedString { /// These are the tags we current support formatting for @@ -19,6 +20,7 @@ public extension NSAttributedString { case underline = "u" case strikethrough = "s" case primaryTheme = "span" + case icon = "icon" // MARK: - Functions @@ -51,6 +53,7 @@ public extension NSAttributedString { case .underline: return [.underlineStyle: NSUnderlineStyle.single.rawValue] case .strikethrough: return [.strikethroughStyle: NSUnderlineStyle.single.rawValue] case .primaryTheme: return [.foregroundColor: ThemeManager.currentTheme.color(for: .sessionButton_text).defaulting(to: ThemeManager.primaryColor.color)] + case .icon: return Lucide.attributes(for: font) } } } @@ -175,6 +178,9 @@ private extension Collection where Element == NSAttributedString.HTMLTag { case .underline: result[.underlineStyle] = NSUnderlineStyle.single.rawValue case .strikethrough: result[.strikethroughStyle] = NSUnderlineStyle.single.rawValue case .primaryTheme: result[.foregroundColor] = ThemeManager.currentTheme.color(for: .sessionButton_text).defaulting(to: ThemeManager.primaryColor.color) + case .icon: + result[.font] = fontWith(Lucide.font(ofSize: (font.pointSize + 1)), traits: []) + result[.baselineOffset] = -Lucide.defaultBaselineOffset } } }