Integrated the DateAdapter and the SizeAdapter adapters into the DocumentItem component for the Browse module.

This commit is contained in:
Javier Cicchelli 2022-12-16 00:10:42 +01:00
parent 6b1089235a
commit e982a8f689
2 changed files with 6 additions and 3 deletions

View File

@ -19,7 +19,7 @@ struct SizeAdapter {
func callAsFunction(value: Int?) -> String { func callAsFunction(value: Int?) -> String {
guard let value else { return .Constants.noValue } guard let value else { return .Constants.noValue }
var sizeInBytes = Measurement( let sizeInBytes = Measurement(
value: Double(value), value: Double(value),
unit: UnitInformationStorage.bytes unit: UnitInformationStorage.bytes
) )

View File

@ -18,6 +18,9 @@ struct DocumentItem: View {
let download: ActionClosure let download: ActionClosure
let delete: ActionClosure let delete: ActionClosure
private let dateAdapter = DateAdapter()
private let sizeAdapter = SizeAdapter()
// MARK: Body // MARK: Body
var body: some View { var body: some View {
@ -34,11 +37,11 @@ struct DocumentItem: View {
.itemName() .itemName()
HStack { HStack {
Text("lastModified") Text(dateAdapter(value: document?.lastModifiedAt))
Spacer() Spacer()
Text("fileSize") Text(sizeAdapter(value: document?.size))
} }
.font(.subheadline) .font(.subheadline)
.foregroundColor(.secondary) .foregroundColor(.secondary)