Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created August 29, 2022 20:54
Show Gist options
  • Select an option

  • Save sturdysturge/eac16e783ddc83ee484edbe561a6f406 to your computer and use it in GitHub Desktop.

Select an option

Save sturdysturge/eac16e783ddc83ee484edbe561a6f406 to your computer and use it in GitHub Desktop.
import SwiftUI
extension HorizontalAlignment {
public var name: String {
if #available(iOS 16.0, *) {
switch self {
case .trailing:
return ".trailing"
case .center:
return ".center"
case .leading:
return ".leading"
case .listRowSeparatorLeading:
return ".listRowSeparatorLeading"
case .listRowSeparatorTrailing:
return ".listRowSeparatorTrailing"
default:
fatalError("No name for unknown type \(self)")
}
} else {
switch self {
case .trailing:
return ".trailing"
case .center:
return ".center"
case .leading:
return ".leading"
default:
fatalError("No name for unknown type \(self)")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment