Skip to content

Commit

Permalink
fix: Multiple selection action not same between iOS and Android, plus…
Browse files Browse the repository at this point in the history
… fix color
  • Loading branch information
Matthieu-dgl committed Oct 16, 2024
1 parent f3c7298 commit cefc581
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension FileActionsFloatingPanelViewController {
case .manageDropbox:
return file.isDropbox
case .folderColor:
return file.canBeColored
return file.capabilities.canColor
case .seeFolder:
return !normalFolderHierarchy && (file.parent != nil || file.parentId != 0)
case .offline:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ extension MultipleSelectionFloatingPanelViewController {
favoriteAction(group: group)
case .manageCategories:
manageCategoriesAction(group: group)
case .folderColor:
folderColorAction(group: group)
case .download:
downloadAction(group: group, at: indexPath)
case .move:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class MultipleSelectionFloatingPanelViewController: UICollectionViewContro
weak var presentingParent: UIViewController?

var sharedWithMe: Bool {
return currentDirectory.visibility == .isInSharedSpace
return currentDirectory.visibility == .isInSharedSpace || currentDirectory.visibility == .isSharedSpace
}

var actions = FloatingPanelAction.listActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class DriveFileManager {
}

public static var sharedWithMeRootFile: File {
return File(id: -3, name: "Shared with me")
return File(id: -10, name: "Shared with me", visibility: .isSharedSpace)
}

public static var mySharedRootFile: File {
Expand Down Expand Up @@ -186,6 +186,11 @@ public final class DriveFileManager {
}
}
}
if oldSchemaVersion < 12 {
migration.enumerateObjects(ofType: Rights.className()) { _, newObject in
newObject?["canColor"] = false
}
}
},
objectTypes: DriveFileManager.constants.driveObjectTypes
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum RealmSchemaVersion {
static let upload: UInt64 = 21

/// Current version of the Drive Realm
static let drive: UInt64 = 11
static let drive: UInt64 = 12
}

public class DriveFileManagerConstants {
Expand Down
21 changes: 11 additions & 10 deletions kDriveCore/Data/Models/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -820,17 +820,18 @@ public final class File: Object, Codable {
// primary key is set as default value
}

convenience init(id: Int, name: String, driveId: Int? = nil) {
self.init()
self.id = id
self.name = name
if let driveId {
self.driveId = driveId
uid = File.uid(driveId: driveId, fileId: id)
convenience init(id: Int, name: String, driveId: Int? = nil, visibility: FileVisibility? = nil) {
self.init()

Check warning on line 824 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
self.id = id

Check warning on line 825 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
self.name = name

Check warning on line 826 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
if let driveId {

Check warning on line 827 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
self.driveId = driveId

Check warning on line 828 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
uid = File.uid(driveId: driveId, fileId: id)

Check warning on line 829 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
}

Check warning on line 830 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
rawType = "dir"

Check warning on line 831 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
rawVisibility = visibility?.rawValue ?? ""

Check warning on line 832 in kDriveCore/Data/Models/File.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
children = MutableSet<File>()
}
rawType = "dir"
children = MutableSet<File>()
}
}

extension File: Differentiable {
Expand Down
6 changes: 6 additions & 0 deletions kDriveCore/Data/Models/Rights.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class Rights: EmbeddedObject, Codable {
@Persisted public var canUseFavorite: Bool
/// Right to use and give team access
@Persisted public var canUseTeam: Bool
/// Right to color a folder
@Persisted public var canColor: Bool

// Directory capabilities
/// Right to add new child directory
Expand Down Expand Up @@ -73,6 +75,7 @@ public class Rights: EmbeddedObject, Codable {
case canUpload
case canMoveInto
case canBecomeDropbox
case canColor
}

public required init(from decoder: Decoder) throws {
Expand All @@ -93,6 +96,8 @@ public class Rights: EmbeddedObject, Codable {
canUpload = try container.decodeIfPresent(Bool.self, forKey: .canUpload) ?? false
canMoveInto = try container.decodeIfPresent(Bool.self, forKey: .canMoveInto) ?? false
canBecomeDropbox = try container.decodeIfPresent(Bool.self, forKey: .canBecomeDropbox) ?? false
canColor = try container.decodeIfPresent(Bool.self, forKey: .canColor) ?? false

Check warning on line 99 in kDriveCore/Data/Models/Rights.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Remove trailing blank line at the end of a scope. (blankLinesAtEndOfScope)

}

override public init() {
Expand All @@ -119,5 +124,6 @@ extension Rights: ContentEquatable {
&& canUpload == source.canUpload
&& canMoveInto == source.canMoveInto
&& canBecomeDropbox == source.canBecomeDropbox
&& canColor == source.canColor
}
}

0 comments on commit cefc581

Please sign in to comment.