diff options
| author | Dustin Mierau <dustin@mierau.me> | 2025-10-25 15:26:05 -0700 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2025-10-25 15:26:05 -0700 |
| commit | 53686e30592fee566585e391738adee8b2ef2137 (patch) | |
| tree | 7ee768ca3c84ac7dad7ea674fb637480e4b7184c /Hotline/Utility/SwiftUIExtensions.swift | |
| parent | 65521893ac5f10ec035cd735747034c263e46d77 (diff) | |
Fixed some warnings. Add basic markdown formatting support to chat messages. Add some metadata support for chat log (though we're not using this yet).
Diffstat (limited to 'Hotline/Utility/SwiftUIExtensions.swift')
| -rw-r--r-- | Hotline/Utility/SwiftUIExtensions.swift | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Hotline/Utility/SwiftUIExtensions.swift b/Hotline/Utility/SwiftUIExtensions.swift index 3b850e0..12217b2 100644 --- a/Hotline/Utility/SwiftUIExtensions.swift +++ b/Hotline/Utility/SwiftUIExtensions.swift @@ -1,7 +1,33 @@ import SwiftUI +import Foundation extension Color { init(hex: Int, opacity: Double = 1.0) { self.init(red: Double((hex >> 16) & 0xFF) / 255.0, green: Double((hex >> 8) & 0xFF) / 255.0, blue: Double(hex & 0xFF) / 255.0, opacity: opacity) } } + +extension AttributedString { + func setHangingIndent(firstLineHeadIndent: CGFloat = 0, otherLinesHeadIndent: CGFloat) -> AttributedString { +// var blah = self + +// guard var paragraph = self.paragraphStyle else { +// return +// } + + var p = self.paragraphStyle?.mutableCopy() as? NSMutableParagraphStyle + p?.headIndent = otherLinesHeadIndent + p?.firstLineHeadIndent = firstLineHeadIndent + +// paragraph.headIndent = otherLinesHeadIndent // indent for lines 2+ +// paragraph.firstLineHeadIndent = firstLineHeadIndent // usually 0 + + var blah = self + + + blah.paragraphStyle = p + + return blah + } +} + |