For iOS NavigationLinks provide a good way to completely transition from one "screen" (view) to another.
In macOS however, NavigationLinks don't completely switch the whole contents of a screen to another.
What I want to achieve is to make a Button press trigger a transition from one screen to another.
Post
Replies
Boosts
Views
Activity
Currently NaviagitonView on macOS creates a side panel. And then navigationViewStyle does not support stack view for macOS.
Given this, is there currently a method to totally switch the content of a window from one view to another on macOS?
In XCode, if I hit a breakpoint, I can't view the value of some local variables:
I've read about disabling optimisations for debugging, but that's already done
I want to have a single selection in a List, holding content of a custom struct:
struct ChannelInfo: Hashable {
let title: String
let description: String
}
And the view:
struct JoinChannelView: View {
@Binding var rooms: [ChannelInfo]
@State var selectedRoom: String?
var body: some View {
VStack {
if $rooms.isEmpty {
Text("Loading...")
.transition(.slide)
} else {
List(selection: $selectedRoom) {
ForEach(rooms, id: \.title) { room in
Text(room.title)
.font(.title)
Text(room.description)
.font(.subheadline)
}
.padding(.bottom)
}
}
}
.frame(width: 150, height: 300)
}
}
My problem here is, that because inside the ForEach I render two Text views, both are selectable, but that's incorrect, I only want the title, the first Text to be selectable.
I want to display a simple message while waiting for a list to be populated. Something like Loading... and when the list starts being populated with even one item, remove the message, via a transition, and display the list.
My current attempt, that does not work, looks like:
struct JoinChannelView: View {
@Binding var rooms: [ChannelInfo]
@State var selectedRoom: String?
var body: some View {
VStack {
if $rooms.isEmpty {
Text("Loading...")
.transition(.slide)
} else {
List(selection: $selectedRoom) {
ForEach(rooms, id: \.title) { room in
Text(room.title)
.font(.title)
Text(room.description)
.font(.subheadline)
}
.padding(.bottom)
}
}
}
.frame(width: 150, height: 300)
}
}
The code for @State doesn't seem to work.
struct DonutListView: View {
var donutList: DonutList
@State private var donutToAdd: Donut?
var body: some View {
List(donutList.donuts) { DonutView(donut: $0) }
Button("Add Donut") { donutToAdd = Donut() }
.sheet(item: $donutToAdd) { // <-- would need a "donut in"
TextField("Name", text: $donutToAdd.name) // <-- donutToAdd is optional and I'm not sure how it would be unwrapped
Button("Save") {
donutList.donuts.append(donutToAdd)
donutToAdd = nil
}
Button("Cancel") { donutToAdd = nil }
}
}
}
Does anyone have a fix for this?
Thanks,
Dan!
Apple Music's "Automatic Downalods" checkbox does not stay checked when saving settings and does not work at all.
Note this was broken for me for a long, long, time (Catalina?).
I'm trying to create and advertise a Bonjour service via Network.framework.
In Xcode, target, Info tab, I've added the entry to plist:
And then written the following code:
guard let listener = try? NWListener(service: .init(name: "My Printer Service", type: "_printer._tcp"),using: .tcp) else {
return nil
}
self.listener = listener
listener.stateUpdateHandler = { newState in
switch newState {
case.ready:
print("starting")
case .failed(let error):
print("error: \(error)")
default:
print(newState)
}
}
listener.start(queue: .main)
However, the status is failed with error message:
POSIXErrorCode(rawValue: 22): Invalid argument