diff --git a/yobble/Views/Tab/Settings/EditProfileView.swift b/yobble/Views/Tab/Settings/EditProfileView.swift index 6520360..d718e96 100644 --- a/yobble/Views/Tab/Settings/EditProfileView.swift +++ b/yobble/Views/Tab/Settings/EditProfileView.swift @@ -22,9 +22,10 @@ struct EditProfileView: View { @State private var avatarViewerState: AvatarViewerState? @State private var shareItems: [Any] = [] @State private var showShareSheet = false - + private let profileService = ProfileService() private let descriptionLimit = 1024 + private let nameLimit = 32 var body: some View { ZStack { @@ -75,13 +76,18 @@ struct EditProfileView: View { Section(header: Text("Публичная информация")) { TextField("Отображаемое имя", text: $displayName) + .onChange(of: displayName) { newValue in + if newValue.count > nameLimit { + displayName = String(newValue.prefix(nameLimit)) + } + } VStack(alignment: .leading, spacing: 5) { - Text("Описание") - .font(.caption) - .foregroundColor(.secondary) - TextEditor(text: $description) - .frame(height: 150) + Text("Описание") + .font(.caption) + .foregroundColor(.secondary) + TextEditor(text: $description) + .frame(height: 150) .onChange(of: description) { newValue in if newValue.count > descriptionLimit { description = String(newValue.prefix(descriptionLimit))