Snippets Collections
<?php
if (!defined('ABSPATH')) {
    exit;
}

class  Elementor_Slider_Custom_Widget extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'custom_slider';
    }

    public function get_title()
    {
        return esc_html__('Custom Slider', 'elementor-list-widget');
    }

    public function get_icon()
    {
        return 'eicon-slides';
    }

    public function get_categories()
    {
        return ['custom'];
    }

    public function get_keywords()
    {
        return ['list', 'slider', 'custom', 'smo'];
    }

    protected function register_controls()
    {
        //content
        $this->start_controls_section(
            'section_content',
            [
                'label' => esc_html__('Content', 'textdomain'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'title_main',
			[
				'label' => esc_html__('Title', 'textdomain'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => 'text',
			]
		);
        $this->add_control(
            'slider_list',
            [
                'label' => esc_html__('List Item', 'textdomain'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'fields' => [
                    [
                        'name' => 'image',
                        'label' => esc_html__('Image', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::MEDIA,
                        'media_types' => ['image', 'video'],
                        'default' => [
                            'url' => \Elementor\Utils::get_placeholder_image_src(),
                        ],
                    ],
                    [
                        'name' => 'sub_title',
                        'label' => esc_html__('Top Title', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::TEXTAREA,
				        'rows' => 5,
                        'default' => '',
                    ],
                    [
                        'name' => 'sub_title_color',
                        'label' => esc_html__('Top Title Color', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::COLOR,
                        'default' => '#FFFFFF',
                    ],
                    [
                        'name' => 'title',
                        'label' => esc_html__('Title', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::TEXTAREA,
                        'rows' => 5,
                        'default' => '',
                    ],
                    [
                        'name' => 'title_color',
                        'label' => esc_html__('Title Color', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::COLOR,
                        'default' => '#FFFFFF',
                    ],
                    [
                        'name' => 'link',
                        'label' => esc_html__('Link', 'textdomain'),
                        'type' => \Elementor\Controls_Manager::URL,
                        'options' => ['url', 'is_external', 'nofollow'],
                        'default' => [
                            'url' => '',
                            'is_external' => false,
                            'nofollow' => false,
                            'custom_attributes' => '',
                        ],
                        'label_block' => true,
                    ],
                ],
                'title_field' => '{{{ sub_title }}}',
            ]
        );
        $this->end_controls_section();


        // Setting silder PC

        $this->start_controls_section(
            'section_slider',
            [
                'label' => esc_html__('Slider PC (>1024px) ', 'textdomain'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]

        );
        $this->add_control(
            'box_height',
            [
                'label' => esc_html__('Height', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => 471,
            ]
        );
        $this->add_control(
            'box_width',
            [
                'label' => esc_html__('Width', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => 353,
            ]
        );
        
        $this->add_control(
            'display_team',
            [
                'label' => esc_html__('Display', 'textdomain'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => '3.5',
            ]
        );
        $this->add_control(
            'space_between',
            [
                'label' => esc_html__('Space Between', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 100,
                'step' => 1,
                'default' => 14,
            ]
        );
        $this->add_control(
            'loop',
            [
                'label' => esc_html__('Loop', 'textdomain'),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__('Yes', 'textdomain'),
                'label_off' => esc_html__('No', 'textdomain'),
                'return_value' => 'yes',
                'default' => '',
            ]
        );
        $this->add_control(
            'pagination',
            [
                'label' => esc_html__('Pagination', 'textdomain'),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__('Yes', 'textdomain'),
                'label_off' => esc_html__('No', 'textdomain'),
                'return_value' => 'no',
                'default' => '',
            ]
        );
        $this->add_control(
            'navigation',
            [
                'label' => esc_html__('Navigation', 'textdomain'),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__('Yes', 'textdomain'),
                'label_off' => esc_html__('No', 'textdomain'),
                'return_value' => 'yes',
                'default' => '',
            ]
        );
        $this->end_controls_section();

        // Setting silder tablet
        $this->start_controls_section(
            'section_slider_tl',
            [
                'label' => esc_html__('Slider Tablet (768px - 1024px)', 'textdomain'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]

        );
        $this->add_control(
            'box_height_tl',
            [
                'label' => esc_html__('Height', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => '425',
            ]
        );
        $this->add_control(
            'box_width_tl',
            [
                'label' => esc_html__('Width', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => '318',
            ]
        );
        
        $this->add_control(
            'display_team_tl',
            [
                'label' => esc_html__('Display', 'textdomain'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => '3.2',
            ]
        );
        $this->add_control(
            'space_between_tl',
            [
                'label' => esc_html__('Space Between', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 100,
                'step' => 1,
                'default' => 14,
            ]
        );
        $this->end_controls_section();

        //Setting silder MB
        $this->start_controls_section(
            'section_slider_mb',
            [
                'label' => esc_html__('Slider Mobile (< 768px)', 'textdomain'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]

        );
        $this->add_control(
            'box_height_mb',
            [
                'label' => esc_html__('Height', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => '320',
            ]
        );
        $this->add_control(
            'box_width_mb',
            [
                'label' => esc_html__('Width', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 10000,
                'step' => 1,
                'default' => '240',
            ]
        );
        
        $this->add_control(
            'display_team_mb',
            [
                'label' => esc_html__('Display', 'textdomain'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => '1.5',
            ]
        );
        $this->add_control(
            'space_between_mb',
            [
                'label' => esc_html__('Space Between', 'textdomain'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'min' => 1,
                'max' => 100,
                'step' => 1,
                'default' => 14,
            ]
        );
        $this->end_controls_section();



        // Style

        $this->start_controls_section(
			'style_name',
			[
				'label' => esc_html__( 'Style Title', 'textdomain' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE,
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Typography::get_type(),
			[
				'name' => 'title_typography',
				'selector' => '{{WRAPPER}} .slider-title',
			]
		);
        
        $this->end_controls_section();


        $this->start_controls_section(
			'style_slider_title',
			[
				'label' => esc_html__( 'Style Slider', 'textdomain' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE,
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Typography::get_type(),
			[
				'name' => 'slider_title_typography',
				'selector' => '{{WRAPPER}} .title',
			]
		);
		$this->end_controls_section();
		
		
		$this->start_controls_section(
			'style_slider_subtitle',
			[
				'label' => esc_html__( 'Style Slider Subtitle', 'textdomain' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE,
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Typography::get_type(),
			[
				'name' => 'slider_subtitle_typography',
				'selector' => '{{WRAPPER}} .sub-title',
			]
		);

		$this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        $title_main = $settings['title_main'];
        
        $slider_list = $settings['slider_list'];
        $box_height = $settings['box_height'];
        $box_width = $settings['box_width'];
        $display_team = $settings['display_team'];
        $loop = $settings['loop'] === 'yes' ? 'true' : 'false';
        $navigation  = $settings['navigation'];
        $pagination = $settings['pagination'];
        $space_between = $settings['space_between'];

        $box_height_mb = $settings['box_height_mb'];
        $box_width_mb = $settings['box_width_mb'];
        $display_team_mb = $settings['display_team_mb'];
        $space_between_mb = $settings['space_between_mb'];

        $box_height_tl = $settings['box_height_tl'];
        $box_width_tl = $settings['box_width_tl'];
        $display_team_tl = $settings['display_team_tl'];
        $space_between_tl = $settings['space_between_tl'];

        // Generate a random string
        $unique_id = uniqid();
        $class_unique = 'slider-item'.$unique_id;
        ob_start();
        ?>
        <!-- PC -->
        <div class="smo-slider-section">
            <div class="smo-title-container">
                <div class="smo-title-box">
                    <?php if(!empty($title_main)): ?>
                        <h2 class="slider-title"><?php echo $title_main?></h2>
                    <?php endif; ?>
                    <?php if($navigation == "yes"):?>
                        <div class="slider-navigation">
                            <div class="navigation-next  navigation-next-<?php echo $unique_id; ?>">
                                <svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd" clip-rule="evenodd" d="M16.2929 27.2572C15.9024 26.8666 15.9024 26.2335 16.2929 25.8429L21.5858 20.55L16.2929 15.2571C15.9024 14.8666 15.9024 14.2334 16.2929 13.8429C16.6834 13.4524 17.3166 13.4524 17.7071 13.8429L23.7071 19.8429C23.8946 20.0305 24 20.2848 24 20.55C24 20.8152 23.8946 21.0696 23.7071 21.2571L17.7071 27.2572C17.3166 27.6477 16.6834 27.6477 16.2929 27.2572Z" fill="#080808" fill-opacity="0.8"/>
                                </svg>
                            </div>
                            <div class="navigation-prev navigation-prev-<?php echo $unique_id; ?>">
                                <svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd" clip-rule="evenodd" d="M23.7071 13.8429C24.0976 14.2335 24.0976 14.8666 23.7071 15.2572L18.4142 20.5501L23.7071 25.8429C24.0976 26.2334 24.0976 26.8666 23.7071 27.2571C23.3166 27.6476 22.6834 27.6476 22.2929 27.2571L16.2929 21.2572C16.1054 21.0696 16 20.8153 16 20.5501C16 20.2848 16.1054 20.0305 16.2929 19.843L22.2929 13.8429C22.6834 13.4524 23.3166 13.4524 23.7071 13.8429Z" fill="#080808" fill-opacity="0.8"/>
                                </svg>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>

            <div class="smo-slider-container">
                <div class="smo-slider smo-slider-<?php echo $unique_id; ?> swiper">
                    <div class="swiper-wrapper">
                        <?php foreach ($slider_list as $key => $team):
                            $image = $team['image']['url'];
                            $title = $team['title'];
                            $title_color = $team['title_color'];
                            $sub_title = $team['sub_title'];
                            $sub_title_color = $team['sub_title_color'];
                            $link = $team['link'];
                            $tags = !empty($link['url'])?'a':'div';
                            $href = !empty($link['url'])?'href="'.$link['url'].'"':'';
                            $target = !empty($link['url']) && $link['is_external'] ? 'target="_blank"' : '';
                            $nofollow = !empty($link['url']) && $link['nofollow'] ? 'rel="nofollow"' : '';

                            $is_video = preg_match('/\.(mp4|webm|ogg)$/i', $image);
                            ?>
                            <div class="swiper-slide slider-item <?php echo $class_unique ?>">
                                <<?php echo $tags ?> class="item-box" style="background: url(<?php echo (!$is_video)?esc_url($image):'' ?>) center/cover no-repeat;" <?php echo $href ?> <?php echo $target ?> <?php echo $nofollow ?>>
                                    <?php if ($is_video): ?>
                                        <video class="background-media" autoplay loop muted playsinline>
                                            <source src="<?php echo esc_url($image) ?>" type="video/mp4">
                                        </video>
                                    <?php endif; ?>
                                    <div class="slider-infor">
                                        <?php if(!empty($sub_title)): ?>
                                            <p class="sub-title" style="color: <?php echo $sub_title_color ?>">
                                                <?php echo $sub_title ?>
                                            </p>
                                        <?php endif; ?>

                                        <?php if(!empty($title)): ?>
                                        <h3 class="title" style="color: <?php echo $title_color ?>">
                                            <?php echo $title ?>
                                        </h3>
                                        <?php endif; ?>
                                        
                                    </div>
                                </<?php echo $tags ?>>
                            </div>
                        <?php endforeach; ?>
                    </div>
                    <?php if($pagination == "yes"):?>
                        <div class="swiper-pagination slider-pagination"></div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <style>
            .smo-slider-section <?php echo '.'.$class_unique ?>{
                aspect-ratio: <?php echo $box_width?>/<?php echo $box_height?>;
                max-width: <?php echo $box_width?>px;
            }
            @media(max-width: 1024px){
                .smo-slider-section <?php echo '.'.$class_unique ?>{
                    aspect-ratio: <?php echo $box_width_tl?>/<?php echo $box_height_tl?>;
                    max-width: <?php echo $box_width_tl?>px;
                }
            }
            @media(max-width: 767px){
                .smo-slider-section <?php echo '.'.$class_unique ?>{
                    aspect-ratio: <?php echo $box_width_mb?>/<?php echo $box_height_mb?>;
					max-width: <?php echo $box_width_mb?>px;
                }
            }
        </style>

        <script>
            (function ($) {
                $(document).ready(function () {
                    var swiper = new Swiper(".smo-slider-<?php echo $unique_id; ?>", {
                        slidesPerView: <?php echo $display_team; ?>,
                        spaceBetween: <?php echo $space_between; ?>,
                        loop: <?php echo $loop; ?>,
                        centeredSlides: false,
						speed: 600,
                        breakpoints: {
                            0: {
                                slidesPerView: <?php echo $display_team_mb; ?>,
                                spaceBetween: <?php echo $space_between_mb; ?>,
                            },
                            768: {
                                slidesPerView: <?php echo $display_team_tl; ?>,
                                spaceBetween: <?php echo $space_between_tl; ?>,
                            },
                            1025: {
                                slidesPerView: <?php echo $display_team; ?>,
                                spaceBetween: <?php echo $space_between; ?>,
                            }
                        },
                        pagination: {
                            el: ".slider-pagination",
                        },
                        navigation: {
                            nextEl: ".navigation-next-<?php echo $unique_id; ?>",
                            prevEl: ".navigation-prev-<?php echo $unique_id; ?>",
                        },
// 						direction: 'horizontal',
// 						mousewheel: true,
// 						effect: 'slide'
                    });
                });
            })(jQuery)
        </script>
        <?php
        echo ob_get_clean();
    }
}


import 'package:flutter/material.dart';
import 'package:pets_home/utils.dart';

class CustomSignInButton extends StatelessWidget {
  final String imagePath;
  final String text;
  final VoidCallback onTap;

  const CustomSignInButton({
    Key? key,
    required this.imagePath,
    required this.text,
    required this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: double.infinity,
        margin: EdgeInsets.symmetric(horizontal: calculateWidth(31)),
        padding: EdgeInsets.symmetric(horizontal: 0, vertical: calculateHeight(8)),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(32), // Rounded corners
          border: Border.all(
            color: primaryColor, // Border color
            width: 2, // Border width
          ),
        ),
        child: Padding(
          padding: EdgeInsets.only(left: calculateWidth(54)),
          child: Row(
            mainAxisSize: MainAxisSize.min, // Adjusts based on content
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Image.asset(
                imagePath,
                height: calculateHeight(50), // Size of the image
                width: calculateHeight(50),
              ),
              const SizedBox(width: 12), // Spacing between image and text
              Text(
                text,
                style: const TextStyle(
                  color: Colors.brown, // Text color
                  fontSize: 16, // Font size
                  fontWeight: FontWeight.bold,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}



//call

     Column(
            children: [
              SizedBox(height: calculateHeight(29)),
              CustomSignInButton(
                imagePath: 'assets/google_icon.png', // Google logo path
                text: 'Sign in using Google',
                onTap: () {
                  print('Google Sign-in button tapped');
                  // Google login logic here
                },
              ),
              const SizedBox(height: 16), // Space between buttons
              CustomSignInButton(
                imagePath: 'assets/facebook_icon.png', // Facebook logo path
                text: 'Sign in using Facebook',
                onTap: () {
                  print('Facebook Sign-in button tapped');
                  // Facebook login logic here
                },
              ),
              const SizedBox(height: 16), // Space between buttons
              CustomSignInButton(
                imagePath: 'assets/apple_icon.png', // Apple logo path
                text: 'Sign in using Apple',
                onTap: () {
                  print('Apple Sign-in button tapped');
                  // Apple login logic here
                },
              ),
            ],
          ) 

/**configure your WordPress site to send emails via the Brevo API**/

function send_email_via_brevo($to, $subject, $message, $headers = '', $attachments = []) {
    $api_url = 'https://api.brevo.com/v3/smtp/email';
    $api_key = '123'; // Your Brevo API key

    // Email data structure
    $email_data = [
        'sender' => [
            'email' => 'contact@example.com', // Your email address
            'name' => 'Your Name' // Your name
        ],
        'to' => [
            [
                'email' => $to, // Recipient's email
                'name' => '' // Recipient's name (optional)
            ]
        ],
        'subject' => $subject,
        'htmlContent' => $message
    ];

    // Headers for the API request
    $request_headers = [
        'Content-Type: application/json',
        'api-key: ' . $api_key
    ];

    // Arguments for the API request
    $args = [
        'body' => json_encode($email_data),
        'headers' => $request_headers,
        'method' => 'POST',
        'data_format' => 'body'
    ];

    // Send the API request
    $response = wp_remote_post($api_url, $args);

    // Handle any errors
    if (is_wp_error($response)) {
        error_log('Email sending failed: ' . $response->get_error_message());
        return false;
    }

    // Log the response
    $response_body = wp_remote_retrieve_body($response);
    error_log('Email sent response: ' . $response_body);

    return true;
}

function override_wp_mail($args) {
    return send_email_via_brevo($args['to'], $args['subject'], $args['message'], $args['headers'], $args['attachments']);
}

add_filter('wp_mail', 'override_wp_mail', 10, 1);

/* single checkbox */

body.snapform .form-group .snap-field .check-box-label{
    padding-left: 40px!important;
}


body.snapform .form-group .snap-field span.checkbox.custom-checkbox label:before{
	width: 32px;
    height: 32px;
    visibility: visible;
    content: " ";
    display: block;
    position: absolute;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background-repeat: no-repeat;
    z-index: 100;
    left: 0px;
    left: 0rem;
    border: 2px solid transparent;
    top: 0;
    background-color: transparent;
    border-color: var(--QLD-color-light-designAccent);
    background-image: none !important;
}

body.snapform .form-group .snap-field span.checkbox.custom-checkbox label:after{
	width: 32px;
    height: 32px;
    visibility: visible;
    content: " ";
    display: block;
    position: absolute;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background-repeat: no-repeat;
    z-index: 100;
    left: 0px;
    left: 0rem;
    border: 2px solid transparent;
    top: 0;
}


body.snapform .form-group .snap-field span.checkbox.custom-checkbox input[type="checkbox"]:checked+label:before{
	width: 32px!important;
    height: 32px!important;
    visibility: visible;
    content: " ";
    display: block;
    position: absolute;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background-repeat: no-repeat;
    z-index: 100;
    left: 0px;
    left: 0rem;
    border: 2px solid transparent;
    top: 0;
    background-color: transparent!important;
    border-color: var(--QLD-color-light-designAccent)!important;
    background-image: none !important;

}


body.snapform .form-group .snap-field span.checkbox.custom-checkbox input[type="checkbox"]:checked+label:after{
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='var(--QLD-color-light-text)' d='M25.6,11.4c0.2-0.2,0.2-0.5,0-0.7l-2.3-2.3c-0.2-0.2-0.5-0.2-0.7,0L14,17l-3.6-3.6c-0.2-0.2-0.5-0.2-0.7,0l-2.3,2.3 c-0.2,0.2-0.2,0.5,0,0.7l6.3,6.3c0.2,0.2,0.5,0.2,0.7,0L25.6,11.4L25.6,11.4z'/%3E%3C/svg%3E");
    background-size: 30px!important;
    background-position: -2px -2px!important;
    font-size: 20px !important;
    left: 0px!important;

}
 // HTML

 <div className='container' data-columns="4">
          <div className="container__block container__block--image1"></div>
          <div className="container__block container__block--image2"></div>
          <div className="container__block container__block--image3"></div>
          <div className="container__block"></div>
      </div>




// CSS

.container{
  width: 1200px;
  height: 600px;
  margin: auto auto;
   background-color: red;
   display: grid;
  //replace the value we want to make dynamic with a var(--something, x) where x is a fallback if --something doesnt exist
  grid-template-columns: repeat(var(--column-count, 4), 1fr); 
  place-content: center;
   align-items: center;
   justify-content: center;
   justify-items: center;

   // use data attribute vales on the html to change the variable --something
   &[data-columns="2"]{
      --column-count: 2;
   }

   &[data-columns="3"]{
    --column-count: 3;
    }

    &[data-columns="4"]{
      --column-count: 4;
    }



   &__block{
    width: 200px;
    height: 200px;
    background-color: rebeccapurple;
    border: 1px solid white;
    background-size: cover;
    background-repeat: no-repeat;
    background-image: var(--selected-url);

        &--image1{
          --selected-url: url('https://source.unsplash.com/user/c_v_r')
        }

        &--image2{
          --selected-url: url('https://www.kimballstock.com/images/car-stock-photos.jpg')
        }

        &--image3{
          --selected-url: url('https://media.gettyimages.com/id/1636857191/photo/topshot-moto-prix-esp-catalunya-practice.jpg?s=2048x2048&w=gi&k=20&c=bt3AqEevYACDxkxf5Rom1MqE4bjHrMG2apxxTkmedJ8=')
        }


   }
 }
import UIKit

class CustomTableViewCell: UITableViewCell {
    var labelStackView: UIStackView!
    var innerView: UIView!
    var label: UILabel!

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupInnerView()
        setupLabelStackView()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupInnerView()
        setupLabelStackView()
    }
    
    private func setupInnerView() {
        
            innerView = UIView()
            innerView.translatesAutoresizingMaskIntoConstraints = false
            innerView.layer.borderWidth = 1.0 // 1-point border width
            innerView.layer.borderColor = UIColor.lightGray.cgColor // Border color
            
            contentView.addSubview(innerView)

            NSLayoutConstraint.activate([
                innerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10), // 8-point spacing from the left
                innerView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 6), // 8-point spacing from the top
                innerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10), // 8-point spacing from the right
                innerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -6) // 8-point spacing from the bottom
            ])
        
        innerView.layer.cornerRadius = 13
        innerView.layer.borderColor = self.hexStringToUIColor(hex: "DCD8D8").cgColor
    }
    
    private func setupLabelStackView() {
        labelStackView = UIStackView()
        labelStackView.translatesAutoresizingMaskIntoConstraints = false
        labelStackView.axis = .vertical
        labelStackView.spacing = 8 // Adjust the vertical spacing between labels
        contentView.addSubview(labelStackView)

        NSLayoutConstraint.activate([
            labelStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
            labelStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16),
            labelStackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
            labelStackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -16)
        ])
    }
    
    func setupLabels(labelData: [(String, UIImage, Int)]) -> ([UILabel], [UIImageView], [Int]) {
        
        var labels: [UILabel] = []
        var imageViews: [UIImageView] = []
        var tags: [Int] = []

        for (labelText, image, tag) in labelData {
            print("tagfkj : ", tag)
            let stackView = UIStackView()
            stackView.axis = .horizontal
            stackView.spacing = 8

            let imageView = UIImageView(image: image)
            imageView.contentMode = .scaleAspectFit
            imageView.widthAnchor.constraint(equalToConstant: 23).isActive = true
            imageView.heightAnchor.constraint(equalToConstant: 23).isActive = true
            imageView.tag = tag
            imageView.accessibilityIdentifier = "sewer"
            
            let label = UILabel()
            label.translatesAutoresizingMaskIntoConstraints = false
            label.text = labelText
            label.tag = tag
            
            stackView.addArrangedSubview(imageView)
            stackView.addArrangedSubview(label)

            labelStackView.addArrangedSubview(stackView)

            labels.append(label)
            imageViews.append(imageView)
            tags.append(tag)
        }

        return (labels, imageViews, tags)
    }
    
    func hexStringToUIColor (hex:String) -> UIColor {
        var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

        if (cString.hasPrefix("#")) {
            cString.remove(at: cString.startIndex)
        }

        if ((cString.count) != 6) {
            return UIColor.gray
        }

        var rgbValue:UInt64 = 0
        Scanner(string: cString).scanHexInt64(&rgbValue)

        return UIColor(
            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
            alpha: CGFloat(1.0)
        )
    }
}






func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

  var imagesArray = ["circle_complete_icon", "circle_unsel"]()
            var textArray = ["jfdsk", "dfs"]()
            var tag = indexpath.row
            var idsArray = ["1","2"]()

      tag = indexPath.row
            print("tag43 : \(indexPath.row) ", tag)
            
            
            let cell = tableView.dequeueReusableCell(withIdentifier: "CustomTableViewCell", for: indexPath) as! CustomTableViewCell
            cell.selectionStyle = .none
            
            for subview in cell.labelStackView.arrangedSubviews {
                cell.labelStackView.removeArrangedSubview(subview)
                subview.removeFromSuperview()
            }
            
            var count = 0
            let labelsAndImagesForCell = textArray.enumerated().map { (index, labelText) -> (String, UIImage, Int) in
                let imageName = imagesArray[count]
                count += 1
                let image = UIImage(named: imageName) ?? UIImage()
                
                // Replace "UIImage()" with your default image if needed
                print("chk378: ", indexPath.row)
                return (labelText, image, tag)
            }
            
            let (labels, imageViews, tags) = cell.setupLabels(labelData: labelsAndImagesForCell)
            
            // Access and configure each label and image view individually
            var c = 0
            for (index, label) in (labels).enumerated() {
                label.text = labelsAndImagesForCell[index].0
                let labelTapGesture = UITapGestureRecognizer(target: self, action: #selector(subCategoryPressed(tagGesture: )))
                label.tag = tags[c]
                label.accessibilityIdentifier = idsArray[c]
                c += 1
                label.isUserInteractionEnabled = true
                label.addGestureRecognizer(labelTapGesture)
            }
            
            var c1 = 0
            for (index, imageView) in imageViews.enumerated() {
                imageView.image = labelsAndImagesForCell[index].1
                
                let tapGesture = UITapGestureRecognizer(target: self, action: #selector(subCategoryPressed(tagGesture: )))
                imageView.tag = tags[c1]
                imageView.accessibilityIdentifier = idsArray[c1]
                c1 += 1
                imageView.isUserInteractionEnabled = true
                imageView.addGestureRecognizer(tapGesture)
            }
            
            imagesArray = []
            textArray = []
            
            return cell
            
        }

const [scroll, setScroll] = useState(false);
 useEffect(() => {
   window.addEventListener("scroll", () => {
     setScroll(window.scrollY > 500);
   });
 }, []);

// Se implementa asi
<div className={scroll ? "box-buscador is--fixed" : "box-buscador"}>
        let parameters: [String:Any] = [
            "country" : "US",
            "type" : "custom",
            "capabilities": ["card_payments": ["requested": "true"], "transfers": ["requested": "true"]]]
            //"business_type": "individual",
//            "business_profile[url]": "https://google.com"]
        
        let url = "https://api.stripe.com/v1/accounts"
        let api_key = ""
        let loginData = api_key.data(using: String.Encoding.utf8)
        let base64LoginString = loginData?.base64EncodedString()
        print("key : ", (base64LoginString ?? "") as String)
        let headers: HTTPHeaders = ["Authorization": "Basic \(base64LoginString!)", "Content-Type": "application/x-www-form-urlencoded", "Accept": "*/*"]
        AF.request(url, method: .post, parameters: parameters, headers: headers)
            .responseJSON(completionHandler: { (response) in
                do {
                    let json = try JSON(data: response.data!)
                    print(json["id"])
                }
                catch let error {
                    print(error.localizedDescription)
                }
            })
star

Sat Mar 29 2025 02:31:22 GMT+0000 (Coordinated Universal Time)

#elementor #custom #widget #slider
star

Tue Oct 22 2024 07:13:41 GMT+0000 (Coordinated Universal Time)

#dart #flutter #custom #signin
star

Mon Jun 10 2024 06:09:03 GMT+0000 (Coordinated Universal Time)

#css #forms #custom #radio
star

Tue Apr 09 2024 01:30:23 GMT+0000 (Coordinated Universal Time)

#custom #properties
star

Wed Aug 02 2023 07:18:27 GMT+0000 (Coordinated Universal Time)

#ios #swift #cell #custom #customcell
star

Sat May 13 2023 05:57:46 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/44205000/how-to-add-class-in-element-on-scroll-react-js

#hooks #custom
star

Tue May 09 2023 12:47:44 GMT+0000 (Coordinated Universal Time) https://codesandbox.io/s/quirky-glade-brmwg6?file

#hooks #custom
star

Wed Nov 02 2022 16:30:52 GMT+0000 (Coordinated Universal Time) https://kuchbhilearning.blogspot.com/2022/11/add-custom-header-in-cloudfrontpass.html

#aws #cloudfront #custom #originrequest
star

Wed Oct 12 2022 03:02:35 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/20996104/how-to-change-panel-border-color

#panel #custom #border #draw
star

Tue Apr 05 2022 07:14:32 GMT+0000 (Coordinated Universal Time)

#ios #swift #custom #stripe #stripeconnect
star

Thu Aug 26 2021 03:10:25 GMT+0000 (Coordinated Universal Time) https://codepen.io/rooc/pen/bONbqw

#youtube #custom #playbutton #js
star

Thu Aug 26 2021 03:08:48 GMT+0000 (Coordinated Universal Time) https://codepen.io/arjunamgain/pen/zxydgg

##youyube #playbutton #custom #js

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension