Current File : /home/n742ef5/royalanteam.com/wp-content/plugins/myhome-core/src/Elementor/ListingCardTab.php
<?php

namespace Tangibledesign\MyHome\Elementor;

use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Tab_Base;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Tangibledesign\Framework\Helpers\Data\AddressTypesHelper;
use Tangibledesign\Framework\Models\Field\Field;
use Tangibledesign\Framework\Models\Field\PriceField;
use Tangibledesign\Framework\Models\Field\SalaryField;
use Tangibledesign\MyHome\Enums\ListingAttributeType;
use Tangibledesign\MyHome\Enums\ListingRowCardBottomAttributeType;
use Tangibledesign\MyHome\Enums\RatingType;

class ListingCardTab extends Tab_Base
{
    public function get_id(): string
    {
        return 'myhome-listing-card';
    }

    public function get_title(): string
    {
        return esc_html__('Listing Card', 'myhome-core');
    }

    public function get_group(): string
    {
        return 'theme-style';
    }

    public function get_icon(): string
    {
        return 'fas fa-paint-brush';
    }

    protected function register_tab_controls(): void
    {
        $this->start_controls_section(
            'myhome_listing_card',
            [
                'label' => esc_html__('MyHome Listing Card', 'myhome-core'),
                'tab' => $this->get_id(),
            ]
        );

        $this->addGalleryControls();

        $this->addLabelControls();

        $this->addNameControls();

        $this->addMainValueControls();

        $this->addCardAttributesControls();

        $this->addAdditionalDetailsControls();

        $this->addUserPhoneNumberControls();

        $this->addDescriptionControls();

        $this->addRatingControls();

        $this->addOtherControls();

        $this->end_controls_section();
    }

