Defined the Model protocol and implemented the File and Folder models for the Browse module.

This commit is contained in:
Javier Cicchelli 2022-12-13 02:02:25 +01:00
parent 6478a57bba
commit d0371c6e48
3 changed files with 54 additions and 4 deletions

View File

@ -0,0 +1,30 @@
//
// File.swift
// Browse
//
// Created by Javier Cicchelli on 13/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
struct File {
// MARK: Properties
public let id: String
public let name: String
// MARK: Initialisers
public init(
id: String,
name: String
) {
self.id = id
self.name = name
}
}
// MARK: - ModelIdentifiable
extension File: ModelIdentifiable {}

View File

@ -16,11 +16,15 @@ public struct Folder {
// MARK: Initialisers
public init(
id: String? = nil,
name: String? = nil
id: String,
name: String
) {
self.id = id ?? "-"
self.name = name ?? "-"
self.id = id
self.name = name
}
}
// MARK: - ModelIdentifiable
extension Folder: ModelIdentifiable {}

View File

@ -0,0 +1,16 @@
//
// Model.swift
// Browse
//
// Created by Javier Cicchelli on 13/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
protocol Model {
var id: String { get }
var name: String { get }
}
// MARK: - Type aliases
typealias ModelIdentifiable = Model & Identifiable