Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok committed Feb 14, 2025
1 parent bb6b1c5 commit c077007
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class EditProfileViewModel: ObservableObject {
var profileDidEdit: (((UserProfile?, UIImage?)) -> Void)?
var oldAvatar: UIImage?

private let minimumFullAccountAge = 13
private let currentYear = Calendar.current.component(.year, from: Date())
public let profileTypes: [ProfileType] = [.full, .limited]
private var years: [PickerFields.Option] = []
Expand Down Expand Up @@ -83,7 +84,7 @@ public class EditProfileViewModel: ObservableObject {
guard let year = yearsConfiguration.text != "" ? Int(yearsConfiguration.text) : userModel.yearOfBirth else {
return false
}
if currentYear - year < 13 {
if currentYear - year < minimumFullAccountAge {
return false
}
return profileChanges.profileType == .full
Expand Down Expand Up @@ -173,7 +174,7 @@ public class EditProfileViewModel: ObservableObject {
} else {
yearOfBirth = userModel.yearOfBirth
}
if yearOfBirth == 0 || currentYear - yearOfBirth < 13 {
if yearOfBirth == 0 || currentYear - yearOfBirth < minimumFullAccountAge {
alertMessage = ProfileLocalization.Edit.tooYongUser
} else {
profileChanges.profileType.toggle()
Expand All @@ -185,7 +186,7 @@ public class EditProfileViewModel: ObservableObject {
func checkProfileType() {
if yearsConfiguration.text != "" {
let yearOfBirth = yearsConfiguration.text
if currentYear - (Int(yearOfBirth) ?? 0) < 13 {
if currentYear - (Int(yearOfBirth) ?? 0) < minimumFullAccountAge {
profileChanges.profileType = .limited
isYongUser = true
} else {
Expand All @@ -194,7 +195,7 @@ public class EditProfileViewModel: ObservableObject {
}
}
} else {
if (currentYear - userModel.yearOfBirth) < 13 {
if (currentYear - userModel.yearOfBirth) < minimumFullAccountAge {
profileChanges.profileType = .limited
isYongUser = true
} else {
Expand Down
5 changes: 4 additions & 1 deletion Profile/Profile/Presentation/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ struct ProfileView_Previews: PreviewProvider {
struct UserAvatar: View {
private var url: URL?
private var borderColor: Color

private let defaultAvatarKeyword = "default"

@Binding private var image: UIImage?
init(url: String, image: Binding<UIImage?>, borderColor: Color = Theme.Colors.avatarStroke) {
if url.contains("default") {
if url.contains(defaultAvatarKeyword) {
self.url = nil
} else if let rightUrl = URL(string: url) {
self.url = rightUrl
Expand Down

0 comments on commit c077007

Please sign in to comment.