Chatbot Initiation Screen
Overview
The LMChatAIBotInitiationViewController
is responsible for managing the initialization and setup of AI chatbot conversations. It displays a loading animation while performing the necessary setup steps in the background.
Functionality
UI Components
containerView
: ALMView
that serves as the main container for the screenanimationContainerView
: ALMView
that contains the Lottie animationpreviewLabel
: AnLMLabel
that displays the loading status textanimationView
: ALottieAnimationView
that shows the loading animation
Properties
viewModel
: An instance ofLMChatAIBotInitiationViewModel
that handles the initialization logic
Methods
setupViews()
: Configures the main UI componentssetupLayouts()
: Sets up the layout constraints for all UI componentssetupAnimation()
: Configures the Lottie animationstartAnimation()
: Starts playing the animationstopAnimation()
: Stops the animationdidCompleteInitialization(chatroomId:)
: Handles successful initializationdidFailInitialization(with:)
: Handles initialization failure
Customization
CustomAIBotInitiationViewController.swift
class CustomAIBotInitiationViewController: LMChatAIBotInitiationViewController {
override func setupViews() {
super.setupViews()
containerView.backgroundColor = .systemBackground
}
override func setupAnimation() {
// Custom animation setup
let customAnimation = LottieAnimation.named("custom_loading")
setupAnimationView(with: customAnimation)
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMCoreComponents.shared.aiBotInitiationScreen = CustomAIBotInitiationViewController.self
// ...
return true
}