HistoryView: Compact UI for phones
This commit is contained in:
@@ -19,16 +19,25 @@ struct HistoryView: View {
|
||||
}
|
||||
|
||||
@Environment(\.dismiss) private var dismissAction
|
||||
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
var body: some View {
|
||||
Table(viewModel.historyItems, selection: $selectedItems) {
|
||||
TableColumn("Title", value: \.title)
|
||||
|
||||
TableColumn("URL") { item in
|
||||
Text(item.url.absoluteString)
|
||||
TableColumn("Title") { item in
|
||||
VStack(alignment: .leading) {
|
||||
Text(item.title.count > 0 ? item.title : item.url.absoluteString)
|
||||
.lineLimit(1)
|
||||
|
||||
if horizontalSizeClass == .compact {
|
||||
Text(item.url.shortString()).font(.caption).lineLimit(1)
|
||||
Text(dateFormatter.string(from: item.lastVisited))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableColumn("Last Visited") { item in
|
||||
TableColumn("URL", value: \.url.absoluteString)
|
||||
TableColumn("Last Visited") { item in
|
||||
Text(dateFormatter.string(from: item.lastVisited))
|
||||
}
|
||||
}
|
||||
@@ -61,3 +70,9 @@ struct HistoryViewPreviewProvider: PreviewProvider {
|
||||
}
|
||||
}
|
||||
|
||||
extension URL {
|
||||
public func shortString() -> String {
|
||||
return String(absoluteString.trimmingPrefix(try! Regex("(.+)://")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user