mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,14 +14,13 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignKit
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, introduced: 14.0, deprecated: 15.0, message: "Use Text with an AttributedString instead.")
|
||||
/// A `Text` view that renders attributed strings with their `.font` and `.foregroundColor` attributes.
|
||||
/// This view is a workaround for iOS 13/14 not supporting `AttributedString`.
|
||||
struct StyledText: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -31,8 +30,8 @@ struct StyledText: View {
|
||||
/// A string with a bold property.
|
||||
private struct StringComponent {
|
||||
let string: String
|
||||
var font: Font? = nil
|
||||
var color: Color? = nil
|
||||
var font: Font?
|
||||
var color: Color?
|
||||
}
|
||||
|
||||
/// Internal representation of the string as composable parts.
|
||||
@@ -47,7 +46,7 @@ struct StyledText: View {
|
||||
let range = NSRange(location: 0, length: attributedString.length)
|
||||
let string = attributedString.string as NSString
|
||||
|
||||
attributedString.enumerateAttributes(in: range, options: []) { attributes, range, stop in
|
||||
attributedString.enumerateAttributes(in: range, options: []) { attributes, range, _ in
|
||||
let font = attributes[.font] as? UIFont
|
||||
let color = attributes[.foregroundColor] as? UIColor
|
||||
|
||||
@@ -66,7 +65,7 @@ struct StyledText: View {
|
||||
/// Creates a `StyledText` using a plain string.
|
||||
/// - Parameter string: The plain string to display
|
||||
init(_ string: String) {
|
||||
self.components = [StringComponent(string: string, font: nil)]
|
||||
components = [StringComponent(string: string, font: nil)]
|
||||
}
|
||||
|
||||
// MARK: - Views
|
||||
@@ -80,7 +79,6 @@ struct StyledText: View {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct StyledText_Previews: PreviewProvider {
|
||||
static func prettyText() -> NSAttributedString {
|
||||
let string = NSMutableAttributedString(string: "T", attributes: [
|
||||
|
||||
Reference in New Issue
Block a user