Prevent SwiftUI App from going to sleep op WatchOS - swiftui

I'm trying to record some CoreMotion data from a watch app I'm making. Every time I go to move, however, the app goes inactive after a while. Since this app is more for testing purposes, I'd like to keep it active as long as it's recording data.
I think I'm basically looking for the SwiftUI equivalent on WatchOS of UIApplication.shared.isIdleTimerDisabled = true.

Related

NSUserActivity state restoration not working in SwiftUI

I'm trying to get state restoration working from SwiftUI. SceneStorage works, but I want to have more control over the process, both so I can disable it for tests and so I can control it from a coordinator separate from my views.
userActivity(_:isActive:_:) gets called when the app opens, but not when the app closes. How can I get it to get called to update the apps state? onContinueUserActivity(_:perform:) on the other hand doesn't get called at all.
What am I missing here?

Why does SwiftUI code run/reloae on iPhone and not on iPad?

I have been looking at this code and other similar code for the last week and have a question.
The app (code link below) is a simple 5 question app in SwiftUI. Using an iPhone 11 simulator, the quiz runs perfectly and when you hit the back nav link and press the Start Quiz button, the quiz runs again. On an iPad however the Start Quiz button does not work to relaunch the Quiz.
I figured since both are running the same IOS, they should both function the same but they do not. Tried it on my physical iPad and the same thing. Runs through the quiz once, and will not run a second time. Anybody have any idea why? Thanks for your help!
https://github.com/albypanz94/Quiz-Game-in-SwiftUI.git
The issue is that the SwiftUI Navigation model is, by default, based on a UISplitview, and that on the iPad, the "Start Quiz" navigation link transfers navigation to its second controller. On an iphone, the second controller is collapsed away.
What this means for the game is that for the iPad (and large iPhones in landscape mode), the game cannot re-start.
You would also find anomalies if you ran the game on a large format iPhone, and then rotated it mid way through the game.
You can change the navigation view style to not use the split view model by using:
.navigationViewStyle(StackNavigationViewStyle())
after the NavigationView closing brace.

The transition is not visible in ember

In my app, I have an image which when clicked make the transition to the different.This is working smoothly and the transition is always successful.But the problem I am facing is the transition takes around some time to render so that it could make different api call.During this time the app goes still and I am not able to tell the transition in happening.It should so something like loading sign in a tab like every web app does.I have tried both ways.
1) this.transitionToRoute('usrprofile',photo.get('owner_pk'));
in actions
2) {{#link-to "usrprofile",photo.owner_pk"}}<img>{{/link-to}}
It might be a silly question.But I am not able to do it.

How do i display a progress bar for CardScrollView in Google Glass?

So I've got my little beginning of an app loading data from json into a CardScrollView. Sometimes this takes a few seconds, so I need a loading screen. Normally I'd do this with the progress action bar or a progress bar spinning around. I found a question around this:
https://stackoverflow.com/questions/20237873/google-glass-gdk-progress-indicator
So far so good, however I can't determine how to construct a layout for my activity so I see the progress loading and then when data load is finished, the card scroll view. What I'm doing now is first I set the loading view in the onCreate:
setContentView(mLoadingView)
Then later once the loader is finished I call:
mCardScrollView.activate()
setContentView(mCardScrollView)
Not only does this feel hackish, but it doesn't handle the case of reloading data. Normally I'd do this in android with a frame layout xml which would have the progress bar and list view in it and then toggle progress bar visibility / progress. But I'm not sure how to do this in glass. Maybe I'm not even following the right "glass paradigm". Any ideas?
Currently in the GDK sneak peek, you'll have to roll your own solution like you've already done. But you can track the feature request for a Glass-style progress here here on our issue tracker.

TabBar application slow

I have a problem, I have a TabBar application with 3 tabs, at the start of app if I try to change tab (only on specific tab) the changing is a bit slow, after the first time all is fast, how can I check the time of specific process (method) for find the problem?