LMViewController
Overview
The LMViewController is a customizable base view controller that extends UIViewController and implements the LMBaseViewControllerProtocol and LMViewLifeCycle protocol. It provides a standardized approach to view controller lifecycle, navigation, keyboard management, loader handling, and alert presentation for LikeMinds UI modules.
File Location:
LMViewController.swift
Functionality
UI Components
loaderScreen: A full-screen loading overlay viewnavigationTitleView: A custom view for navigation bar title and subtitletitleStackView: A stack view for organizing navigation title and subtitlenavigationHeaderTitleLabel: The main title label in the navigation barnavigationHeaderSubtitleLabel: The subtitle label in the navigation barloaderView: Activity indicator for loading state
Properties
view: The main view of the view controllernavigationItem: The navigation item for configuring navigation barparent: The parent view controller, if any
Methods
Initialization & Lifecycle
init(nibName:bundle:): Initializes the view controller with nib and bundleinit(coder:): Initializes the view controller from Interface BuilderloadView(): Loads the view hierarchyviewDidLoad(): Called after the view has been loadedviewDidLayoutSubviews(): Called after the view lays out its subviewsviewWillAppear(_:): Called before the view appearsviewWillDisappear(_:): Called before the view disappearsdeinit: Cleans up observers
Navigation & Alerts
setNavigationTitleAndSubtitle(with:subtitle:alignment:): Sets the navigation bar title and subtitlesetBackButtonWithAction(): Configures the back button with a custom actionsetRightNavigationWithAction(title:image:style:target:action:): Adds a right bar button itemshowAlertWithActions(title:message:withActions:): Presents an alert with custom actionsshowErrorAlert(_:message:): Presents an error alertpresentAlert(with:animated:): Presents a given alert controllershowError(withTitle:message:isPopVC:): Presents an error alert and optionally pops the view controllerpopViewController(animated:): Pops the current view controllerdismissViewController(): Dismisses the current view controller
Loader & Toast
showHideLoaderView(isShow:): Shows or hides the loader overlayshowHideLoaderView(isShow:backgroundColor:): Shows or hides the loader with a custom background colordisplayToast(_:): Displays a toast message
Keyboard Management
setupKeyboardNotifications(): Registers for keyboard show/hide notificationsremoveKeyboardNotifications(): Removes keyboard notificationsinitializeHideKeyboard(_:): Adds tap gesture to dismiss keyboarddismissMyKeyboard(): Dismisses the keyboardkeyboardWillShow(_:): Handles keyboard show eventkeyboardWillHide(_:): Handles keyboard hide event
Child View Controller Management
add(child:to:): Adds a child view controller to a subviewremove(): Removes the view controller from its parent
LMViewLifeCycle Protocol Methods
setupViews(): Sets up the view hierarchysetupLayouts(): Sets up layout constraintssetupActions(): Sets up action handlerssetupAppearance(): Sets up visual appearancesetupObservers(): Sets up observers for data binding