add custom fonts to SwiftUI

pull/874/head
Ryan Zhao 11 months ago
parent 1a22bd07ef
commit 09bece5c10

@ -241,12 +241,14 @@ struct MessageInfoView: View {
alignment: .leading, alignment: .leading,
spacing: 4 spacing: 4
) { ) {
Text(messageViewModel.senderName ?? "Tester") if !messageViewModel.authorName.isEmpty {
.bold() Text(messageViewModel.authorName)
.font(.system(size: 18)) .bold()
.foregroundColor(themeColor: .textPrimary) .font(.system(size: 18))
.foregroundColor(themeColor: .textPrimary)
}
Text(messageViewModel.authorId) Text(messageViewModel.authorId)
.font(.system(size: 16)) .font(.spaceMono(size: 16))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
} }

@ -1,4 +1,5 @@
import UIKit import UIKit
import SwiftUI
@objc(LKFonts) @objc(LKFonts)
public final class Fonts : NSObject { public final class Fonts : NSObject {
@ -11,3 +12,13 @@ public final class Fonts : NSObject {
return UIFont(name: "SpaceMono-Bold", size: size)! return UIFont(name: "SpaceMono-Bold", size: size)!
} }
} }
public extension Font {
static func spaceMono(size: CGFloat) -> Font {
return Font.custom("SpaceMono-Regular", size: size)
}
static func boldSpaceMono(size: CGFloat) -> Font {
return Font.custom("SpaceMono-Bold", size: size)
}
}

Loading…
Cancel
Save