If an action button text is based on a state change, when `addSwipeAction(menu: .swiped)` is used, it doesn't seem to rebuild correctly.
Thank you for your hard work.
I have a question: If an action button text is based on a state change, when addSwipeAction(menu: .swiped) is used, it doesn't seem to rebuild correctly.
For example, in the following code for a conversation list cell, when the "pin" action is clicked, the text of this action changes to "unpin". However, the width of the action is not correct. How can I properly re-render the action button?
@State var swipeState = SwipeState.untouched
func contentCard(conversation: Conversation) -> some View {
HStack {
NetworkImage(url: conversation.couple.avatar, size: 80)
VStack(alignment: .leading, spacing: 3) {
HStack {
Text(conversation.couple.nickName)
.semibold(size: 12)
}
Text(conversation.couple.describe)
.regualr(size: 11)
.foregroundStyle(Color.black.opacity(0.5))
}
.lineLimit(1)
Spacer(minLength: 0)
}
.padding(.all, 15)
.background(Color.white)
.addSwipeAction(menu: .swiped, edge: .trailing, state: $swipeState) {
Button {
withAnimation {
swipeState = .swiped(UUID())
}
send(.userDidTapPinConversation(conversation), animation: .default)
} label: {
Text(conversation.isPinned ? "unpin" : "pin")
.foregroundStyle(Color.white)
.semibold(size: 12)
.padding(.horizontal, 8.ap)
}
.frame(maxHeight: .infinity)
.background(Color(hex: "#FF6599FF"))
Button {
withAnimation {
swipeState = .swiped(UUID())
}
send(.userDidTapDeleteConversation(conversation), animation: .default)
} label: {
Text("delete")
.foregroundStyle(Color.white)
.semibold(size: 12)
.padding(.horizontal, 8.ap)
}
.frame(maxHeight: .infinity)
.background(Color(hex: "#FFFF2C2C"))
}
.cornerRadius(15)
.padding(.horizontal, 15.ap)
Good day, @MorningStarJ ! thanks for your feedback)
Confirmed)
Good day, @MorningStarJ ! thanks for your feedback)
Confirmed)
Thank you for your quick response. Is there any way I can solve this issue now?⬤
@MorningStarJ sry, didn't see ur question... Yes, u can fix the width for your button with the bigger title... In your case is "unpin".. in that case title "pin" is less in the width... Therefore it will place in the center of the button after its renaming and won't go beyond bounds
fix in 0.4.0