Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS-2621 Core | AnytypeText | migrate color api to swiftui api  🎨 #1157

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@
2A41A68D2B84EBBC00EAE6E6 /* DeepLinks in Frameworks */ = {isa = PBXBuildFile; productRef = 2A41A68C2B84EBBC00EAE6E6 /* DeepLinks */; };
2A4373722906808700A1C4D6 /* InlineMarkdownListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4373712906808700A1C4D6 /* InlineMarkdownListener.swift */; };
2A43EAC72A98A18500DA4AAE /* QuickActionShortcutBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A43EAC62A98A18500DA4AAE /* QuickActionShortcutBuilder.swift */; };
2A45A37A2BC4170200F5CAED /* SpaceSettingsShareSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A45A3792BC4170200F5CAED /* SpaceSettingsShareSection.swift */; };
2A475F172AFE47BE00E8C6D5 /* AnytypeNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A475F162AFE47BE00E8C6D5 /* AnytypeNavigationView.swift */; };
2A4919A929530B0F00FCEAC9 /* HomeSubmoduleProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4919A829530B0F00FCEAC9 /* HomeSubmoduleProviderProtocol.swift */; };
2A4919AC29530B5700FCEAC9 /* LinkWidgetViewContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4919AB29530B5700FCEAC9 /* LinkWidgetViewContainer.swift */; };
Expand Down Expand Up @@ -573,7 +574,7 @@
2A80D0622ABAFE9200DB0513 /* EditorNavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80D0612ABAFE9200DB0513 /* EditorNavigationBarView.swift */; };
2A80F7682BB47569000B55C6 /* SpaceMoreInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80F7672BB47569000B55C6 /* SpaceMoreInfoView.swift */; };
2A80F76A2BB5764F000B55C6 /* SetPermissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80F7692BB5764F000B55C6 /* SetPermissions.swift */; };
2A80F76C2BB5AA63000B55C6 /* ButtonForeground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80F76B2BB5AA63000B55C6 /* ButtonForeground.swift */; };
2A80F76C2BB5AA63000B55C6 /* DynamicForeground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80F76B2BB5AA63000B55C6 /* DynamicForeground.swift */; };
2A80F76F2BB5BCD2000B55C6 /* SetPermissionsBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A80F76E2BB5BCD2000B55C6 /* SetPermissionsBuilder.swift */; };
2A816AC72AD7DC1700975BCA /* ServerConfigirationStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A816AC62AD7DC1700975BCA /* ServerConfigirationStorage.swift */; };
2A816AC92AD7DFC700975BCA /* ServerConfigurationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A816AC82AD7DFC700975BCA /* ServerConfigurationView.swift */; };
Expand Down Expand Up @@ -2217,6 +2218,7 @@
2A41A6762B84D43C00EAE6E6 /* DeepLinks */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = DeepLinks; path = Modules/DeepLinks; sourceTree = "<group>"; };
2A4373712906808700A1C4D6 /* InlineMarkdownListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InlineMarkdownListener.swift; sourceTree = "<group>"; };
2A43EAC62A98A18500DA4AAE /* QuickActionShortcutBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickActionShortcutBuilder.swift; sourceTree = "<group>"; };
2A45A3792BC4170200F5CAED /* SpaceSettingsShareSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceSettingsShareSection.swift; sourceTree = "<group>"; };
2A475F162AFE47BE00E8C6D5 /* AnytypeNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnytypeNavigationView.swift; sourceTree = "<group>"; };
2A4919A829530B0F00FCEAC9 /* HomeSubmoduleProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSubmoduleProviderProtocol.swift; sourceTree = "<group>"; };
2A4919AB29530B5700FCEAC9 /* LinkWidgetViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkWidgetViewContainer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2365,7 +2367,7 @@
2A80D0612ABAFE9200DB0513 /* EditorNavigationBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorNavigationBarView.swift; sourceTree = "<group>"; };
2A80F7672BB47569000B55C6 /* SpaceMoreInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceMoreInfoView.swift; sourceTree = "<group>"; };
2A80F7692BB5764F000B55C6 /* SetPermissions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetPermissions.swift; sourceTree = "<group>"; };
2A80F76B2BB5AA63000B55C6 /* ButtonForeground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonForeground.swift; sourceTree = "<group>"; };
2A80F76B2BB5AA63000B55C6 /* DynamicForeground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicForeground.swift; sourceTree = "<group>"; };
2A80F76E2BB5BCD2000B55C6 /* SetPermissionsBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetPermissionsBuilder.swift; sourceTree = "<group>"; };
2A816AC62AD7DC1700975BCA /* ServerConfigirationStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerConfigirationStorage.swift; sourceTree = "<group>"; };
2A816AC82AD7DFC700975BCA /* ServerConfigurationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerConfigurationView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5769,6 +5771,7 @@
2A0F40392BAD7560002D8D37 /* SpaceLeaveAlert */,
2A4C7FF92A822BA000201946 /* SettingsInfoBlockView.swift */,
2A377E3D2A82564E00EA856B /* SpaceTypeView.swift */,
2A45A3792BC4170200F5CAED /* SpaceSettingsShareSection.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -8991,7 +8994,7 @@
2ABF8F5A2B7FADA3004B8FB8 /* ErrorStateView.swift */,
2ABF8F5C2B7FB1B5004B8FB8 /* ScreenStateView.swift */,
2A27F9B72B8DDB1F00BA1303 /* AsyncThrowsTask.swift */,
2A80F76B2BB5AA63000B55C6 /* ButtonForeground.swift */,
2A80F76B2BB5AA63000B55C6 /* DynamicForeground.swift */,
);
path = BasicComponents;
sourceTree = "<group>";
Expand Down Expand Up @@ -11395,7 +11398,7 @@
120AC25E2747B56000330D7B /* TextRelationDetailsViewModel.swift in Sources */,
2AD37D5829911FA50012409E /* WidgetObjectListSetsViewModel.swift in Sources */,
53CC99B3280DB6CC00C39CCF /* EventConfigurtion.swift in Sources */,
2A80F76C2BB5AA63000B55C6 /* ButtonForeground.swift in Sources */,
2A80F76C2BB5AA63000B55C6 /* DynamicForeground.swift in Sources */,
120F7D78267F873500327734 /* BlockBookmarkView.swift in Sources */,
3D26AA722B9725EF00D61479 /* MembershipEmailSheetView.swift in Sources */,
2A03039C28ABAC92002EFC46 /* TextRelationReloadContentActionViewModel.swift in Sources */,
Expand Down Expand Up @@ -12086,6 +12089,7 @@
2E0A6CD12A376B4600A28AF2 /* LoginView.swift in Sources */,
2ECF1DCC2BBEE71E007C68E2 /* GlobalSearchDataSection.swift in Sources */,
3DB1C9DC2726C248000D2779 /* DeletedLabel.swift in Sources */,
2A45A37A2BC4170200F5CAED /* SpaceSettingsShareSection.swift in Sources */,
2ADF00912ACD66D4000D01F8 /* NavigationGestureModifier.swift in Sources */,
2ABF214C29B2056500E872D9 /* DashboardAccountDeletionAlertModel.swift in Sources */,
2E56F13F2A0D81AC00031167 /* TransparentBackground.swift in Sources */,
Expand Down
16 changes: 10 additions & 6 deletions Anytype/Sources/Design system/Fonts/AnytypeText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ struct AnytypeText: View {
self.spacing = spacing
}

