Structures

The following structures are available globally.

Conformance to MessageData protocol

UIModelData format

  • Standard message format returns by CAI platform Raw format parsed as-is from what the backend system returns

    See more

    Declaration

    Swift

    public struct UIModelData : Decodable
    extension UIModelData: ListMessageData
    extension UIModelData: FormMessageData
    extension UIModelData: ButtonsMessageData
    extension UIModelData: CarouselMessageData
  • Undocumented

    See more

    Declaration

    Swift

    public struct UIModelDataHeader : Decodable
    extension UIModelDataHeader: HeaderMessageData
  • Undocumented

    See more

    Declaration

    Swift

    public struct UIModelDataSection : Decodable
    extension UIModelDataSection: ObjectSectionData
  • Undocumented

    See more

    Declaration

    Swift

    public struct UIModelDataImage : Decodable
  • Undocumented

    See more

    Declaration

    Swift

    public struct UIModelDataValue : Decodable
    extension UIModelDataValue: ValueData
  • Holds the content for a specific UIModelData. Properties will be filled based on UIModelData type.

    See more

    Declaration

    Swift

    public struct UIModelDataContent : Decodable
    extension UIModelDataContent: ObjectMessageData
    extension UIModelDataContent: CarouselItemMessageData, CardMessageData
  • Undocumented

    See more

    Declaration

    Swift

    public struct UIModelDataAction : Decodable
    extension UIModelDataAction: PostbackData
  • Used for Image & Video cards

    See more

    Declaration

    Swift

    public struct UIModelDataMedia : Decodable
    extension UIModelDataMedia: MediaItem
  • Enum CAIError. Implement SAPError. Raised when something is wrong with our platform services.

    See more

    Declaration

    Swift

    public struct CAIError : SAPError, Equatable
  • CAI Service definition. Helps to connect to CAI services. By default, it will connect to Community tenant.

    See more

    Declaration

    Swift

    public struct CAIServiceConfig
  • Casual Color Palette

    See more

    Declaration

    Swift

    public struct CasualColorPalette : ColorPalette
  • Fiori Color Palette. Follows SAP Fiori Design Language.

    See more

    Declaration

    Swift

    public struct FioriColorPalette : ColorPalette
  • Use this structure to create and implement your own custom theme. Check out Theme.Key enums to know what can be configured.

    See more

    Declaration

    Swift

    public struct Theme
  • Undocumented

    Declaration

    Swift

    public struct URLNavigation
  • SwiftUI main view. Use this when you want a full screen out-of-the box view that contains:

    • BannerView hidden by default that slides down to display any errors.
    • ChatView
    • InputBarView This view will apply the accent color defined in your theme.

    Safe Area is ignored at the bottom so the InputBarView can extend and apply the background Blur Effect all the way.

    To function properly, this view requires 2 @EnvironmentObject objects to be set:

    • viewModel: MessagingViewModel
    • themeManager: ThemeManager. Recommended to use ThemeManager.shared

    Usage example:

    AssistantView()
        .navigationBarTitle(Text("Chat"), displayMode: .inline) // if you are in navigation controller
        .environmentObject( MessagingViewModel(publisher:
                              CAIConversation(config: CAIServiceConfig(SAPURLSession(), <#backendURL#>),
                                              channel: "<#channelId#>",
                                              token: "<#channelToken#>") )
        .environmentObject(themeManager)
    

    Declaration

    Swift

    public struct AssistantView : View
  • Renders a ScrollView with the list of messages provided by the MessagingViewModel

    See more

    Declaration

    Swift

    public struct ChatView : View
  • Slide down and up a banner view. There is no default background color.

    Example of usage:

    BannerView("Text to display")
          .onTapGesture {
              someError = nil
          }
    }
    
    See more

    Declaration

    Swift

    public struct BannerView : View
  • SearchBar SwiftUI wrapper for rendering a TextField, magnifer icon and clear button while editing

    See more

    Declaration

    Swift

    public struct SearchBar<S> : View where S : StringProtocol

SwiftUI View

  • A view drawing an animated 3 dots. Use TypingIndicatorData to customize it. The view comes with a default frame already set.

    See more

    Declaration

    Swift

    public struct TypingIndicatorView : View
  • InputBar view. Wraps a TextView and Send button. Send will call MessagingViewModel.postMessage(text: String) Height of the TextView grows as user types longer text.

    Declaration

    Swift

    public struct InputBarView : View
  • Type-erased container to be used when setting own QuickReply button style If you wish to create your own QuickReply button style, do so by conforming to ButtonStyle, put it into QuickReplyButtonStyleContainer and use Theme.Key enum quickReplyButtonStyle() to apply it.

    ## Example: define style

    
     public struct MyCustomQuickReplyButtonStyle: ButtonStyle {
         public func makeBody(configuration: MyCustomQuickReplyButtonStyle.Configuration) -> AnyView {
    
             return AnyView(
                 configuration.label
                     .font(.body)
                     .lineLimit(1)
                     .padding(EdgeInsets(top: 10, leading: 16, bottom: 10, trailing: 16))
             )
         }
     }
    

    Example: apply style

     Theme(name: "myCustomTheme", values: [
         .quickReplyButtonStyle: QuickReplyButtonStyleContainer(MyCustomQuickReplyButtonStyle())
     ])
    
    See more

    Declaration

    Swift

    public struct QuickReplyButtonStyleContainer : ButtonStyle
  • QuickReply button style applied when using custom theme and no specific button style was provided

    See more

    Declaration

    Swift

    public struct BaseQuickReplyButtonStyle : ButtonStyle
  • QuickReply button style applied when using Fiori theme

    See more

    Declaration

    Swift

    public struct FioriQuickReplyButtonStyle : ButtonStyle
  • QuickReply button style applied when using Casual theme

    See more

    Declaration

    Swift

    public struct CasualQuickReplyButtonStyle : ButtonStyle