Add residence sharing via .casera files
- Add SharedResidence model and package type detection for .casera files - Add generateSharePackage API endpoint integration - Create ResidenceSharingManager for iOS and Android - Add share button to residence detail screens (owner only) - Add residence import handling with confirmation dialogs - Update Quick Look extensions to show house icon for residence packages - Route .casera imports by type (contractor vs residence) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,19 +10,37 @@ import QuickLookThumbnailing
|
||||
|
||||
class ThumbnailProvider: QLThumbnailProvider {
|
||||
|
||||
/// Represents the type of .casera package
|
||||
private enum PackageType {
|
||||
case contractor
|
||||
case residence
|
||||
}
|
||||
|
||||
override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) {
|
||||
|
||||
let thumbnailSize = request.maximumSize
|
||||
|
||||
// Detect package type from file
|
||||
let packageType = detectPackageType(at: request.fileURL)
|
||||
|
||||
handler(QLThumbnailReply(contextSize: thumbnailSize, currentContextDrawing: { () -> Bool in
|
||||
// Draw background
|
||||
let backgroundColor = UIColor(red: 7/255, green: 160/255, blue: 195/255, alpha: 1)
|
||||
backgroundColor.setFill()
|
||||
UIRectFill(CGRect(origin: .zero, size: thumbnailSize))
|
||||
|
||||
// Choose icon based on package type
|
||||
let iconName: String
|
||||
switch packageType {
|
||||
case .contractor:
|
||||
iconName = "person.crop.rectangle.stack"
|
||||
case .residence:
|
||||
iconName = "house.fill"
|
||||
}
|
||||
|
||||
// Draw icon
|
||||
let config = UIImage.SymbolConfiguration(pointSize: min(thumbnailSize.width, thumbnailSize.height) * 0.5, weight: .regular)
|
||||
if let icon = UIImage(systemName: "person.crop.rectangle.stack", withConfiguration: config) {
|
||||
if let icon = UIImage(systemName: iconName, withConfiguration: config) {
|
||||
let tintedIcon = icon.withTintColor(.white, renderingMode: .alwaysOriginal)
|
||||
let iconSize = tintedIcon.size
|
||||
let iconOrigin = CGPoint(
|
||||
@@ -35,4 +53,19 @@ class ThumbnailProvider: QLThumbnailProvider {
|
||||
return true
|
||||
}), nil)
|
||||
}
|
||||
|
||||
/// Detects the package type by reading the "type" field from the JSON
|
||||
private func detectPackageType(at url: URL) -> PackageType {
|
||||
do {
|
||||
let data = try Data(contentsOf: url)
|
||||
if let json = try JSONSerialization.jsonObject(with: data) as? [String: Any],
|
||||
let typeString = json["type"] as? String,
|
||||
typeString == "residence" {
|
||||
return .residence
|
||||
}
|
||||
} catch {
|
||||
// Default to contractor on error
|
||||
}
|
||||
return .contractor
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user