android, desktop: profile names (remove full name) (#3177)

* desktop, android: profile names (remove full name)

* rename back

* disallow spaces only in names

* ios: disallow spaces only in names

* changes
This commit is contained in:
Stanislav Dmitrenko
2023-10-06 04:49:18 +08:00
committed by GitHub
parent 0d8558a6d0
commit 34e1e44338
15 changed files with 288 additions and 220 deletions

View File

@@ -80,7 +80,7 @@ struct GroupProfileView: View {
HStack(spacing: 20) {
Button("Cancel") { dismiss() }
Button("Save group profile") { saveProfile() }
.disabled(groupProfile.displayName == "" || !validNewProfileName())
.disabled(!canUpdateProfile())
}
}
.frame(maxWidth: .infinity, minHeight: 120, alignment: .leading)
@@ -134,6 +134,10 @@ struct GroupProfileView: View {
.onTapGesture { hideKeyboard() }
}
private func canUpdateProfile() -> Bool {
groupProfile.displayName.trimmingCharacters(in: .whitespaces) != "" && validNewProfileName()
}
private func validNewProfileName() -> Bool {
groupProfile.displayName == groupInfo.groupProfile.displayName
|| validDisplayName(groupProfile.displayName.trimmingCharacters(in: .whitespaces))

View File

@@ -179,7 +179,8 @@ struct AddGroupView: View {
}
func canCreateProfile() -> Bool {
profile.displayName != "" && validDisplayName(profile.displayName.trimmingCharacters(in: .whitespaces))
let name = profile.displayName.trimmingCharacters(in: .whitespaces)
return name != "" && validDisplayName(name)
}
}

View File

@@ -162,7 +162,7 @@ struct UserProfile: View {
}
private func canSaveProfile(_ user: User) -> Bool {
profile.displayName != "" && validNewProfileName(user)
profile.displayName.trimmingCharacters(in: .whitespaces) != "" && validNewProfileName(user)
}
func saveProfile() {