Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bottom divider to SettingsViewIconCell (needed for accessibility statement task) #1342

Merged
merged 4 commits into from
May 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ struct SettingsViewIconCell: View {
let title: String
let icon: UIImage
let tintColor: Color?
let isLastItem: Bool

var body: some View {
HStack(alignment: .center) {
Expand All @@ -20,12 +21,38 @@ struct SettingsViewIconCell: View {
.frame(width: .spacingM, height: .spacingM)
.foregroundColor(tintColor)
.padding([.trailing], .spacingXL)
}
}.bottomDivider(!isLastItem)
}
}

extension View {
func bottomDivider(
_ isLastItem: Bool,
inset: EdgeInsets = EdgeInsets(top: 0, leading: .spacingM, bottom: 0, trailing: 0)
) -> some View {
modifier(BottomDivider(isLastItem: isLastItem, inset: inset))
}
}

struct SettingsViewIconCell_Previews: PreviewProvider {
static var previews: some View {
SettingsViewIconCell(title: "Personvernerklæring", icon: .init(systemName: "square.and.arrow.up")!, tintColor: .bgSuccess) // swiftlint:disable:this force_unwrapping
SettingsViewIconCell(title: "Personvernerklæring", icon: .init(systemName: "square.and.arrow.up")!, tintColor: .bgSuccess, isLastItem: false) // swiftlint:disable:this force_unwrapping
}
}

struct BottomDivider: ViewModifier {
let isLastItem: Bool
let inset: EdgeInsets

public func body(content: Content) -> some View {
ZStack {
content
if isLastItem {
VStack {
Spacer()
Divider().padding(inset)
}
}
}.listRowInsets(EdgeInsets())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ extension SettingsView: UITableViewDataSource {
let (icon, tintColor) = iconModel.icon

cell.contentConfiguration = HostingContentConfiguration(content: {
SettingsViewIconCell(title: iconModel.title, icon: icon, tintColor: tintColor)
SettingsViewIconCell(title: iconModel.title, icon: icon, tintColor: tintColor, isLastItem: isLastItem)
})
return cell
default:
Expand Down