Skip to content

Commit d626b52

Browse files
committed
Use TitleAndTextFieldRow and ListHeaderView for content
1 parent d83625f commit d626b52

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

WooCommerce/Classes/ViewRelated/Bookings/Booking Details/BookingDetailsView.swift

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import WooFoundation
33
import Networking
44

55
struct BookingDetailsView: View {
6+
@Environment(\.safeAreaInsets) var safeAreaInsets: EdgeInsets
7+
68
@ObservedObject private var viewModel: BookingDetailsViewModel
79

810
private enum Layout {
@@ -39,7 +41,6 @@ struct BookingDetailsView: View {
3941
VStack(alignment: .leading, spacing: .zero) {
4042
ForEach(viewModel.sections) { section in
4143
sectionView(with: section)
42-
Divider()
4344
}
4445
}
4546
}
@@ -52,21 +53,20 @@ private extension BookingDetailsView {
5253
func sectionView(with section: BookingDetailsViewModel.Section) -> some View {
5354
VStack(alignment: .leading, spacing: 0) {
5455
if let headerText = section.headerText {
55-
Text(headerText)
56-
.font(.footnote)
57-
.foregroundColor(.gray)
58-
.padding(.vertical)
59-
.padding(.horizontal, Layout.contentSidePadding)
60-
Divider()
56+
ListHeaderView(
57+
text: headerText,
58+
alignment: .left
59+
)
60+
.padding(.horizontal, insets: safeAreaInsets)
61+
.accessibility(addTraits: .isHeader)
6162
}
6263

6364
sectionContentView(section.content)
6465
.padding(.horizontal, Layout.contentSidePadding)
65-
.padding(.vertical, 10)
6666
.background(Color(uiColor: .listBackground))
67+
.addingTopAndBottomDividers()
6768

6869
if let footerText = section.footerText {
69-
Divider()
7070
Text(footerText)
7171
.padding(.horizontal, Layout.contentSidePadding)
7272
.font(.footnote)
@@ -113,10 +113,17 @@ private extension BookingDetailsView {
113113
}
114114

115115
func appointmentDetailsView(with content: BookingDetailsViewModel.AppointmentDetailsContent) -> some View {
116-
VStack(alignment: .leading) {
116+
VStack(alignment: .leading, spacing: 0) {
117117
ForEach(content.rows) { row in
118-
DetailRow(title: row.title, value: row.value)
119-
.padding(.vertical, Layout.appointmentDetailsRowVerticalPadding)
118+
TitleAndTextFieldRow(
119+
title: row.title,
120+
placeholder: String(),
121+
text: .constant(row.value),
122+
fieldAlignment: .trailing,
123+
keyboardType: .default,
124+
minHeight: 44,
125+
horizontalPadding: 0 // Parent section padding is added elsewhere,
126+
)
120127

121128
if row.id != content.rows.last?.id {
122129
Divider()
@@ -127,21 +134,6 @@ private extension BookingDetailsView {
127134
}
128135
}
129136

130-
struct DetailRow: View {
131-
let title: String
132-
let value: String
133-
var body: some View {
134-
HStack {
135-
Text(title)
136-
.font(BookingDetailsView.TextFont.bodyMedium)
137-
Spacer()
138-
Text(value)
139-
.font(BookingDetailsView.TextFont.bodyRegular)
140-
.foregroundColor(.secondary)
141-
}
142-
}
143-
}
144-
145137
#if DEBUG
146138
struct BookingDetailsView_Previews: PreviewProvider {
147139
static var previews: some View {

0 commit comments

Comments
 (0)