AIUserFeedback
public struct AIUserFeedback
extension AIUserFeedback: View
extension AIUserFeedback: _ViewEmptyChecking
AIUserFeedback
is used to display a feedback page with customizable title, description, navigation title, filter form view and key value form view.
AIUserFeedback
can be presented modally using .sheet, or pushed onto a navigation stack.
Usage
@State var voteState: AIUserFeedbackVoteState = .notDetermined
@State var submitButtonState: AIUserFeedbackSubmitButtonState = .normal
@State var filterFormViewSelectionValue: [Int] = [0]
@State var valueText: String = ""
let valueOptions: [AttributedString] = ["Inaccuraies", "Inappropriate Content", "Security Risks", "Slow Response", "Repetitive or Wordy", "Others"]
let filterFormView = FilterFormView(title: "Select all that apply", isRequired: true, options: valueOptions, errorMessage: nil, isEnabled: true, allowsMultipleSelection: true, allowsEmptySelection: false, value: self.$filterFormViewSelectionValue, buttonSize: .fixed, onValueChange: { value in
print("FilterFormView value change: \(value)")
})
let keyValueFormView = KeyValueFormView(title: "Additional feedback", text: self.$valueText, placeholder: "Write additional comments here", errorMessage: nil, minTextEditorHeight: 88, maxTextEditorHeight: 200, maxTextLength: 200, hintText: AttributedString("Hint Text"), isCharCountEnabled: true, allowsBeyondLimit: false, isRequired: true)
AIUserFeedback(title: { Title(title: "How was your AI experience?") },
description: { Text("Please rate your experience to help us improve.") },
navigationTitle: "Feedback" ,
filterFormView: filterFormView,
keyValueFormView: keyValueFormView,
displayMode: .sheet,
onCancel: {
}, onUpVote: {
}, onDownVote: {
}, onSubmit: { voteState, feedbacks, additional, submitResult in
submitResult(true)
}, voteState: $voteState,
submitButtonState: $submitButtonState)
### Toggle:
@State var isFeedbackPresented = false
Button {
isFeedbackPresented.toggle()
} label: {
Text("Present AI User Feedback")
}
.popover(isPresented: $isFeedbackPresented) {
AIUserFeedback
}
-
init(detailImage:
title: description: action: secondaryAction: detailImageSize: isActionVerticallyAligned: contentAlignment: submitAction: cancelAction: navigationTitle: filterFormView: keyValueFormView: displayMode: isBackgroundInteractionEnabled: errorView: onCancel: onUpVote: onDownVote: onSubmit: voteState: submitButtonState: componentIdentifier: ) Undocumented
Declaration
Swift
public init(@ViewBuilder detailImage: () -> any View = { EmptyView() }, @ViewBuilder title: () -> any View, @ViewBuilder description: () -> any View = { EmptyView() }, @ViewBuilder action: () -> any View = { EmptyView() }, @ViewBuilder secondaryAction: () -> any View = { EmptyView() }, detailImageSize: IllustratedMessage.DetailImageSize? = nil, isActionVerticallyAligned: Bool = false, contentAlignment: HorizontalAlignment = .leading, @ViewBuilder submitAction: () -> any View = { EmptyView() }, @ViewBuilder cancelAction: () -> any View = { FioriButton { _ in Text("Cancel".localizedFioriString()) } }, navigationTitle: AttributedString? = nil, filterFormView: FilterFormView? = nil, keyValueFormView: KeyValueFormView? = nil, displayMode: AIUserFeedbackDisplayMode = .sheet, isBackgroundInteractionEnabled: Bool = false, @ViewBuilder errorView: () -> any View = { EmptyView() }, onCancel: (() -> Void)? = nil, onUpVote: (() -> Void)? = nil, onDownVote: (() -> Void)? = nil, onSubmit: ((_ voteState: AIUserFeedbackVoteState, _ feedbacks: [String], _ additional: String, _ submitResult: @escaping (Bool) -> Void) -> Void)? = nil, voteState: Binding<AIUserFeedbackVoteState>, submitButtonState: Binding<AIUserFeedbackSubmitButtonState>, componentIdentifier: String? = AIUserFeedback.identifier)
-
Undocumented
Declaration
Swift
static let identifier: String
-
init(detailImage:
title: description: action: secondaryAction: detailImageSize: isActionVerticallyAligned: contentAlignment: submitAction: cancelAction: navigationTitle: filterFormView: keyValueFormView: displayMode: isBackgroundInteractionEnabled: errorView: onCancel: onUpVote: onDownVote: onSubmit: voteState: submitButtonState: ) Undocumented
Declaration
Swift
init(detailImage: Image? = nil, title: AttributedString, description: AttributedString? = nil, action: FioriButton? = nil, secondaryAction: FioriButton? = nil, detailImageSize: IllustratedMessage.DetailImageSize? = nil, isActionVerticallyAligned: Bool = false, contentAlignment: HorizontalAlignment = .leading, submitAction: FioriButton? = nil, cancelAction: FioriButton? = FioriButton { _ in Text("Cancel".localizedFioriString()) }, navigationTitle: AttributedString? = nil, filterFormView: FilterFormView? = nil, keyValueFormView: KeyValueFormView? = nil, displayMode: AIUserFeedbackDisplayMode = .sheet, isBackgroundInteractionEnabled: Bool = false, errorView: IllustratedMessage? = nil, onCancel: (() -> Void)? = nil, onUpVote: (() -> Void)? = nil, onDownVote: (() -> Void)? = nil, onSubmit: ((_ voteState: AIUserFeedbackVoteState, _ feedbacks: [String], _ additional: String, _ submitResult: @escaping (Bool) -> Void) -> Void)? = nil, voteState: Binding<AIUserFeedbackVoteState>, submitButtonState: Binding<AIUserFeedbackSubmitButtonState>)
-
Undocumented
Declaration
Swift
init(_ configuration: AIUserFeedbackConfiguration)
-
Declaration
Swift
@MainActor public var body: some View { get }
-
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }