Skip to content

Commit

Permalink
EventHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
kasianov-mikhail committed Nov 29, 2024
1 parent d49e77a commit 048a7b9
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions Sources/Scout/UI/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ struct EventView: View {

@EnvironmentObject var tint: Tint

let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.y, HH:mm"
return formatter
}()

init(event: Event, showHistory: Bool) {
self.event = event
self.showHistory = showHistory
Expand All @@ -29,25 +23,7 @@ struct EventView: View {
let color = event.level?.color

List {
VStack(alignment: .leading) {
if let date = event.date {
Text(dateFormatter.string(from: date))
.font(.system(size: 16))
.monospaced()
}

Spacer().frame(height: 10)

if let level = event.level {
Group {
Text("LEVEL: ")
+ Text(level.description.uppercased()).foregroundColor(
level.color ?? .blue)
}
.fontWeight(.bold)
}
}
.padding(.vertical, 4)
EventHeader(event: event)

if let paramCount = event.paramCount, paramCount > 0 {
ParamSection(
Expand Down Expand Up @@ -75,6 +51,42 @@ struct EventView: View {
}
}

// MARK: - Header

extension EventView {
static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.y, HH:mm"
return formatter
}()

struct EventHeader: View {
let event: Event

var body: some View {
VStack(alignment: .leading) {
if let date = event.date {
Text(dateFormatter.string(from: date))
.font(.system(size: 16))
.monospaced()
}

Spacer().frame(height: 10)

if let level = event.level {
Group {
Text("LEVEL: ")
+ Text(level.description.uppercased()).foregroundColor(
level.color ?? .blue)
}
.fontWeight(.bold)
}
}
.padding(.vertical, 4)
}
}
}

// MARK: - Sections

extension EventView {
Expand Down

0 comments on commit 048a7b9

Please sign in to comment.