I'm trying to customize the color or tint of a SwiftUI ProgressView that's placed within a SidebarView on a macOS app. Here's the code structure I have:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
SidebarView()
MainView()
}
}
}
struct SidebarView: View {
@State private var progress = 0.8
var body: some View {
List {
NavigationLink(destination: MainView()) {
Label("Blue", systemImage: "1.circle")
}
NavigationLink(destination: Text("Second Item Detail")) {
Label("Second Item", systemImage: "2.circle")
}
}
.listStyle(SidebarListStyle())
.frame(minWidth: 150, idealWidth: 200, maxWidth: 300)
ProgressView(value: progress) {
Text("Label")
}
.progressViewStyle(CircularProgressViewStyle(tint: .blue))
.tint(.blue)
.accentColor(.blue)
}
}
struct MainView: View {
@State private var progress = 0.8
var body: some View {
ProgressView(value: progress) {
Text("Label")
}
.progressViewStyle(CircularProgressViewStyle(tint: .blue))
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The ProgressView inside MainView has its tint color customized using .progressViewStyle(CircularProgressViewStyle(tint: .blue)), and it works as expected.
However, the same approach does not seem to work for the ProgressView placed within SidebarView. The color remains the default and doesn't reflect the desired blue tint. I've tried using .tint(.blue) and .accentColor(.blue) on the ProgressView, but it doesn't change the color.
Is there a way to modify the tint or color of a ProgressView within a SidebarView? Any insights into what might be causing this issue would be greatly appreciated!