Skip to content
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
15 changes: 8 additions & 7 deletions MC1/Views/Chats/Components/MessagePathMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ struct MessagePathMapView: View {
)
.ignoresSafeArea()

PathDistanceBanner(
hopCount: hopCount,
totalPathDistance: totalPathDistance
)

VStack {
Spacer()
HStack {
Expand All @@ -116,9 +111,15 @@ struct MessagePathMapView: View {
}
}
}
.navigationTitle(L10n.Chats.Chats.Path.map)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
if !locatedNodes.isEmpty {
ToolbarItem(placement: .principal) {
PathDistanceBanner(
hopCount: hopCount,
totalPathDistance: totalPathDistance
)
}
}
ToolbarItem(placement: .confirmationAction) {
Button(L10n.Localizable.Common.done) { dismiss() }
}
Expand Down
33 changes: 13 additions & 20 deletions MC1/Views/Map/PathDistanceBanner.swift
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import MapKit
import SwiftUI

/// Floating top-of-map capsule summarizing a path: hop count and, when at least
/// two nodes have coordinates, the drawn-path distance.
/// Path summary shown in place of the map sheet's navigation title: hop count
/// and, when at least two nodes have coordinates, the drawn-path distance.
struct PathDistanceBanner: View {
private static let horizontalPadding: CGFloat = 16
private static let verticalPadding: CGFloat = 10
private static let verticalPadding: CGFloat = 8

let hopCount: Int
let totalPathDistance: CLLocationDistance?

var body: some View {
VStack {
HStack {
Text(L10n.Contacts.Contacts.Trace.Map.hops(hopCount))
if let distance = totalPathDistance {
Text("•")
Text(Measurement(value: distance, unit: UnitLength.meters),
format: .measurement(width: .abbreviated, usage: .road))
}
HStack(spacing: 4) {
Text(L10n.Contacts.Contacts.Trace.Map.hops(hopCount))
if let distance = totalPathDistance {
Text("•")
Text(Measurement(value: distance, unit: UnitLength.meters),
format: .measurement(width: .abbreviated, usage: .road))
}
.font(.subheadline.weight(.medium))
.padding(.horizontal, Self.horizontalPadding)
.padding(.vertical, Self.verticalPadding)
.liquidGlass(in: .capsule)

Spacer()
}
.frame(maxWidth: .infinity)
.safeAreaPadding(.top)
.transition(.move(edge: .top).combined(with: .opacity))
.font(.subheadline.weight(.medium))
.padding(.horizontal, Self.horizontalPadding)
.padding(.vertical, Self.verticalPadding)
.liquidGlass(in: .capsule)
}
}
Loading