Skip to main content

Edit Short Video Screen

Overview​

The Edit Short Video Screen (LMFeedEditShortVideoScreen) provides an interface for users to edit their existing short video content.

File Location:
LMFeedEditShortVideoScreen.swift

Functionality​

Protocols Implemented​

LMFeedEditShortVideoViewModelProtocol​

Defines methods that are triggered from the view model and are implemented by the view controller using it

  • setupData(with userData: LMFeedCreatePostHeaderView.ContentModel, text: String): Called to initialize the screen with user data and post text.
  • setupMediaPreview(with mediaCells: [LMFeedVideoCollectionCell.ContentModel]): Called to set up the video preview with the provided media cells.

LMFeedTaggingTextViewProtocol​

Manages user mention functionality in the text view.

LMFeedTaggedUserFoundProtocol​

Handles user selection from the tagging list.

UI Components​

  • containerView: The main container view with a white background.
  • containerStackView: A vertical stack view organizing the main content.
  • scrollView: A scrollable view for content that may exceed screen height.
  • scrollStackView: A vertical stack view within the scroll view for content organization.
  • inputTextView: A text view for entering post content with user mention support.
  • mediaCollectionView: A collection view for displaying video content.
  • taggingView: A view for displaying and selecting mentioned users.
  • saveButton: A navigation bar button for saving changes.

Data Variables​

  • mediaCells: An array of LMFeedVideoCollectionCell.ContentModel objects containing video data.
  • inputTextViewHeightConstraint: A constraint for the input text view's height.
  • textInputMaximumHeight: The maximum height allowed for the input text view.
  • taggingViewHeight: A constraint for the tagging view's height.

Methods​

  • setupViews(): Configures the initial view hierarchy.
  • setupLayouts(): Sets up the layout constraints for all UI components.
  • setupActions(): Configures action handlers for UI elements.
  • setupAppearance(): Customizes the visual appearance of the screen.
  • setupInitialView(): Initializes the view state.
  • showDiscardAlert(): Shows an alert when attempting to discard changes.

Action Handlers​

  • didTapSaveButton(): Called when the save button is tapped.
  • didTapBackButton(): Called when the back button is tapped.

Customization​

CustomEditShortVideoScreen.swift
class CustomEditShortVideoScreen: LMFeedEditShortVideoScreen {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .systemBackground
inputTextView.backgroundColor = .secondarySystemBackground
mediaCollectionView.layer.cornerRadius = 16
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Components.shared.editShortVideoScreen = CustomEditShortVideoScreen.self
// ...
return true
}