I found out that using canCollapseFromWindowResize with canCollapse did the trick and you cannot hide the sidebar anymore by dragging it on macOS.
.introspect(.navigationSplitView, on: .macOS(.v13,.v14,.v15)) { splitview in
if let delegate = splitview.delegate as? NSSplitViewController {
delegate.splitViewItems.first?.canCollapse = false
delegate.splitViewItems.first?.canCollapseFromWindowResize = false
}
}
But I agree it's a shame that options/features that they are clearly using in many of their apps are somehow still not available in SwiftUI. All the thanks to swiftui-introspect developers for making possible to overcome Apple's dumb mistakes.
Post
Replies
Boosts
Views
Activity
I also had problem making this work, even colorsScheme enviroment didn't work. Now I found out that it works but only of Live activity view is in separate variable.
If everything is defined right inside Widget it desn't seems to work:
struct MyLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyActivityAttributes.self) { context in
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // always default values (false, light)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // always white
} dynamicIsland: { context in
DynamicIsland {
When it is in separate view, enviroments are working as intended:
struct MyLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyActivityAttributes.self) { context in
MyActivityLiveView(context: context)
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // always default values (false, light)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // always white
} dynamicIsland: { context in
DynamicIsland {
struct MyActivityLiveView: View {
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
var context: ActivityViewContext<VirtualTableActivityAttributes>
var body: some View {
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // actual values (true, dark)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // colors are changeing, when changing from light to dark mode
}
}
.activityBackgroundTint(nil) still unfortunately make it only white and black but now you can you can at least customise it.
This is closest I got to match notification background / ios 16 default:
.activityBackgroundTint(colorScheme == .dark ? Color(Color.systemBackground.resolve(in: environment)).opacity(0.43) : Color(Color.systemBackground.resolve(in: environment)).opacity(0.43))
Color.systemBackground is just an UIColor:
extension Color {
// MARK: - Background Colors
static let systemBackground = Color(UIColor.systemBackground)
}
This Color extension is from this answer: https://stackoverflow.com/a/64414674