|
Hi everyone! I just completed the "Habit Tracker" challenge. To solve this, I added the "plus" buttom to the main view and used the 'Habits' View Model to find the index of the Item and add one to it and it works when I press the buttom but also when I press the Row and I wasn't expecting this last behavior, does anyone have any idea of why this is happening? Here's the piece of code:
Thanks in advance for the input! |
|
Hi @KeyBarreto! If you could provide more details on ViewModel and HabitView it would be easier for others to understand what is happining in your code. With such limited information it is difficult to say what might be the reason for such behavior. |
|
Yes, sure @ygeras. I tried to add a Screenshot too but I couldn't find how. This is my "Habit View":
And this is the Habits ViewModel:
|
|
Add a |
|
Thanks @roosterboy ! That worked! So adding a button to a VStack or HStack will make the entire Stack a button (Clickable) if I don't use the 'borderless' modifier? Also, 'borderless' sounds counterintuitive, the documentation says: "A button style that doesn’t apply a border." Or maybe it's because English it's not my main language but it sounds like exactly the opposite. Would you mind to explain further? Thanks again! |
|
@Key wants to understand the buttonStyle modifier.
Here's a small example for you to run in Playgrounds to illustrate three types of button border styles.
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.