我想在 SwiftUI 视图中基于 ViewState 使用协议来渲染 SwiftUI 视图,但是在确认它时,我收到了这种错误
“MainView”与协议“View”的冗余一致性
import Foundation
import SwiftUI
public struct ViewState: Equatable {
// MARK: - Properties
private(set) var isDismissible = false
private(set) var isEnabled = true
private(set) var isError = false
private(set) var isShowLoading = false
// MARK: - Methods
public init() {}
}
typealias UserInterfaceView = UserInterface & View
protocol UserInterface {
func render(state: ViewState)
}
/// Error : Redundant conformance of 'MainView' to protocol 'View'
struct MainView: View, UserInterfaceView {
var body: some View {
Text("Test")
}
}
我知道 View 也是一种协议,但我如何确认协议?如果我想在ViewState的基础上改变状态!有什么我想念的吗?