Skip to content

Commit 0c88ece

Browse files
committed
make POSInformationCardFieldRowWithToggle
1 parent e0441ae commit 0c88ece

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import SwiftUI
2+
3+
struct POSInformationCardFieldRowWithToggle: View {
4+
let label: String
5+
let value: String
6+
let showSeparator: Bool
7+
@Binding var isOn: Bool
8+
9+
init(label: String,
10+
value: String,
11+
showSeparator: Bool = true,
12+
isOn: Binding<Bool>) {
13+
self.label = label
14+
self.value = value
15+
self.showSeparator = showSeparator
16+
self._isOn = isOn
17+
}
18+
19+
var body: some View {
20+
VStack(alignment: .leading, spacing: POSPadding.small) {
21+
HStack(alignment: .center, spacing: POSSpacing.medium) {
22+
VStack(alignment: .leading, spacing: POSPadding.small) {
23+
Text(label)
24+
.font(.posBodyMediumRegular())
25+
Text(value)
26+
.font(.posBodyMediumRegular())
27+
.foregroundStyle(.secondary)
28+
}
29+
30+
Spacer()
31+
32+
Toggle("", isOn: $isOn)
33+
.toggleStyle(SwitchToggleStyle())
34+
.tint(Color.posPrimaryContainer)
35+
}
36+
37+
if showSeparator {
38+
Divider()
39+
.padding(.top, POSPadding.small)
40+
}
41+
}
42+
.frame(maxWidth: .infinity, alignment: .leading)
43+
}
44+
}

Modules/Sources/PointOfSale/Presentation/Settings/POSSettingsLocalCatalogDetailView.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ private extension POSSettingsLocalCatalogDetailView {
5757

5858
@ViewBuilder
5959
var managingDataUsage: some View {
60+
@Bindable var viewModel = viewModel
6061
VStack(spacing: POSSpacing.none) {
6162
POSInformationCard {
62-
POSInformationCardFieldRow(label: Localization.managingDataUsage,
63-
value: Localization.allowSyncOnCellular,
64-
showSeparator: false,
65-
buttonAction: {
66-
viewModel.allowFullSyncOnCellular.toggle()
67-
})
63+
POSInformationCardFieldRowWithToggle(
64+
label: Localization.managingDataUsage,
65+
value: Localization.allowSyncOnCellular,
66+
showSeparator: false,
67+
isOn: $viewModel.allowFullSyncOnCellular
68+
)
6869
}
6970
}
7071
}

0 commit comments

Comments
 (0)