    private function addMainValueControls(): void
    {
        $this->add_control(
            'myhome_listing_main_value_heading',
            [
                'label' => esc_html__('Main Value', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $fields = tdf_ordered_fields()->filter(static function ($field) {
            return $field instanceof PriceField || $field instanceof SalaryField;
        });

        $options = [];

        foreach ($fields as $field) {
            /*  @var Field $field */
            $options[$field->getKey()] = $field->getName();
        }

        $this->add_control(
            'myhome_listing_main_value',
            [
                'label' => esc_html__('Field', 'myhome-core'),
                'type' => Controls_Manager::SELECT2,
                'multiple' => true,
                'options' => $options,
            ]
        );

        $this->add_control(
            'myhome_listing_main_value_when_empty',
            [
                'label' => esc_html__('When Empty', 'myhome-core'),
                'type' => Controls_Manager::TEXT,
            ]
        );

        $this->add_control(
            'myhome_listing_card_price_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-main-value' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'myhome_listing_card_price_typography',
                'label' => esc_html__('Typography', 'myhome-core'),
                'selector' => $this->getWrapper() . ' .myhome-listing-card-main-value',
            ]
        );
    }

    private function addCardAttributesControls(): void
    {
        $this->add_control(
            'myhome_listing_card_attributes_heading',
            [
                'label' => esc_html__('Basic Information', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'attributes_icon_color',
            [
                'label' => esc_html__('Icon', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card__attribute-icon path' => 'fill: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row__attribute-icon path' => 'fill: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'attributes_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card__attribute' => 'color: {{VALUE}}',
                    $this->getWrapper() . ' .myhome-listing-row__attribute' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'attributes_background',
            [
                'label' => esc_html__('Background', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card__attribute' => 'background-color: {{VALUE}}',
                    $this->getWrapper() . ' .myhome-listing-row__attribute' => 'background-color: {{VALUE}};',
                ]
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_attributes_tabs');

        $this->start_controls_tab('myhome_listing_card_attributes_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->addAttributesControl('myhome_listing_attributes');

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_row_attributes_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->addAttributesControl('myhome_row_listing_attributes');

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addAdditionalDetailsControls(): void
    {
        $this->add_control(
            'myhome_listing_card_additional_details_heading',
            [
                'label' => esc_html__('Additional Details', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'card_meta_icon_color',
            [
                'label' => esc_html__('Icon Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-additional-attribute__icon path' => 'fill: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'card_meta_text_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-additional-attribute__value' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => esc_html__('Typography', 'myhome-core'),
                'name' => 'card_meta_typo',
                'selector' => $this->getWrapper() . ' .myhome-listing-card-additional-attribute__value',
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_additional_details_tabs');

        $this->start_controls_tab('myhome_listing_card_regular_additional_details_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->addAdditionalDetailsFieldsControl('myhome_listing_card_regular_additional_details');

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_row_additional_details_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->addAdditionalDetailsFieldsControl('myhome_listing_card_row_additional_details');

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addAdditionalDetailsFieldsControl(string $key): void
    {
        $fields = new Repeater();

        $fields->add_control(
            'type',
            [
                'label' => esc_html__('Type', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => ListingAttributeType::getLabels(),
                'default' => 'address',
            ]
        );

        $fields->add_control(
            'address_type',
            [
                'label' => esc_html__('Address Type', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => AddressTypesHelper::make()->getAddressTypes(),
                'condition' => [
                    'type' => ListingAttributeType::ADDRESS,
                ],
            ]
        );

        $this->add_control(
            $key,
            [
                'label' => esc_html__('Fields', 'myhome-core'),
                'type' => Controls_Manager::REPEATER,
                'fields' => $fields->get_controls(),
                'prevent_empty' => false,
            ]
        );
    }

    /** @noinspection DuplicatedCode */
    private function addAttributesControl(string $controlKey): void
    {
        $options = [];
        foreach (tdf_simple_text_value_fields() as $field) {
            $options[tdf_prefix() . '_' . $field->getId()] = $field->getName();
        }

        $fields = new Repeater();

        $fields->add_control(
            'icon',
            [
                'label' => esc_html__('Icon', 'myhome-core'),
                'type' => Controls_Manager::ICONS,
            ]
        );

        $fields->add_control(
            'field',
            [
                'label' => esc_html__('Field', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => $options,
            ]
        );

        $this->add_control(
            $controlKey,
            [
                'label' => esc_html__('Attributes', 'myhome-core'),
                'type' => Controls_Manager::REPEATER,
                'fields' => $fields->get_controls(),
                'prevent_empty' => false,
            ]
        );
    }

    private function addLabelControls(): void
    {
        $this->add_control(
            'myhome_listing_card_labels_heading',
            [
                'label' => esc_html__('Labels', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $options = [
            'featured' => esc_html__('Featured', 'myhome-core'),
        ];

        foreach (tdf_taxonomy_fields() as $field) {
            $options[$field->getKey()] = $field->getName();
        }

        foreach (tdf_text_fields() as $field) {
            $options[$field->getKey()] = $field->getName();
        }

        $fields = new Repeater();

        $fields->add_control(
            'value',
            [
                'label' => esc_html__('Value', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => $options,
            ]
        );

        $this->add_control(
            'myhome_listing_card_label',
            [
                'label' => esc_html__('Labels', 'myhome-core'),
                'type' => Controls_Manager::REPEATER,
                'fields' => $fields->get_controls(),
                'prevent_empty' => false,
            ]
        );

        $this->add_control(
            'myhome_listing_card_label_color',
            [
                'label' => esc_html__('Featured Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-featured-label-selector' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_label_bg_color',
            [
                'label' => esc_html__('Featured Background', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-featured-label-selector' => 'background-color: {{VALUE}};',
                ]
            ]
        );
    }

    private function addDescriptionControls(): void
    {
        $this->add_control(
            'card_description_heading',
            [
                'label' => esc_html__('Description', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'card_description_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-description-selector' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => esc_html__('Typography', 'myhome-core'),
                'name' => 'card_description_typo',
                'selector' => $this->getWrapper() . ' .myhome-listing-card-description-selector',
            ]
        );

        $this->start_controls_tabs('card_description_tabs');

        $this->start_controls_tab('card_description_regular_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->add_control(
            'card_description_regular_show',
            [
                'label' => esc_html__('Display', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '0',
            ]
        );

        $this->add_control(
            'card_description_regular_lines',
            [
                'label' => esc_html__('Max Lines Number', 'myhome-core'),
                'type' => Controls_Manager::NUMBER,
                'default' => 2,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card__description' => '-webkit-line-clamp: {{VALUE}};',
                ],
                'condition' => [
                    'card_description_regular_show' => '1',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab('card_description_row_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->add_control(
            'card_description_row_show',
            [
                'label' => esc_html__('Display', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
            ]
        );

        $this->add_control(
            'card_description_row_lines',
            [
                'label' => esc_html__('Max Lines Number', 'myhome-core'),
                'type' => Controls_Manager::NUMBER,
                'default' => 2,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-row__description' => '-webkit-line-clamp: {{VALUE}};',
                ],
                'condition' => [
                    'card_description_row_show' => '1',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addRatingControls(): void
    {
        $this->add_control(
            'myhome_listing_card_rating_heading',
            [
                'label' => esc_html__('Rating', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'myhome_listing_card_rating_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card .myhome-rating__rating' => 'color: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row .myhome-rating__rating' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_rating_count_color',
            [
                'label' => esc_html__('Number Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card .myhome-rating__count' => 'color: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row .myhome-rating__count' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_rating_star_tabs');

        $this->start_controls_tab('myhome_listing_card_rating_star_empty_tab', ['label' => esc_html__('Empty', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_rating_star_empty_color',
            [
                'label' => esc_html__('Star Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card .myhome-rating__star path' => 'fill: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row .myhome-rating__star path' => 'fill: {{VALUE}};',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_rating_star_active_tab', ['label' => esc_html__('Active', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_rating_star_active_color',
            [
                'label' => esc_html__('Star Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card .myhome-rating__star--active path' => 'fill: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row .myhome-rating__star--active path' => 'fill: {{VALUE}};',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->end_controls_tabs();

        $this->start_controls_tabs('myhome_listing_card_rating_tabs');

        $this->start_controls_tab('myhome_listing_card_rating_regular_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_regular_rating_show',
            [
                'label' => esc_html__('Display', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '0',
            ]
        );

        $this->add_control(
            'myhome_listing_card_regular_rating_type',
            [
                'label' => esc_html__('Rating Type', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => RatingType::getLabels(),
                'default' => RatingType::USER,
                'condition' => [
                    'myhome_listing_card_regular_rating_show' => '1',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_regular_rating_count_show',
            [
                'label' => esc_html__('Display Ratings Number', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
                'condition' => [
                    'myhome_listing_card_regular_rating_show' => '1',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_row_rating_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_row_rating_show',
            [
                'label' => esc_html__('Display', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '0',
            ]
        );

        $this->add_control(
            'myhome_listing_card_row_rating_type',
            [
                'label' => esc_html__('Rating Type', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => RatingType::getLabels(),
                'default' => RatingType::USER,
                'condition' => [
                    'myhome_listing_card_row_rating_show' => '1',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_row_rating_count_show',
            [
                'label' => esc_html__('Display Ratings Number', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
                'condition' => [
                    'myhome_listing_card_row_rating_show' => '1',
                ]
            ]
        );

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addNameControls(): void
    {
        $this->add_control(
            'card_name_heading',
            [
                'label' => esc_html__('Name', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'card_name_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-name-selector' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => esc_html__('Typography', 'myhome-core'),
                'name' => 'card_name_typo',
                'selector' => $this->getWrapper() . ' .myhome-listing-card-name-selector',
            ]
        );
    }

    private function addUserPhoneNumberControls(): void
    {
        $this->add_control(
            'myhome_listing_card_user_phone_number_heading',
            [
                'label' => esc_html__('User Phone Number', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'myhome_listing_card_user_phone_number_icon_color',
            [
                'label' => esc_html__('Icon', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-user-phone .myhome-simple-button path' => 'fill: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_user_phone_number_color',
            [
                'label' => esc_html__('Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-user-phone .myhome-simple-button' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_user_phone_number_background',
            [
                'label' => esc_html__('Background', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card-user-phone .myhome-simple-button' => 'background-color: {{VALUE}};',
                ]
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'myhome_listing_card_user_phone_number_typography',
                'label' => esc_html__('Typography', 'myhome-core'),
                'selector' => $this->getWrapper() . ' .myhome-listing-card-user-phone .myhome-simple-button',
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_user_phone_number_tabs');

        $this->start_controls_tab(
            'myhome_listing_card_user_phone_number_regular_tab',
            ['label' => esc_html__('Regular', 'myhome-core')]
        );

        $this->addUserPhoneNumberVisibilityControls('regular');

        $this->end_controls_tab();

        $this->start_controls_tab(
            'myhome_listing_card_user_phone_number_row_tab',
            ['label' => esc_html__('Row', 'myhome-core')]
        );

        $this->addUserPhoneNumberVisibilityControls('row');

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addUserPhoneNumberVisibilityControls(string $controlId): void
    {
        $this->add_control(
            'myhome_listing_card_' . $controlId . '_show_user_phone',
            [
                'label' => esc_html__('Display', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '0',
            ]
        );

        $this->add_control(
            'myhome_listing_card_' . $controlId . '_hide_user_phone_at_start',
            [
                'label' => esc_html__('Initially Hidden', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
                'condition' => [
                    'myhome_listing_card_' . $controlId . '_show_user_phone' => '1',
                ]
            ]
        );
    }

    private function getWrapper(): string
    {
        if (is_rtl()) {
            return '[dir] {{WRAPPER}}';
        }

        return '{{WRAPPER}}';
    }

    protected function addGalleryControls(): void
    {
        $this->add_control(
            'myhome_listing_card_gallery_heading',
            [
                'label' => esc_html__('Image', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->addGalleryFieldControl();

        $this->add_control(
            'myhome_listing_card_gallery',
            [
                'label' => esc_html__('Gallery', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
            ]
        );

        $this->add_control(
            'myhome_listing_card_max_images',
            [
                'label' => esc_html__('Max Image Number', 'myhome-core'),
                'type' => Controls_Manager::NUMBER,
                'default' => 20,
                'condition' => [
                    'myhome_listing_card_gallery' => '1',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_active_color',
            [
                'label' => esc_html__('Active Dot Color', 'myhome-core'),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-card__pagination .myhome-swiper-pagination-bullet-active:before' => 'background-color: {{VALUE}};',
                    $this->getWrapper() . ' .myhome-listing-row__pagination .myhome-swiper-pagination-bullet-active:before' => 'background-color: {{VALUE}};',
                ],
                'condition' => [
                    'myhome_listing_card_gallery' => '1',
                ]
            ]
        );

        $this->add_control(
            'myhome_listing_card_image_size_heading',
            [
                'label' => esc_html__('Image Size', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_image_size_tabs');

        $this->start_controls_tab('myhome_listing_card_image_size_regular_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_image_size',
            [
                'label' => esc_html__('Size', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => tdf_app('image_size_options'),
                'default' => tdf_prefix() . '_360_240',
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_image_size_row_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_row_image_size',
            [
                'label' => esc_html__('Size', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => tdf_app('image_size_options'),
                'default' => tdf_prefix() . '_360_240',
            ]
        );

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }

    private function addGalleryFieldControl(): void
    {
        if (tdf_gallery_fields()->count() <= 1) {
            return;
        }

        $fields = tdf_gallery_fields();

        $options = [];
        foreach ($fields as $field) {
            $options[$field->getKey()] = $field->getName();
        }

        $this->add_control(
            'myhome_listing_card_gallery_field',
            [
                'label' => esc_html__('Gallery Field', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => $options,
            ]
        );
    }

    private function addOtherControls(): void
    {
        $this->add_control(
            'myhome_listing_card_other_heading',
            [
                'label' => esc_html__('Other', 'myhome-core'),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->start_controls_tabs('myhome_listing_card_other_controls_tabs');

        $this->start_controls_tab('myhome_listing_card_other_regular_controls_tab', ['label' => esc_html__('Regular', 'myhome-core')]);

        $this->add_control(
            'myhome_listing_card_show_user',
            [
                'label' => esc_html__('Display User', 'myhome-core'),
                'type' => Controls_Manager::SWITCHER,
                'return_value' => '1',
                'default' => '1',
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab('myhome_listing_card_other_row_controls_tab', ['label' => esc_html__('Row', 'myhome-core')]);

        $this->add_responsive_control(
            'myhome_listing_card_row_height',
            [
                'label' => esc_html__('Height', 'myhome-core'),
                'type' => Controls_Manager::SLIDER,
                'size_units' => ['px'],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 800,
                    ],
                ],
                'selectors' => [
                    $this->getWrapper() . ' .myhome-listing-row' => 'height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->add_control(
            'myhome_listing_card_row_bottom_left_type',
            [
                'label' => esc_html__('Bottom Left Attribute', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => ListingRowCardBottomAttributeType::getLabels(),
                'default' => ListingRowCardBottomAttributeType::USER,
            ]
        );

        $this->add_control(
            'myhome_listing_card_row_bottom_right_type',
            [
                'label' => esc_html__('Bottom Right Attribute', 'myhome-core'),
                'type' => Controls_Manager::SELECT,
                'options' => ListingRowCardBottomAttributeType::getLabels(),
                'default' => ListingRowCardBottomAttributeType::MAIN_VALUE,
            ]
        );

        $this->end_controls_tab();

        $this->end_controls_tabs();
    }
}