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

fix: [FC-0078] Bugfixes part 1 #570

Merged
merged 8 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ struct CustomDisclosureGroup: View {
private func assignmentStatusText(
sequential: CourseSequential
) -> String? {

guard let sequentialProgress = sequential.sequentialProgress,
let assignmentType = sequentialProgress.assignmentType,
let due = sequential.due else {
Expand All @@ -217,7 +216,14 @@ struct CustomDisclosureGroup: View {

let daysRemaining = getAssignmentStatus(for: due)

return "\(assignmentType) - \(daysRemaining)"
let progress: String = {
guard let numPointsEarned = sequentialProgress.numPointsEarned,
let numPointsPossible = sequentialProgress.numPointsPossible else {
return ""
}
return " - \(numPointsEarned) / \(numPointsPossible)"
}()
return "\(assignmentType) - \(daysRemaining)\(progress)"
}

private func downloadAllSubsections(in chapter: CourseChapter, state: DownloadViewState) {
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 231e03216f446b4695e43a4c85a29e2127fd674b

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
28 changes: 20 additions & 8 deletions Profile/Profile/Presentation/EditProfile/EditProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,34 @@ public struct EditProfileView: View {
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("profile_type_text")
Button(action: {
withAnimation {
showingBottomSheet.toggle()
}
}, label: {
UserAvatar(url: viewModel.userModel.avatarUrl, image: $viewModel.inputImage)
Button(
action: {
withAnimation {
showingBottomSheet.toggle()
}
},
label: {
UserAvatar(
url: viewModel.profileChanges.profileType == .full
? viewModel.userModel.avatarUrl
: "",
image: viewModel.profileChanges.profileType == .full
? $viewModel.inputImage
: .constant(nil)
)
.padding(.top, 30)
.overlay(
ZStack {
Circle().frame(width: 36, height: 36)
.foregroundColor(Theme.Colors.accentXColor)
CoreAssets.addPhoto.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.primaryButtonTextColor)
}.offset(x: 36, y: 50)
}
.offset(x: 36, y: 50)
.saturation(viewModel.canEditAvatar ? 1.0 : 0)
)
})
})
.disabled(!viewModel.canEditAvatar)
.accessibilityIdentifier("change_profile_image_button")

Text(viewModel.userModel.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ public class EditProfileViewModel: ObservableObject {
}
}

public var canEditAvatar: Bool {
guard let year = yearsConfiguration.text != "" ? Int(yearsConfiguration.text) : userModel.yearOfBirth else {
return false
}
if currentYear - year < 13 {
return false
}
return profileChanges.profileType == .full
}

let router: ProfileRouter

private let interactor: ProfileInteractorProtocol
Expand All @@ -97,6 +107,7 @@ public class EditProfileViewModel: ObservableObject {
self.spokenLanguages = interactor.getSpokenLanguages()
self.countries = interactor.getCountries()
generateYears()
profileChanges.profileType = userModel.isFullProfile ? .full : .limited
}

func resizeImage(image: UIImage, longSideSize: Double) {
Expand Down
18 changes: 15 additions & 3 deletions Profile/Profile/Presentation/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,18 @@ public struct ProfileView: View {
.accessibilityIdentifier("progress_bar")
} else {
HStack(alignment: .center, spacing: 12) {
UserAvatar(url: viewModel.userModel?.avatarUrl ?? "", image: $viewModel.updatedAvatar)
if let userModel = viewModel.userModel {
UserAvatar(
url: userModel.isFullProfile
? userModel.avatarUrl
: "",
image: userModel.isFullProfile
? $viewModel.updatedAvatar
: .constant(nil)
)
.accessibilityIdentifier("user_avatar_image")
}

VStack(alignment: .leading, spacing: 4) {
Text(viewModel.userModel?.name ?? "")
.font(Theme.Fonts.headlineSmall)
Expand Down Expand Up @@ -205,7 +215,9 @@ struct UserAvatar: View {
private var borderColor: Color
@Binding private var image: UIImage?
init(url: String, image: Binding<UIImage?>, borderColor: Color = Theme.Colors.avatarStroke) {
if let rightUrl = URL(string: url) {
if url.contains("default") {
self.url = nil
} else if let rightUrl = URL(string: url) {
self.url = rightUrl
} else {
self.url = nil
Expand All @@ -227,7 +239,7 @@ struct UserAvatar: View {
}
} else {
KFImage(url)
.onFailureImage(CoreAssets.noCourseImage.image)
.onFailureImage(CoreAssets.noAvatar.image)
.resizable()
.scaledToFill()
.frame(width: 80, height: 80)
Expand Down
Loading