Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS-3251 Version history | Add icon and date time title #1869

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

@MainActor
protocol VersionHistoryModuleOutput: AnyObject {
func onVersionTap(title: String, versionId: String)
func onVersionTap(title: String, icon: ObjectIcon?, versionId: String)
}

@MainActor
Expand All @@ -19,9 +19,10 @@ final class VersionHistoryCoordinatorViewModel: ObservableObject, VersionHistory

// MARK: VersionHistoryModuleOutput

func onVersionTap(title: String, versionId: String) {
func onVersionTap(title: String, icon: ObjectIcon?, versionId: String) {
objectVersionData = ObjectVersionData(
title: title,
icon: icon,
objectId: data.objectId,
versionId: versionId,
isListType: data.isListType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ struct ObjectVersionView: View {
private var header: some View {
VStack(spacing: 0) {
DragIndicator()
TitleView(title: model.data.title)
TitleView(title: model.data.title) {
ObjectIconView(icon: model.data.icon)
.frame(width: 24, height: 24)
}
}
.background(Color.Background.primary)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SwiftUI

struct ObjectVersionData: Identifiable, Hashable {
let title: String
let icon: ObjectIcon?
let objectId: String
let versionId: String
let isListType: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ final class VersionHistoryDataBuilder: VersionHistoryDataBuilderProtocol {
dateFormatter.timeStyle = .short
return dateFormatter
}()
private let dateTimeFormatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .short
return dateFormatter
}()

nonisolated init() { }

Expand Down Expand Up @@ -98,7 +104,8 @@ final class VersionHistoryDataBuilder: VersionHistoryDataBuilderProtocol {

private func buildVersionHistoryItem(for version: VersionHistory, participant: Participant) -> VersionHistoryItem {
VersionHistoryItem(
id: version.id,
id: version.id,
dateTime: buildDateTimeString(for: version),
time: buildTimeString(for: version),
author: participant.localName,
icon: participant.icon
Expand All @@ -110,6 +117,11 @@ final class VersionHistoryDataBuilder: VersionHistoryDataBuilderProtocol {
return dateFormatter.localizedString(for: date)
}

private func buildDateTimeString(for version: VersionHistory) -> String {
let date = buildDate(for: version)
return dateTimeFormatter.string(from: date)
}

private func buildTimeString(for version: VersionHistory) -> String {
let date = buildDate(for: version)
return timeFormatter.string(from: date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct VersionHistoryDataGroup: Identifiable, Hashable {

struct VersionHistoryItem: Identifiable, Hashable {
let id: String
let dateTime: String
let time: String
let author: String
let icon: ObjectIcon?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class VersionHistoryViewModel: ObservableObject {
}

func onVersionTap(_ version: VersionHistoryItem) {
output?.onVersionTap(title: version.time, versionId: version.id)
output?.onVersionTap(title: version.dateTime, icon: version.icon, versionId: version.id)
}

private func updateView() {
Expand Down
Loading