diff --git a/app-ios/Sources/EventMapFeature/EventItem.swift b/app-ios/Sources/EventMapFeature/EventItem.swift index 7101bddd1..3dc45cf6e 100644 --- a/app-ios/Sources/EventMapFeature/EventItem.swift +++ b/app-ios/Sources/EventMapFeature/EventItem.swift @@ -1,7 +1,7 @@ import SwiftUI import CommonComponents import Theme -import shared +import Model struct EventItem: View { let event: EventMapEvent @@ -24,7 +24,7 @@ struct EventItem: View { .padding(.bottom, 8) VStack(alignment: .leading ,spacing: 8) { - Text(event.description_.currentLangTitle) + Text(event.description.currentLangTitle) .foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor) .textStyle(.bodyLarge) @@ -34,7 +34,7 @@ struct EventItem: View { .textStyle(.bodyMedium) } - if let urlString = event.moreDetailsUrl, let url = URL(string: urlString) { + if let url = event.moreDetailsUrl { Button { onTappedMoreDetail(url) } label: { @@ -61,5 +61,14 @@ struct EventItem: View { } #Preview { - EventItem(event: EventMapEvent.companion.fakes().first!) { _ in } + EventItem( + event: .init( + name: .init(currentLangTitle: "name", enTitle: "name", jaTitle: "name"), + roomName: .init(currentLangTitle: "roomName", enTitle: "roomName", jaTitle: "roomName"), + roomIcon: .square, + description: .init(currentLangTitle: "description", enTitle: "description", jaTitle: "description"), + moreDetailsUrl: nil, + message: nil + ) + ) { _ in } } diff --git a/app-ios/Sources/EventMapFeature/EventMapReducer.swift b/app-ios/Sources/EventMapFeature/EventMapReducer.swift index a4a5aa672..c3953ee5d 100644 --- a/app-ios/Sources/EventMapFeature/EventMapReducer.swift +++ b/app-ios/Sources/EventMapFeature/EventMapReducer.swift @@ -2,7 +2,6 @@ import ComposableArchitecture import KMPClient import Model import Foundation -@preconcurrency import shared @Reducer public struct EventMapReducer: Sendable { @@ -19,19 +18,19 @@ public struct EventMapReducer: Sendable { public init() { } } - public enum Action: BindableAction { + public enum Action: Sendable, BindableAction { case binding(BindingAction) case view(View) case `internal`(Internal) @CasePathable - public enum View { + public enum View: Sendable { case onAppear case selectFloorMap(FloorMap) case moreDetailButtonTapped(URL) } - public enum Internal { + public enum Internal: Sendable { case response(Result<[EventMapEvent], any Error>) } } diff --git a/app-ios/Sources/EventMapFeature/Model/FloorMap.swift b/app-ios/Sources/EventMapFeature/Model/FloorMap.swift index a5647a2fd..52707d179 100644 --- a/app-ios/Sources/EventMapFeature/Model/FloorMap.swift +++ b/app-ios/Sources/EventMapFeature/Model/FloorMap.swift @@ -2,7 +2,7 @@ import Foundation import Model import SwiftUI -public enum FloorMap { +public enum FloorMap: Sendable { case first case firstBasement } diff --git a/app-ios/Sources/KMPClient/Client.swift b/app-ios/Sources/KMPClient/Client.swift index 03313a8d6..d521a1d54 100644 --- a/app-ios/Sources/KMPClient/Client.swift +++ b/app-ios/Sources/KMPClient/Client.swift @@ -86,7 +86,7 @@ public struct ContributorClient: Sendable { @DependencyClient public struct EventMapClient: Sendable { - public var streamEvents: @Sendable () throws -> AsyncThrowingStream<[EventMapEvent], any Error> + public var streamEvents: @Sendable () throws -> AsyncThrowingStream<[Model.EventMapEvent], any Error> } @DependencyClient diff --git a/app-ios/Sources/KMPClientLive/LiveKey.swift b/app-ios/Sources/KMPClientLive/LiveKey.swift index 6d7949d63..a7de0bbe5 100644 --- a/app-ios/Sources/KMPClientLive/LiveKey.swift +++ b/app-ios/Sources/KMPClientLive/LiveKey.swift @@ -136,7 +136,39 @@ extension ContributorClient: DependencyKey { extension EventMapClient: DependencyKey { public static let liveValue: EventMapClient = .init { - eventMapRepository.getEventMapStream().eraseToThrowingStream() + eventMapRepository + .getEventMapStream() + .map { + $0.map { + Model.EventMapEvent( + name: .init( + currentLangTitle: $0.name.currentLangTitle, + enTitle: $0.name.enTitle, + jaTitle: $0.name.jaTitle + ), + roomName: .init( + currentLangTitle: $0.roomName.currentLangTitle, + enTitle: $0.roomName.enTitle, + jaTitle: $0.roomName.jaTitle + ), + roomIcon: RoomIcon(rawValue: $0.roomIcon.name.lowercased()) ?? .none, + description: .init( + currentLangTitle: $0.description_.currentLangTitle, + enTitle: $0.description_.enTitle, + jaTitle: $0.description_.jaTitle + ), + moreDetailsUrl: $0.moreDetailsUrl.flatMap(URL.init(string:)), + message: $0.message.map { + .init( + currentLangTitle: $0.currentLangTitle, + enTitle: $0.enTitle, + jaTitle: $0.jaTitle + ) + } + ) + } + } + .eraseToThrowingStream() } } diff --git a/app-ios/Sources/Model/Entity/EventMapEvent.swift b/app-ios/Sources/Model/Entity/EventMapEvent.swift new file mode 100644 index 000000000..93f087c2e --- /dev/null +++ b/app-ios/Sources/Model/Entity/EventMapEvent.swift @@ -0,0 +1,24 @@ +import Foundation + +public struct EventMapEvent: Equatable, Sendable, Hashable { + public let name: MultiLangText + public let roomName: MultiLangText + public let roomIcon: RoomIcon + public let description: MultiLangText + public let moreDetailsUrl: URL? + public let message: MultiLangText? + + public init(name: MultiLangText, roomName: MultiLangText, roomIcon: RoomIcon, description: MultiLangText, moreDetailsUrl: URL?, message: MultiLangText?) { + self.name = name + self.roomName = roomName + self.roomIcon = roomIcon + self.description = description + self.moreDetailsUrl = moreDetailsUrl + self.message = message + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(name.enTitle) + hasher.combine(roomName.enTitle) + } +} diff --git a/app-ios/Sources/Model/Entity/MultiLangText.swift b/app-ios/Sources/Model/Entity/MultiLangText.swift index e2a5c708b..e3c458d3e 100644 --- a/app-ios/Sources/Model/Entity/MultiLangText.swift +++ b/app-ios/Sources/Model/Entity/MultiLangText.swift @@ -1,6 +1,6 @@ import Foundation -public struct MultiLangText { +public struct MultiLangText: Equatable, Sendable { public let currentLangTitle: String public let enTitle: String public let jaTitle: String diff --git a/app-ios/Sources/Model/Entity/RoomIcon.swift b/app-ios/Sources/Model/Entity/RoomIcon.swift new file mode 100644 index 000000000..ae46a723b --- /dev/null +++ b/app-ios/Sources/Model/Entity/RoomIcon.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum RoomIcon: String, Sendable { + case square + case circle + case diamond + case rhombus + case triangle + case none +}