Created
August 15, 2022 13:19
-
-
Save marcoarment/b980ff60cc45623aeb06a4121e13f354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension UIColor: Identifiable { | |
public var id: String { | |
get { self.accessibilityName } | |
} | |
} | |
struct ContentView: View { | |
let defaultColor = UIColor.systemBlue | |
let colors: [UIColor] = [ | |
.systemRed, | |
.systemGreen, | |
.systemYellow, | |
.systemBlue, | |
] | |
@State var navigationValue: String? | |
@State var selectedColor: UIColor? | |
var body: some View { | |
NavigationSplitView { | |
List(selection: $navigationValue) { | |
NavigationLink("Tint Color", value: "test") | |
} | |
.navigationTitle("Home") | |
} detail: { | |
Text("⬆️ Back button and/or display-mode button above should change color after choosing a new color:") | |
List(selection: $selectedColor) { | |
ForEach(colors) { color in | |
Button { | |
selectedColor = color | |
navigationValue = nil | |
} label: { | |
Text(color.accessibilityName) | |
} | |
} | |
} | |
} | |
.tint(Color(uiColor: selectedColor ?? defaultColor)) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Happy to report that this is fixed in iOS 16 developer beta 7.