Skip to content

Commit

Permalink
Adjusts RoundedRectangleSelectableListRowBackport.
Browse files Browse the repository at this point in the history
- From Apple Design Resources.
  • Loading branch information
mntone committed Jan 22, 2024
1 parent d558119 commit e12393e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/App/Views/Components/iOS/SelectableListRowBackport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ struct RoundedRectangleSelectableListRowBackport<Tag: Equatable, Content: View>:
@Binding
var selection: Tag

@ScaledMetric(relativeTo: .body)
private var verticalPadding: CGFloat = 11.0

init(tag: Tag,
selection: Binding<Tag>,
@ViewBuilder content: () -> Content) {
Expand All @@ -21,11 +24,14 @@ struct RoundedRectangleSelectableListRowBackport<Tag: Equatable, Content: View>:
}

var body: some View {
let shape = RoundedRectangle(cornerRadius: 8)
let shape = RoundedRectangle(cornerRadius: 11.0)
let isSelected = tag == selection
content
.foregroundStyle(isSelected ? .white : .primary)
.layoutMargin()
.padding(EdgeInsets(top: verticalPadding,
leading: 8.0,
bottom: verticalPadding,
trailing: 8.0))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.background(isSelected ? Color.accentColor : .clear, in: shape)
.contentShape(shape) // Fix tap area
Expand Down
1 change: 0 additions & 1 deletion src/App/Views/Sidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct SidebarBackport: View {
List(viewModel.items) { item in
RoundedRectangleSelectableListRowBackport(tag: item.id, selection: $selection) {
Text(item.name)
.preferredVerticalPadding()
}
}
.injectHorizontalLayoutMargin()
Expand Down

0 comments on commit e12393e

Please sign in to comment.