mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
Revert the space filters Toggle and instead don't try to use glass when in the sidebar.
This reverts commit 283029b14976cda1aa567c947c27b09916c88824.
This commit is contained in:
@@ -326,6 +326,11 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension EnvironmentValues {
|
||||||
|
/// Whether or not the current view is part of the sidebar module of a `NavigationSplitCoordinator`.
|
||||||
|
@Entry var isInSidebar = false
|
||||||
|
}
|
||||||
|
|
||||||
private struct NavigationSplitCoordinatorView: View {
|
private struct NavigationSplitCoordinatorView: View {
|
||||||
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
||||||
|
|
||||||
@@ -381,9 +386,11 @@ private struct NavigationSplitCoordinatorView: View {
|
|||||||
NavigationSplitView(columnVisibility: $columnVisibility) {
|
NavigationSplitView(columnVisibility: $columnVisibility) {
|
||||||
if let sidebarModule = navigationSplitCoordinator.sidebarModule {
|
if let sidebarModule = navigationSplitCoordinator.sidebarModule {
|
||||||
sidebarModule.coordinator?.toPresentable()
|
sidebarModule.coordinator?.toPresentable()
|
||||||
|
.environment(\.isInSidebar, true)
|
||||||
.id(sidebarModule.id)
|
.id(sidebarModule.id)
|
||||||
} else {
|
} else {
|
||||||
navigationSplitCoordinator.placeholderModule.coordinator?.toPresentable()
|
navigationSplitCoordinator.placeholderModule.coordinator?.toPresentable()
|
||||||
|
.environment(\.isInSidebar, true)
|
||||||
.id(navigationSplitCoordinator.placeholderModule.id)
|
.id(navigationSplitCoordinator.placeholderModule.id)
|
||||||
}
|
}
|
||||||
} detail: {
|
} detail: {
|
||||||
|
|||||||
@@ -127,22 +127,46 @@ struct HomeScreen: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private struct SpaceFiltersButton: View {
|
private struct SpaceFiltersButton: View {
|
||||||
|
@Environment(\.isInSidebar) private var isInSidebar
|
||||||
|
|
||||||
var selected = false
|
var selected = false
|
||||||
var action: () -> Void
|
var action: () -> Void
|
||||||
|
|
||||||
|
/// Design prefers the custom style over the system's styling of a Toggle within a toolbar,
|
||||||
|
/// however Glass isn't supported for toolbar buttons in the sidebar on iPadOS 26 (likely due
|
||||||
|
/// to glass on glass being discouraged by Apple), so we need to handle our styling accordingly.
|
||||||
|
var shouldUseGlassButtonStyle: Bool {
|
||||||
|
!isInSidebar
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
// Use a Toggle to let the system handle the selection style for both the Liquid Glass
|
if #available(iOS 26, *), shouldUseGlassButtonStyle {
|
||||||
// button on iPhone, along with the plain button used in the sidebar on iPad/Mac.
|
if selected {
|
||||||
Toggle(isOn: .constant(selected)) {
|
content
|
||||||
CompoundIcon(\.filter)
|
.backportButtonStyleGlassProminent()
|
||||||
.foregroundStyle(selected ? .compound.iconOnSolidPrimary : .compound.iconPrimary)
|
.tint(.compound.bgActionPrimaryRest)
|
||||||
|
} else {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if selected {
|
||||||
|
content
|
||||||
|
.buttonStyle(.compound(.primary, size: .toolbarIcon))
|
||||||
|
} else {
|
||||||
|
content
|
||||||
|
.buttonStyle(.compound(.tertiary, size: .toolbarIcon))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.overlay {
|
}
|
||||||
// The tap gesture is ignored when applied to the toggle so apply it to an overlay instead.
|
|
||||||
Color.black.opacity(0.001)
|
private var content: some View {
|
||||||
.onTapGesture(perform: action)
|
Button {
|
||||||
|
action()
|
||||||
|
} label: {
|
||||||
|
CompoundIcon(\.filter)
|
||||||
}
|
}
|
||||||
.accessibilityLabel(L10n.screenRoomlistYourSpaces)
|
.accessibilityLabel(L10n.screenRoomlistYourSpaces)
|
||||||
|
.accessibilityAddTraits(selected ? .isSelected : [])
|
||||||
.accessibilityIdentifier(A11yIdentifiers.homeScreen.spaceFilters)
|
.accessibilityIdentifier(A11yIdentifiers.homeScreen.spaceFilters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user