Displaying event authors
This commit is contained in:
parent
a00cf9a597
commit
59ad858234
@ -1822,7 +1822,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 154;
|
CURRENT_PROJECT_VERSION = 155;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
@ -1849,7 +1849,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 154;
|
CURRENT_PROJECT_VERSION = 155;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
|
|||||||
@ -15,6 +15,7 @@ struct EventModel: Identifiable, Hashable {
|
|||||||
var coordinate: CLLocationCoordinate2D
|
var coordinate: CLLocationCoordinate2D
|
||||||
var address: String
|
var address: String
|
||||||
var isMe: Bool
|
var isMe: Bool
|
||||||
|
var user: String?
|
||||||
|
|
||||||
func hash(into hasher: inout Hasher) {
|
func hash(into hasher: inout Hasher) {
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ struct EventModel: Identifiable, Hashable {
|
|||||||
hasher.combine(coordinate.longitude)
|
hasher.combine(coordinate.longitude)
|
||||||
hasher.combine(address)
|
hasher.combine(address)
|
||||||
hasher.combine(isMe)
|
hasher.combine(isMe)
|
||||||
|
hasher.combine(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func == (lhs: EventModel, rhs: EventModel) -> Bool {
|
static func == (lhs: EventModel, rhs: EventModel) -> Bool {
|
||||||
@ -34,5 +36,6 @@ struct EventModel: Identifiable, Hashable {
|
|||||||
&& lhs.coordinate.longitude == rhs.coordinate.longitude
|
&& lhs.coordinate.longitude == rhs.coordinate.longitude
|
||||||
&& lhs.address == rhs.address
|
&& lhs.address == rhs.address
|
||||||
&& lhs.isMe == rhs.isMe
|
&& lhs.isMe == rhs.isMe
|
||||||
|
&& lhs.user == rhs.user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,11 @@ struct EventsScreen: View {
|
|||||||
Text(event.address)
|
Text(event.address)
|
||||||
Text(event.date)
|
Text(event.date)
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
|
if let user = event.user, !event.isMe, viewModel.shouldDisplayEventAuthors {
|
||||||
|
Text(user)
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundStyle(.teal)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
Image(systemName: event.isMe ? "person.fill" : "person")
|
Image(systemName: event.isMe ? "person.fill" : "person")
|
||||||
|
|||||||
@ -45,6 +45,11 @@ class EventsViewModel: ACHudContainer {
|
|||||||
UIPasteboard.general.data(forPasteboardType: UTType.vehicleEvent.identifier) != nil
|
UIPasteboard.general.data(forPasteboardType: UTType.vehicleEvent.identifier) != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shouldDisplayEventAuthors: Bool {
|
||||||
|
|
||||||
|
settingsService.user.hasPermission(.locationAuthor)
|
||||||
|
}
|
||||||
|
|
||||||
init(apiService: ApiServiceProtocol,
|
init(apiService: ApiServiceProtocol,
|
||||||
storageService: StorageServiceProtocol,
|
storageService: StorageServiceProtocol,
|
||||||
settingsService: SettingsServiceProtocol,
|
settingsService: SettingsServiceProtocol,
|
||||||
@ -73,7 +78,8 @@ class EventsViewModel: ACHudContainer {
|
|||||||
date: dateString,
|
date: dateString,
|
||||||
coordinate: coordinate,
|
coordinate: coordinate,
|
||||||
address: event.address ?? "Lat: \(event.latitude), Lon: \(event.longitude)",
|
address: event.address ?? "Lat: \(event.latitude), Lon: \(event.longitude)",
|
||||||
isMe: event.addedBy == email
|
isMe: event.addedBy == email,
|
||||||
|
user: event.addedBy
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,25 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
public enum Permission: String, CaseIterable, Sendable {
|
||||||
|
|
||||||
|
case locationAuthor
|
||||||
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public struct User: Codable, Sendable {
|
public struct User: Codable, Sendable {
|
||||||
public let email: String
|
public let email: String
|
||||||
public var token: String
|
public var token: String
|
||||||
public var firebaseIdToken: String?
|
public var firebaseIdToken: String?
|
||||||
public var firebaseRefreshToken: String?
|
public var firebaseRefreshToken: String?
|
||||||
|
public var permissions: [String]?
|
||||||
|
|
||||||
public init(email: String = "", token: String = "") {
|
public init(email: String = "", token: String = "") {
|
||||||
self.email = email
|
self.email = email
|
||||||
self.token = token
|
self.token = token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func hasPermission(_ permission: Permission) -> Bool {
|
||||||
|
|
||||||
|
permissions?.contains(permission.rawValue) == true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user