<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/**
 * Product list toolbar
 *
 * @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
 */

$themeHelper = $this->helper('MGS\ThemeSettings\Helper\Config');

$showTitlePosition = $themeHelper->getStoreConfig('themesettings/category/breadcrumb_position_title');
?>
<?php if ($block->isEnabledViewSwitcher()) :?>
    <div class="modes">
        <?php if ( $showTitlePosition == 'topbar' ) : ?>
            <h1 class="arrow-topbar-page-title"><?= $block->getLayout()->getBlock('page.main.title')->getPageTitle(); ?></h1>
        <?php endif; ?>

        <?php $_modes = $block->getModes(); ?>
        <?php if ($_modes && count($_modes) > 1) :?>
            <strong class="modes-label" id="modes-label"><?= $block->escapeHtml(__('View as')) ?></strong>
            <?php foreach ($block->getModes() as $_code => $_label) :?>
                <?php if ($block->isModeActive($_code)) :?>
                    <div class="arrow-mode arrow-mode-<?= $block->escapeHtmlAttr(strtolower($_code)) ?>">
                        <strong title="<?= $block->escapeHtmlAttr($_label) ?>"
                                class="modes-mode active mode-<?= $block->escapeHtmlAttr(strtolower($_code)) ?>"
                                data-value="<?= $block->escapeHtmlAttr(strtolower($_code)) ?>">
                            <span><?= $block->escapeHtml($_label) ?></span>
                        </strong>
                    </div>
                <?php else :?>
                    <a class="modes-mode mode-<?= $block->escapeHtmlAttr(strtolower($_code)) ?>"
                       title="<?= $block->escapeHtmlAttr($_label) ?>"
                       href="#"
                       data-role="mode-switcher"
                       data-value="<?= $block->escapeHtmlAttr(strtolower($_code)) ?>"
                       id="mode-<?= $block->escapeHtmlAttr(strtolower($_code)) ?>"
                       aria-labelledby="modes-label mode-<?= $block->escapeHtmlAttr(strtolower($_code)) ?>">
                        <span><?= $block->escapeHtml($_label) ?></span>
                    </a>
                <?php endif; ?>
            <?php endforeach; ?>
        <?php endif; ?>
    </div>
<?php endif; ?>
