Curious ProgressView side effect

Have been trying to sort this out for a couple of days. Wondering if any others have seen this…

Working on a game app. The ‘game board’ is a container view (i.e. ZStack). There are ‘game pieces’ that are views (with defined frame sizes and positions). During game play the app keeps track of which ‘game piece’ is tapped (via .onTapGesture). The container view has a timer (which limits player time; publishes every 0.1 sec). Each game piece also has a timer ( to control a timed change in color ).

The app functions as desired UNTIL I add a ProgressView that provides feedback on game time left. With the ProgressView, the game pieces do not respond to the .onTapgesture ; comment out the ProgressView and all is fine. Curiously, if I select a static value for ProgressView, the ‘game piece’ .onTapGesture fires appropriately. It is as if the ProgressView update ‘steals’ focus from all other views.

Unable to find any answers via google. Realize difficult to be definitive without seeing the exact code but the views together have 400 lines of code.

Can live without the ProgressView but still looking to better understand what is going on. Any thoughts greatly appreciated.

Very hard to know what’s going on without code. What does your ProgressView look like? Does it effectively occupy the entire screen when active (which appears to be the case since you say that other objects cannot be tapped on).

Chris,

Thank you for the offer but it is too much an imposition to expect you to troubleshoot the entire app - it would take too much of your time.

I just did a small mock-up to test the combination ProgressView with Timer and .onTapGesture worked just fine. Am concluding that although in my app, the ProgressView caused problem, there is some other complexity in the view structure and multiple @state variables that is combining to create the issue. Vexing to say the least. Fortunately this feature is not critical.

Thanks again !!

A quick follow up on how I solved the issue in case others are faced with similar scenario. As a SwiftUI beginner, my view(s) start simple and I incrementally add features. This lead to a complex view. It appears there came a level of complexity where the ProgressView was pre-empting other events ( in this case the .onTapGesture). I decided to ‘divide’ the screen in to regions and make each region its own view. This put the ProgressView and .onTapGesture in a separate view and viola, all is fine.

Moral seems to be that top-down modularization makes life better. Guess that’s why we assign ourselves ‘starter’ projects.

Screen region view modularization may also have benefit of more gracefully handling portrait vs landscape layouts. This is next learning goal yet to be implemented :slight_smile: