Post

Replies

Boosts

Views

Activity

Configurable Watch Widgets "Unable to Load" watchOS 26 Issue
I updated my IntentWidgetProvider recommendations() to return an empty array instead of all my previous static IntentRecommendation to allow my widgets to finally be configurable. When I go to the watch widget chooser I see samples of my widgets OK: But when I touch the sample would should bring up my configurations, I get "Unable to Load": Anybody see this or have any ideas? Thanks.
4
0
49
2w
SwiftUI: scrollEdgeEffectStyle(.hard, for: .all) bug with preferredColorScheme(.dark)
In the small example below, I have set .preferredColorScheme(.dark). I am pushing a view that has a List. I have a custom background color. When .scrollEdgeEffectStyle(.hard, for: .all) is used, the pushed view top and bottom safe areas flash black before being replaced by the blue background color. If I change this to .scrollEdgeEffectStyle(.soft, for: .all), the issue goes away. If I do not set preferredColorScheme(.dark), the issue also goes away. I filled FB18465023, but wonder if I am just doing something wrong? Video of sample running: https://www.youtube.com/shorts/87rWqHtdmKw. var body: some View { NavigationStack { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") NavigationLink("Push New View") { PushedView() } .buttonStyle(.glass) .padding() } .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea(.all) .background(.blue) } .preferredColorScheme(.dark) } } struct PushedView: View { @State private var searchText = "" var body: some View { List { ForEach(1...30, id: \.self) { index in Label("Label \(index)", systemImage: "number.circle") .listRowBackground(Color.blue) } } // This causes the top and bottom safe areas to start off black before // getting the blue background from below .scrollEdgeEffectStyle(.hard, for: .all) // This does not have the issue // .scrollEdgeEffectStyle(.hard, for: .all) .listStyle(.plain) .background(.blue) .searchable(text: $searchText, prompt: "Search labels...") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Toolbar Button", systemImage: "questionmark") { print("touched") } } } } }
Topic: UI Frameworks SubTopic: SwiftUI
1
0
194
3w
Will Lock Screen Widgets be Configurable?
Will there be a user interface to configure lock screen widgets like home screen widgets? This seems to be implied as possible based on the stock apps, such as the Clock app lock screen widget saying "Add a clock for a city to check the time at that location." I could not figure out how to bring up the configuration GUI: long press various places has no effect.
5
1
2.0k
Jun ’22
SwiftUI: forcing focus based on state with TabView and watchOS
I'm trying to have a feature where a button enables the digital crown. There are multiple tabs with this button, and I want to be able to scroll between the tabs and keep the mode/crown enabled. So for above, my goal is the user could touch 'Enable Crown' and be able to swipe between tabs, keeping the digital crown mode enabled. I believe that means maintaining focus on an element that has digitalCrownRotation() and focusable(). I got this working somewhat with the code below: if the 2nd tab is not active yet and I enable the crown and swipe to tab #2, the default focus modifier triggers #2 button to get focus and get the crown input. But after that the buttons lose focus. I've tried various tricks and can't get it working. Complete code is at https://github.com/t9mike/DigitalCrownHelp3. Any tips and ways to achieve my goal? Thank you. import SwiftUI class GlobalState : ObservableObject { @Published var enableCrown = false } struct ChildView: View { @State var crownValue = 0.0 @ObservedObject var globalState = ContentView.globalState @Namespace private var namespace @Environment(\.resetFocus) var resetFocus let label: String init(_ label: String) { self.label = label } var body: some View { ScrollView { Text(label) Button("\(globalState.enableCrown ? "Disable" : "Enable") Crown") { globalState.enableCrown = !globalState.enableCrown } .focusable() .prefersDefaultFocus(globalState.enableCrown, in: namespace) .digitalCrownRotation($crownValue) .onChange(of: crownValue, perform: { value in print("crownValue is \(crownValue)") }) } .focusScope(namespace) .onAppear { print("\(label), enableCrown=\(globalState.enableCrown)") resetFocus(in: namespace) } } } struct ContentView: View { static let globalState = GlobalState() var body: some View { TabView { ChildView("Tab #1") ChildView("Tab #2") } } }
3
0
2.5k
Jun ’21