Skip to main content

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 view
  • navigationTitleView: A custom view for navigation bar title and subtitle
  • titleStackView: A stack view for organizing navigation title and subtitle
  • navigationHeaderTitleLabel: The main title label in the navigation bar
  • navigationHeaderSubtitleLabel: The subtitle label in the navigation bar
  • loaderView: Activity indicator for loading state

Properties

  • view: The main view of the view controller
  • navigationItem: The navigation item for configuring navigation bar
  • parent: The parent view controller, if any

Methods

Initialization & Lifecycle

  • init(nibName:bundle:): Initializes the view controller with nib and bundle
  • init(coder:): Initializes the view controller from Interface Builder
  • loadView(): Loads the view hierarchy
  • viewDidLoad(): Called after the view has been loaded
  • viewDidLayoutSubviews(): Called after the view lays out its subviews
  • viewWillAppear(_:): Called before the view appears
  • viewWillDisappear(_:): Called before the view disappears
  • deinit: Cleans up observers
  • setNavigationTitleAndSubtitle(with:subtitle:alignment:): Sets the navigation bar title and subtitle
  • setBackButtonWithAction(): Configures the back button with a custom action
  • setRightNavigationWithAction(title:image:style:target:action:): Adds a right bar button item
  • showAlertWithActions(title:message:withActions:): Presents an alert with custom actions
  • showErrorAlert(_:message:): Presents an error alert
  • presentAlert(with:animated:): Presents a given alert controller
  • showError(withTitle:message:isPopVC:): Presents an error alert and optionally pops the view controller
  • popViewController(animated:): Pops the current view controller
  • dismissViewController(): Dismisses the current view controller

Loader & Toast

  • showHideLoaderView(isShow:): Shows or hides the loader overlay
  • showHideLoaderView(isShow:backgroundColor:): Shows or hides the loader with a custom background color
  • displayToast(_:): Displays a toast message

Keyboard Management

  • setupKeyboardNotifications(): Registers for keyboard show/hide notifications
  • removeKeyboardNotifications(): Removes keyboard notifications
  • initializeHideKeyboard(_:): Adds tap gesture to dismiss keyboard
  • dismissMyKeyboard(): Dismisses the keyboard
  • keyboardWillShow(_:): Handles keyboard show event
  • keyboardWillHide(_:): Handles keyboard hide event

Child View Controller Management

  • add(child:to:): Adds a child view controller to a subview
  • remove(): Removes the view controller from its parent

LMViewLifeCycle Protocol Methods

  • setupViews(): Sets up the view hierarchy
  • setupLayouts(): Sets up layout constraints
  • setupActions(): Sets up action handlers
  • setupAppearance(): Sets up visual appearance
  • setupObservers(): Sets up observers for data binding