Atributika
Atributika copied to clipboard
Naming considerations
Hi,
Thank you for making such a great package!
I've noticed that sometimes, the naming is causing some confusions, especially with SwiftUI as we have Text as a replacement of UILabel.
But in Atributika:
AttributedText is a wrapper of NSAttributedString, instead of a View, Text, TextView or UIView.
AttributedLabel is using UITextView inside, instead of UILabel.
AttributedLabelView is the SwiftUI version of AttributedLabel proposed in #119 .
Perhaps a better naming? I would suggest:
AttributedText -> AttributedString if we can convert NSAttributedString to AttributedString and vice versa, or StyledString if we can only convert it to NSAttributedString.
AttributedLabel -> UIAttributedTextView as we are using UITextView inside, the prefix indicates that it's a UIKit View.
AttributedLabelView -> AttributedTextView as this is the SwiftUI version of it. It should support some SwiftUI modifiers such as .font (works like styleAll).
New UIAttributedLabel: it uses UILabel internally, so it does not require a width and supports sizeToFit.
New AttributedLabel: it is the SwiftUI version of UIAttributedLabel. It should support some SwiftUI modifiers such as .font (works like styleAll).
I know it is a breaking change, but I still would like to suggest it here as it will remove many potential errors and confusions.
Hi, Thanks for your suggestions! You are definitely right that there is some inconsistency right now with naming. Looks like it is a time to start work on v5 with SwiftUI support and where naming changes can be introduced.
AttributedLabel and AttributedTextView were introduced in v5, they use UILabel and UITextView respectively. AttributedText was removed as a concept. As for SwiftUI, there are no 'official' SwiftUI at the moment, but there is a new example in the Demo app.