mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add the initial implementation for managing spaces. (#4963)
This isn't hooked up into the flows yet.
This commit is contained in:
@@ -16,10 +16,11 @@ struct ToolbarButton: View {
|
||||
|
||||
case cancel(title: String)
|
||||
case confirm(title: String)
|
||||
case destructive(title: String)
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .cancel(let title), .confirm(let title):
|
||||
case .cancel(let title), .confirm(let title), .destructive(let title):
|
||||
title
|
||||
}
|
||||
}
|
||||
@@ -33,6 +34,9 @@ struct ToolbarButton: View {
|
||||
case .confirm:
|
||||
CompoundIcon(\.check)
|
||||
.foregroundStyle(.compound.iconOnSolidPrimary)
|
||||
case .destructive:
|
||||
CompoundIcon(\.delete)
|
||||
.foregroundStyle(.compound.iconOnSolidPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +46,8 @@ struct ToolbarButton: View {
|
||||
.compound.bgCanvasDefault
|
||||
case .confirm:
|
||||
.compound.bgAccentRest
|
||||
case .destructive:
|
||||
.compound.bgCriticalPrimary
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,27 +62,13 @@ struct ToolbarButton: View {
|
||||
.accessibilityLabel(role.title)
|
||||
}
|
||||
.tint(role.tint)
|
||||
.buttonStyleGlassProminent()
|
||||
.backportButtonStyleGlassProminent()
|
||||
} else {
|
||||
Button(role.title, action: action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 26, *)
|
||||
private extension View {
|
||||
@ViewBuilder
|
||||
func buttonStyleGlassProminent() -> some View {
|
||||
// `.glassProminent` breaks our preview tests so we need to disable it when running tests.
|
||||
// https://github.com/pointfreeco/swift-snapshot-testing/issues/1029#issuecomment-3366942138
|
||||
if ProcessInfo.isRunningTests {
|
||||
self
|
||||
} else {
|
||||
buttonStyle(.glassProminent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ToolbarButton_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
@@ -88,6 +80,9 @@ struct ToolbarButton_Previews: PreviewProvider, TestablePreview {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
ToolbarButton(role: .cancel) { }
|
||||
}
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
ToolbarButton(role: .destructive(title: L10n.actionRemove)) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user