Skip to content

Commit

Permalink
chore: size in GB or MB
Browse files Browse the repository at this point in the history
  • Loading branch information
rnr committed Jul 30, 2024
1 parent cb83a81 commit 604e5a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct CourseVideoDownloadBarView: View {
.accessibilityIdentifier("remaining_videos_text")
}
if let totalSize = viewModel.totalSize {
let text = ", \(totalSize)MB \(CourseLocalization.Download.total)"
let text = ", \(totalSize) \(CourseLocalization.Download.total)"
Text(text)
.accessibilityElement(children: .ignore)
.accessibilityLabel(text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ final class CourseVideoDownloadBarViewModel: ObservableObject {
if isOn {
let size = mb - calculateSize(value: mb, percentage: progress * 100)
if size == 0 {
return String(format: "%.2f", mb)
return sizeInMbOrGb(size: mb)
}
return String(format: "%.2f", size)
return sizeInMbOrGb(size: size)
}

let size = blockToMB(
Expand All @@ -103,7 +103,15 @@ final class CourseVideoDownloadBarViewModel: ObservableObject {
downloadQuality: downloadQuality
)

return String(format: "%.2f", size)
return sizeInMbOrGb(size: size)
}

private func sizeInMbOrGb(size: Double) -> String {
if size >= 1024.0 {
return String(format: "%.2fGB", size / 1024.0)
} else {
return String(format: "%.2fMB", size)
}
}

init(
Expand Down

0 comments on commit 604e5a2

Please sign in to comment.