Skip to content

Commit b41b947

Browse files
[PM-21624] Remove divider from SettingListItem (#1580)
1 parent 6aee643 commit b41b947

File tree

10 files changed

+20
-63
lines changed

10 files changed

+20
-63
lines changed

BitwardenShared/Core/Platform/Models/Enum/LanguageOption.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public enum LanguageOption: Equatable, Sendable {
6666

6767
// MARK: Properties
6868

69-
/// Whether the language option is the last one in the list.
70-
var isLast: Bool {
71-
switch self {
72-
case .default:
73-
false
74-
case let .custom(languageCode: languageCode):
75-
languageCode == LanguageOption.allCases.last?.value
76-
}
77-
}
78-
7969
/// The title of the language option as it appears in the list of options.
8070
var title: String {
8171
switch self {

BitwardenShared/UI/Platform/Settings/Settings/About/AboutView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct AboutView: View {
7373
accessibilityIdentifier: "FlightRecorderSwitch"
7474
)
7575

76-
SettingsListItem(Localizations.viewRecordedLogs, hasDivider: false) {
76+
SettingsListItem(Localizations.viewRecordedLogs) {
7777
store.send(.viewFlightRecorderLogsTapped)
7878
}
7979
}
@@ -91,7 +91,7 @@ struct AboutView: View {
9191

9292
externalLinkRow(Localizations.learnOrg, action: .learnAboutOrganizationsTapped)
9393

94-
SettingsListItem(store.state.version, hasDivider: false) {
94+
SettingsListItem(store.state.version) {
9595
store.send(.versionTapped)
9696
} trailingContent: {
9797
Asset.Images.copy24.swiftUIImage
@@ -122,7 +122,7 @@ struct AboutView: View {
122122
/// - Returns: A `SettingsListItem` configured for an external web link.
123123
///
124124
private func externalLinkRow(_ name: String, action: AboutAction) -> some View {
125-
SettingsListItem(name, hasDivider: false) {
125+
SettingsListItem(name) {
126126
store.send(action)
127127
} trailingContent: {
128128
Asset.Images.externalLink24.swiftUIImage

BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityView.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ struct AccountSecurityView: View {
8080
ContentBlock(dividerLeadingPadding: 16) {
8181
SettingsListItem(
8282
Localizations.accountFingerprintPhrase,
83-
hasDivider: false,
8483
accessibilityIdentifier: "AccountFingerprintPhraseLabel"
8584
) {
8685
Task {
@@ -90,7 +89,6 @@ struct AccountSecurityView: View {
9089

9190
SettingsListItem(
9291
Localizations.twoStepLogin,
93-
hasDivider: false,
9492
accessibilityIdentifier: "TwoStepLoginLinkItemView"
9593
) {
9694
store.send(.twoStepLoginPressed)
@@ -102,7 +100,6 @@ struct AccountSecurityView: View {
102100
if store.state.isLockNowVisible {
103101
SettingsListItem(
104102
Localizations.lockNow,
105-
hasDivider: false,
106103
accessibilityIdentifier: "LockNowLabel"
107104
) {
108105
Task {
@@ -113,15 +110,13 @@ struct AccountSecurityView: View {
113110

114111
SettingsListItem(
115112
Localizations.logOut,
116-
hasDivider: false,
117113
accessibilityIdentifier: "LogOutLabel"
118114
) {
119115
store.send(.logout)
120116
}
121117

122118
SettingsListItem(
123119
Localizations.deleteAccount,
124-
hasDivider: false,
125120
accessibilityIdentifier: "DeleteAccountLabel"
126121
) {
127122
store.send(.deleteAccountPressed)
@@ -135,7 +130,6 @@ struct AccountSecurityView: View {
135130
SectionView(Localizations.approveLoginRequests) {
136131
SettingsListItem(
137132
Localizations.pendingLogInRequests,
138-
hasDivider: false,
139133
accessibilityIdentifier: "PendingLogInRequestsLabel"
140134
) {
141135
store.send(.pendingLoginRequestsTapped)

BitwardenShared/UI/Platform/Settings/Settings/Appearance/SelectLanguage/SelectLanguageView.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ struct SelectLanguageView: View {
1313
// MARK: View
1414

1515
var body: some View {
16-
VStack(spacing: 0) {
16+
ContentBlock(dividerLeadingPadding: 16) {
1717
ForEach(LanguageOption.allCases) { languageOption in
1818
languageOptionRow(languageOption)
1919
}
2020
}
21-
.background(Asset.Colors.backgroundSecondary.swiftUIColor)
22-
.cornerRadius(10)
2321
.scrollView()
2422
.navigationBar(title: Localizations.selectLanguage, titleDisplayMode: .inline)
2523
.toolbar {
@@ -42,10 +40,7 @@ struct SelectLanguageView: View {
4240

4341
/// Construct the row for the language option.
4442
private func languageOptionRow(_ languageOption: LanguageOption) -> some View {
45-
SettingsListItem(
46-
languageOption.title,
47-
hasDivider: !languageOption.isLast
48-
) {
43+
SettingsListItem(languageOption.title) {
4944
store.send(.languageTapped(languageOption))
5045
} trailingContent: {
5146
checkmarkView(languageOption)

BitwardenShared/UI/Platform/Settings/Settings/AutoFill/AutoFillView.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ struct AutoFillView: View {
8181
private var autoFillSection: some View {
8282
SectionView(Localizations.autofill, contentSpacing: 8) {
8383
ContentBlock(dividerLeadingPadding: 16) {
84-
SettingsListItem(Localizations.passwordAutofill, hasDivider: false) {
84+
SettingsListItem(Localizations.passwordAutofill) {
8585
store.send(.passwordAutoFillTapped)
8686
}
8787

88-
SettingsListItem(
89-
Localizations.appExtension,
90-
hasDivider: false
91-
) {
88+
SettingsListItem(Localizations.appExtension) {
9289
store.send(.appExtensionTapped)
9390
}
9491
}

BitwardenShared/UI/Platform/Settings/Settings/SettingsListItem.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ struct SettingsListItem<Content: View>: View {
1616
/// An optional string to display as the badge next to the trailing content.
1717
let badgeValue: String?
1818

19-
/// Whether or not the list item should have a divider on the bottom.
20-
let hasDivider: Bool
21-
2219
/// The optional icon to display on the leading edge of the list item.
2320
let icon: ImageAsset?
2421

@@ -63,11 +60,6 @@ struct SettingsListItem<Content: View>: View {
6360
.multilineTextAlignment(.trailing)
6461
}
6562
.padding(.horizontal, icon == nil ? 16 : 12)
66-
67-
if hasDivider {
68-
Divider()
69-
.padding(.leading, icon == nil ? 16 : 48)
70-
}
7163
}
7264
}
7365
.accessibilityIdentifier(accessibilityIdentifier ?? "")
@@ -80,7 +72,6 @@ struct SettingsListItem<Content: View>: View {
8072
///
8173
/// - Parameters:
8274
/// - name: The name of the list item.
83-
/// - hasDivider: Whether or not the list item should have a divider on the bottom.
8475
/// - accessibilityIdentifier: The accessibility ID for the list item.
8576
/// - badgeValue: An optional string to display as the badge next to the trailing content.
8677
/// - icon: The optional icon to display on the leading edge of the list item.
@@ -92,7 +83,6 @@ struct SettingsListItem<Content: View>: View {
9283
///
9384
init(
9485
_ name: String,
95-
hasDivider: Bool = true,
9686
accessibilityIdentifier: String? = nil,
9787
badgeValue: String? = nil,
9888
icon: ImageAsset? = nil,
@@ -103,7 +93,6 @@ struct SettingsListItem<Content: View>: View {
10393
self.accessibilityIdentifier = accessibilityIdentifier
10494
self.badgeValue = badgeValue
10595
self.name = name
106-
self.hasDivider = hasDivider
10796
self.icon = icon
10897
self.nameAccessibilityID = nameAccessibilityID
10998
self.trailingContent = trailingContent
@@ -116,7 +105,7 @@ struct SettingsListItem<Content: View>: View {
116105
#if DEBUG
117106
#Preview {
118107
ScrollView {
119-
VStack(spacing: 0) {
108+
ContentBlock(dividerLeadingPadding: 16) {
120109
SettingsListItem("Account Security", icon: Asset.Images.locked24) {} trailingContent: {
121110
Text("Trailing content")
122111
}
@@ -134,5 +123,7 @@ struct SettingsListItem<Content: View>: View {
134123
}
135124
}
136125
}
126+
.padding()
127+
.background(Asset.Colors.backgroundPrimary.swiftUIColor)
137128
}
138129
#endif

BitwardenShared/UI/Platform/Settings/Settings/SettingsView.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ struct SettingsView: View {
5757
private var aboutRow: some View {
5858
SettingsListItem(
5959
Localizations.about,
60-
hasDivider: false,
6160
icon: Asset.Images.informationCircle24
6261
) {
6362
store.send(.aboutPressed)
@@ -71,7 +70,6 @@ struct SettingsView: View {
7170
private var accountSecurityRow: some View {
7271
SettingsListItem(
7372
Localizations.accountSecurity,
74-
hasDivider: false,
7573
badgeValue: store.state.accountSecurityBadgeValue,
7674
icon: Asset.Images.locked24
7775
) {
@@ -84,7 +82,7 @@ struct SettingsView: View {
8482

8583
/// The appearance settings row.
8684
private var appearanceRow: some View {
87-
SettingsListItem(Localizations.appearance, hasDivider: false, icon: Asset.Images.paintBrush) {
85+
SettingsListItem(Localizations.appearance, icon: Asset.Images.paintBrush) {
8886
store.send(.appearancePressed)
8987
} trailingContent: {
9088
chevron
@@ -96,7 +94,6 @@ struct SettingsView: View {
9694
private var autofillRow: some View {
9795
SettingsListItem(
9896
Localizations.autofill,
99-
hasDivider: false,
10097
badgeValue: store.state.autofillBadgeValue,
10198
icon: Asset.Images.checkCircle24
10299
) {
@@ -109,7 +106,7 @@ struct SettingsView: View {
109106

110107
/// The other settings row.
111108
private var otherRow: some View {
112-
SettingsListItem(Localizations.other, hasDivider: false, icon: Asset.Images.other) {
109+
SettingsListItem(Localizations.other, icon: Asset.Images.other) {
113110
store.send(.otherPressed)
114111
} trailingContent: {
115112
chevron
@@ -121,7 +118,6 @@ struct SettingsView: View {
121118
private var vaultRow: some View {
122119
SettingsListItem(
123120
Localizations.vault,
124-
hasDivider: false,
125121
badgeValue: store.state.vaultBadgeValue,
126122
icon: Asset.Images.vaultSettings
127123
) {

BitwardenShared/UI/Platform/Settings/Settings/Vault/ExportVault/ExportSettings/ExportSettingsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ struct ExportSettingsView: View {
1414

1515
var body: some View {
1616
VStack(alignment: .leading, spacing: 16) {
17-
SettingsListItem(Localizations.exportVaultToAFile, hasDivider: false) {
17+
SettingsListItem(Localizations.exportVaultToAFile) {
1818
store.send(.exportToFileTapped)
1919
} trailingContent: {
2020
chevron
2121
}
2222
.accessibilityIdentifier("ExportVaultToAFileLabel")
2323
.cornerRadius(10)
2424

25-
SettingsListItem(Localizations.exportVaultToAnotherApp, hasDivider: false) {
25+
SettingsListItem(Localizations.exportVaultToAnotherApp) {
2626
store.send(.exportToAppTapped)
2727
} trailingContent: {
2828
chevron

BitwardenShared/UI/Platform/Settings/Settings/Vault/Folders/FoldersView.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ struct FoldersView: View {
5353

5454
/// The section listing all the user's folders.
5555
private var folders: some View {
56-
VStack(spacing: 0) {
57-
ForEachIndexed(
56+
ContentBlock(dividerLeadingPadding: 16) {
57+
ForEach(
5858
store.state.folders.sorted { first, second in
5959
if first.name.localizedStandardCompare(second.name) == .orderedSame {
6060
first.id?.localizedStandardCompare(second.id ?? "") == .orderedAscending
@@ -63,19 +63,14 @@ struct FoldersView: View {
6363
}
6464
},
6565
id: \.id
66-
) { index, folder in
67-
SettingsListItem(
68-
folder.name,
69-
hasDivider: index < (store.state.folders.count - 1),
70-
nameAccessibilityID: "FolderName"
71-
) {
66+
) { folder in
67+
SettingsListItem(folder.name, nameAccessibilityID: "FolderName") {
7268
guard let id = folder.id else { return }
7369
store.send(.folderTapped(id: id))
7470
}
7571
.accessibilityIdentifier("FolderCell")
7672
}
7773
}
78-
.clipShape(RoundedRectangle(cornerRadius: 10))
7974
.padding(.bottom, FloatingActionButton.bottomOffsetPadding)
8075
}
8176
}

BitwardenShared/UI/Platform/Settings/Settings/Vault/VaultSettingsView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct VaultSettingsView: View {
5656

5757
/// The vault settings section.
5858
private var vaultSettings: some View {
59-
VStack(spacing: 0) {
59+
ContentBlock(dividerLeadingPadding: 16) {
6060
SettingsListItem(Localizations.folders) {
6161
store.send(.foldersTapped)
6262
}
@@ -67,15 +67,14 @@ struct VaultSettingsView: View {
6767
}
6868
.accessibilityIdentifier("ExportVaultLabel")
6969

70-
SettingsListItem(Localizations.importItems, hasDivider: false) {
70+
SettingsListItem(Localizations.importItems) {
7171
store.send(.importItemsTapped)
7272
} trailingContent: {
7373
Image(asset: Asset.Images.externalLink24)
7474
.imageStyle(.rowIcon)
7575
}
7676
.accessibilityIdentifier("ImportItemsLinkItemView")
7777
}
78-
.clipShape(RoundedRectangle(cornerRadius: 10))
7978
}
8079
}
8180

0 commit comments

Comments
 (0)