Skip to content

Commit

Permalink
Merge pull request #1877 from anyproto/ios-3160-link-section-change-r…
Browse files Browse the repository at this point in the history
…emove-icon

IOS-3160 Message Input | change icon and fix layout for linked objects
  • Loading branch information
mgolovko authored Aug 6, 2024
2 parents 3a041f4 + c5ce54c commit bced94f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct MessageLinkInputViewContainer: View {
let objects: [ObjectDetails]
let onTapRemove: (ObjectDetails) -> Void

@State private var itemWidth: CGFloat = 0
@State private var sizeWidth: CGFloat = 0

var body: some View {
if objects.isNotEmpty {
Expand All @@ -17,7 +17,7 @@ struct MessageLinkInputViewContainer: View {

private var content: some View {
ScrollView(.horizontal) {
HStack {
HStack(spacing: 12) {
ForEach(objects, id: \.id) {
MessageLinkObjectView(details: $0, style: .input, onTapRemove: onTapRemove)
.frame(width: itemWidth)
Expand All @@ -29,9 +29,14 @@ struct MessageLinkInputViewContainer: View {
.scrollIndicators(.hidden)
.background(Color.Background.primary)
.readSize { size in
itemWidth = size.width - 32
sizeWidth = size.width
}
}

private var itemWidth: CGFloat {
let width = sizeWidth - (objects.count > 1 ? 64 : 32)
return max(width, 0)
}
}

#Preview {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct MessageLinkObjectView: View {
Button {
onTapRemove()
} label: {
IconView(asset: .X24.removeRed)
IconView(asset: .X18.clear)
}
.padding([.top, .trailing], -6)
}
Expand Down

0 comments on commit bced94f

Please sign in to comment.