Skip to content

Commit

Permalink
set ridetime in list item view
Browse files Browse the repository at this point in the history
  • Loading branch information
mltbnz committed Sep 30, 2024
1 parent 097ec12 commit af5443e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
84 changes: 46 additions & 38 deletions CriticalMapsKit/Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,45 +175,14 @@ public struct AppView: View {
func bottomSheetContentView() -> some View {
VStack {
List(viewStore.nextRideState.rideEvents, id: \.id) { ride in
HStack(alignment: .center, spacing: .grid(2)) {
Image(uiImage: Asset.cm.image)
.accessibilityHidden(true)

VStack(alignment: .leading, spacing: .grid(1)) {
Text(ride.title)
.multilineTextAlignment(.leading)
.font(Font.body.weight(.semibold))
.foregroundColor(Color(.textPrimary))
.padding(.bottom, .grid(1))

VStack(alignment: .leading, spacing: 2) {
Label(ride.dateTime.humanReadableDate, systemImage: "calendar")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))

Label(ride.dateTime.humanReadableTime, systemImage: "clock")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))

if let location = ride.location {
Label(location, systemImage: "location.fill")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))
}
}
RideEventView(ride: ride)
.contentShape(Rectangle())
.padding(.vertical, .grid(1))
.accessibilityElement(children: .combine)
.onTapGesture {
viewStore.send(.onRideSelectedFromBottomSheet(ride))
}
Spacer()
}
.contentShape(Rectangle())
.padding(.vertical, .grid(1))
.accessibilityElement(children: .combine)
.onTapGesture {
viewStore.send(.onRideSelectedFromBottomSheet(ride))
}
.listRowBackground(Color.clear)
.listRowBackground(Color.clear)
}
.listStyle(.plain)
}
Expand Down Expand Up @@ -297,3 +266,42 @@ struct NumericContentTransition: ViewModifier {
}
}
}

struct RideEventView: View {
let ride: Ride

var body: some View {
HStack(alignment: .center, spacing: .grid(2)) {
Image(uiImage: Asset.cm.image)
.accessibilityHidden(true)

VStack(alignment: .leading, spacing: .grid(1)) {
Text(ride.title)
.multilineTextAlignment(.leading)
.font(Font.body.weight(.semibold))
.foregroundColor(Color(.textPrimary))
.padding(.bottom, .grid(1))

VStack(alignment: .leading, spacing: 2) {
Label(ride.dateTime.humanReadableDate, systemImage: "calendar")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))

Label(ride.rideTime, systemImage: "clock")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))

if let location = ride.location {
Label(location, systemImage: "location.fill")
.multilineTextAlignment(.leading)
.font(.bodyTwo)
.foregroundColor(Color(.textSecondary))
}
}
}
Spacer()
}
}
}
5 changes: 0 additions & 5 deletions CriticalMapsKit/Sources/Helpers/Date+Additions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ public extension Date {
return component
}

/// - Returns: Formatted time without date components.
var humanReadableTime: String {
self.formatted(Date.FormatStyle.localeAwareShortTime)
}

/// - Returns: Formatted date without time components.
var humanReadableDate: String {
self.formatted(Date.FormatStyle.localeAwareShortDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public extension Ride {
{
return dateTime.formatted(Date.FormatStyle.shortTimeWithEventTimeZone(timeZone))
} else {
return dateTime.humanReadableTime
return dateTime.formatted(Date.FormatStyle.localeAwareShortTime)
}
}

Expand Down

0 comments on commit af5443e

Please sign in to comment.