init(_ text: String?, style: AnytypeFont, color: Color, enableMarkdown: Bool = false) {
init(_ text: String?, style: AnytypeFont, enableMarkdown: Bool = false) {
let spacing = style.lineSpacing

self.textView = Self.buildText(text ?? "", style: style, enableMarkdown: enableMarkdown)
.foregroundColor(color)
self.spacing = spacing
}

Expand Down Expand Up @@ -53,6 +52,11 @@ struct AnytypeText: View {
}


func foregroundColor(_ color: Color) -> AnytypeText {
let textView = textView.foregroundColor(color)
return AnytypeText(textView: textView, spacing: spacing)
}

// MARK: - Private

private static func buildText(_ text: String, style: AnytypeFont, enableMarkdown: Bool) -> Text {
Expand All @@ -71,10 +75,10 @@ struct AnytypeText: View {
struct AnytypeText_Previews: PreviewProvider {
static var previews: some View {
VStack {
AnytypeText("Foo", style: .title, color: .Text.primary)
AnytypeText("Foo", style: .bodyRegular, color: .Text.primary)
AnytypeText("Foo", style: .relation3Regular, color: .Text.primary)
AnytypeText("collapse", style: .codeBlock, color: .Text.primary)
AnytypeText("Foo", style: .title)
AnytypeText("Foo", style: .bodyRegular)
AnytypeText("Foo", style: .relation3Regular)
AnytypeText("collapse", style: .codeBlock)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ struct TypographyExample: View {
ScrollView() {
ForEach(AnytypeFont.allCases, id: \.self) { style in
VStack {
AnytypeText("\(String(describing: style))", style: style, color: .Text.primary)
AnytypeText("The quick brown fox jumps over the lazy dog", style: style, color: .Text.primary)
AnytypeText("\(String(describing: style))", style: style)
.foregroundColor(.Text.primary)
AnytypeText("The quick brown fox jumps over the lazy dog", style: style)
.foregroundColor(.Text.primary)
}.padding(10)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public struct AnytypeInlinePicker<T> : View where T: (Identifiable & Equatable &
Image(asset: .system(name: "checkmark"))
.opacity(value == initialValue ? 1 : 0)
Spacer.fixedWidth(8)
AnytypeText(value.title, style: .bodyRegular, color: .Text.primary)
AnytypeText(value.title, style: .bodyRegular)
.foregroundColor(.Text.primary)
Spacer()
}
.frame(height: 48)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ struct CheckPopupView<ViewModel: CheckPopupViewViewModelProtocol>: View {
}

VStack(alignment: .leading, spacing: 0) {
AnytypeText(item.title, style: .uxBodyRegular, color: .Text.primary)
AnytypeText(item.title, style: .uxBodyRegular)
.foregroundColor(.Text.primary)

if let subtitle = item.subtitle {
AnytypeText(subtitle, style: .caption1Regular, color: .Text.secondary)
AnytypeText(subtitle, style: .caption1Regular)
.foregroundColor(.Text.secondary)
}
}
Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct WaitingPopupView: View {
var body: some View {
VStack(spacing: 0) {
Spacer.fixedHeight(15)
AnytypeText(text, style: .uxCalloutRegular, color: .Text.primary)
AnytypeText(text, style: .uxCalloutRegular)
.foregroundColor(.Text.primary)
Spacer.fixedHeight(13)
ProgressBar(showAnimation: true)
Spacer.fixedHeight(20)
Expand Down
3 changes: 2 additions & 1 deletion Anytype/Sources/Design system/TitleView/TitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct TitleView<RightContent>: View where RightContent: View {
HStack {
Spacer()
if let title = title {
AnytypeText(title, style: .uxTitle1Semibold, color: .Text.primary)
AnytypeText(title, style: .uxTitle1Semibold)
.foregroundColor(.Text.primary)
.frame(height: 48)
}
Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ struct NewRelationFormatSectionView: View {
HStack(spacing: 5) {
Image(asset: model.icon)
.foregroundColor(.Button.active)
AnytypeText(model.title, style: .uxBodyRegular, color: .Text.primary)
AnytypeText(model.title, style: .uxBodyRegular)
.foregroundColor(.Text.primary)
.lineLimit(1)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct NewRelationRestrictionsSectionView: View {
}

private var emptyView: some View {
AnytypeText(Loc.none, style: .uxBodyRegular, color: .Text.primary)
AnytypeText(Loc.none, style: .uxBodyRegular)
.foregroundColor(.Text.primary)
.lineLimit(1)
}

Expand All @@ -38,7 +39,8 @@ struct NewRelationRestrictionsSectionView: View {
.frame(width: 20, height: 20)

}
AnytypeText(model.title, style: .uxBodyRegular, color: .Text.primary)
AnytypeText(model.title, style: .uxBodyRegular)
.foregroundColor(.Text.primary)
.lineLimit(1)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct NewRelationSectionView<Content: View>: View {
}

private var titleView: some View {
AnytypeText(title, style: .caption1Regular, color: .Text.secondary)
AnytypeText(title, style: .caption1Regular)
.foregroundColor(.Text.secondary)
.lineLimit(1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ struct RelationFormatListCell: View {
Image(asset: model.iconAsset)
.foregroundColor(.Button.active)

AnytypeText(model.title, style: .uxBodyRegular, color: .Text.primary)
AnytypeText(model.title, style: .uxBodyRegular)
.foregroundColor(.Text.primary)
.lineLimit(1)

Spacer()
Expand Down
5 changes: 3 additions & 2 deletions Anytype/Sources/PresentationLayer/Auth/Auth/AuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct AuthView: View {

Spacer.fixedHeight(20)

AnytypeText(Loc.Auth.Welcome.subtitle, style: .uxCalloutRegular, color: .Auth.body)
AnytypeText(Loc.Auth.Welcome.subtitle, style: .uxCalloutRegular)
.foregroundColor(.Auth.body)
.multilineTextAlignment(.center)
.padding(.horizontal, UIDevice.isPad ? 85 : 38)
}
Expand Down Expand Up @@ -97,9 +98,9 @@ struct AuthView: View {
AnytypeText(
Loc.Auth.Caption.Privacy.text(AboutApp.termsLink, AboutApp.privacyLink),
style: .authCaption,
color: .Auth.caption,
enableMarkdown: true
)
.foregroundColor(.Auth.caption)
.multilineTextAlignment(.center)
.padding(.horizontal, 38)
.accentColor(.Auth.body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ struct DeletedAccountView: View {
VStack(alignment: .leading, spacing: 0) {
clock
Spacer.fixedHeight(19)
AnytypeText(viewModel.title, style: .heading, color: .Text.primary)
AnytypeText(viewModel.title, style: .heading)
.foregroundColor(.Text.primary)
Spacer.fixedHeight(11)
AnytypeText(Loc.pendingDeletionText, style: .uxCalloutRegular, color: .Text.primary)
AnytypeText(Loc.pendingDeletionText, style: .uxCalloutRegular)
.foregroundColor(.Text.primary)
Spacer.fixedHeight(14)
SettingsButton(text: Loc.cancelDeletion, textColor: .System.red) { viewModel.cancel() }
SettingsButton(text: Loc.logoutAndClearData, textColor: .System.red) { viewModel.logOut() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct CreatingSoulView: View {
VStack(alignment: .center, spacing: 0) {
AnytypeText(
model.showSpace ? Loc.Auth.JoinFlow.Setting.Space.title : Loc.Auth.JoinFlow.Creating.Soul.title,
style: .bodyRegular,
color: .Auth.inputText
style: .bodyRegular
)
.foregroundColor(.Auth.inputText)

Spacer.fixedHeight(64)

Expand Down Expand Up @@ -62,7 +62,8 @@ struct CreatingSoulView: View {
VStack(spacing: 8) {
IconView(icon: model.profileIcon)
.frame(width: Constants.imageDimension, height: Constants.imageDimension)
AnytypeText(model.soulName, style: .calloutRegular, color: .Auth.body)
AnytypeText(model.soulName, style: .calloutRegular)
.foregroundColor(.Auth.body)
.frame(width: 80)
.truncationMode(.middle)
.lineLimit(1)
Expand All @@ -74,7 +75,8 @@ struct CreatingSoulView: View {
VStack(spacing: 8) {
IconView(icon: model.spaceIcon)
.frame(width: Constants.imageDimension, height: Constants.imageDimension)
AnytypeText(Loc.Spaces.Accessibility.personal, style: .calloutRegular, color: .Auth.body)
AnytypeText(Loc.Spaces.Accessibility.personal, style: .calloutRegular)
.foregroundColor(.Auth.body)
.multilineTextAlignment(.center)
}
.frame(width: Constants.itemWidth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ struct JoinFlowView: View {
}

private var counter : some View {
AnytypeText(model.counter, style: .authBody, color: .Button.active)
AnytypeText(model.counter, style: .authBody)
.foregroundColor(.Button.active)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ struct KeyPhraseMoreInfoView: View {
ScrollView(.vertical, showsIndicators: false) {
Spacer.fixedHeight(26)

AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.title, style: .heading, color: .Auth.inputText)
AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.title, style: .heading)
.foregroundColor(.Auth.inputText)
.multilineTextAlignment(.center)

Spacer.fixedHeight(32)
Expand Down Expand Up @@ -36,10 +37,12 @@ struct KeyPhraseMoreInfoView: View {
private func optionRow(for emoji: String, description: String) -> some View {
HStack(alignment: .top, spacing: 12) {
VStack(alignment: .leading) {
AnytypeText(emoji, style: .authEmoji, color: .Auth.inputText)
AnytypeText(emoji, style: .authEmoji)
.foregroundColor(.Auth.inputText)
}
.frame(width: 56, height: 56)
AnytypeText(description, style: .bodyRegular, color: .Auth.inputText)
AnytypeText(description, style: .bodyRegular)
.foregroundColor(.Auth.inputText)
}
}

Expand All @@ -61,7 +64,8 @@ struct KeyPhraseMoreInfoView: View {

Spacer.fixedHeight(12)

AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.Instruction.title, style: .subheading, color: .Auth.inputText)
AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.Instruction.title, style: .subheading)
.foregroundColor(.Auth.inputText)

Spacer.fixedHeight(12)

Expand All @@ -81,8 +85,10 @@ struct KeyPhraseMoreInfoView: View {

private func instructionRow(description: String) -> some View {
HStack(alignment: .top, spacing: 12) {
AnytypeText("•", style: .bodyRegular, color: .Auth.inputText)
AnytypeText(description, style: .uxCalloutRegular, color: .Auth.inputText)
AnytypeText("•", style: .bodyRegular)
.foregroundColor(.Auth.inputText)
AnytypeText(description, style: .uxCalloutRegular)
.foregroundColor(.Auth.inputText)
}
}
}
Expand Down
Loading
Loading