Skip to content

Conversation

@mikhailChelbaev
Copy link
Collaborator

@mikhailChelbaev mikhailChelbaev commented Nov 29, 2024

This PR introduces the implementation of center and bottom modal controllers for UIKit.

Since the behavior and properties of these modals differ based on their position (e.g., the bottom modal can be swiped or dragged vertically), I decided to create separate components rather than have a single one.

Shared Components

  1. ModalVM:
    A protocol defining the essential properties that all modals must implement.

  2. UKModalController:
    An abstract base class that cannot be directly initialized outside the library. This class provides the shared functionality and structure for specific modal implementations, serving as a foundation for extension.

Center Modal

  • CenterModalVM:
    Implements the ModalVM protocol. The center modal does not have additional unique properties, as its functionality is standard.

  • UKCenterModalController:
    Inherits from UKModalController and adjusts the layout to center the modal's content on the screen.

Bottom Modal

  • BottomModalVM:
    Implements the ModalVM protocol and introduces two specific properties:

    • isDraggable: Determines if the modal can be dragged vertically.
    • hidesOnSwap: Specifies whether the modal should hide when swiped down.
  • UKBottomModalController:
    Inherits from UKModalController and aligns content to the bottom of the screen. This controller also includes a gesture recognizer, enabling users to drag the modal vertically to adjust its position or dismiss it.

Common Features

All modals support three customizable content areas:

  1. Header: Optional.
  2. Body: Mandatory and serves as the primary content area.
  3. Footer: Optional.

The body is wrapped in a content-sized scroll view. This scroll view adjusts its behavior dynamically:

  • If the modal's height is less than the available screen space, the scroll view remains non-scrollable.
  • If the content exceeds the available height, the scroll view becomes scrollable.

Previews

This PR includes previews for both modal types. Common functionality has been extracted into ModalPreviewHelpers.

Base automatically changed from dev to main December 2, 2024 15:33
@mikhailChelbaev mikhailChelbaev changed the base branch from main to dev December 20, 2024 14:41
@mikhailChelbaev mikhailChelbaev changed the base branch from dev to refactor/config December 20, 2024 15:47
Base automatically changed from refactor/config to dev December 21, 2024 14:19
@mikhailChelbaev mikhailChelbaev merged commit ba11ff7 into dev Dec 21, 2024
1 check passed
@mikhailChelbaev mikhailChelbaev deleted the modal-uikit branch December 21, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants