import { Component } from '@angular/core';
import { Router } from '@angular/router';

import { IconName } from 'src/app/shared/components/icon/icon.component';

interface Link {
  label: string;
  path: string;
  icon: IconName;
}
@Component({
  selector: 'app-tab-bar',
  templateUrl: './tab-bar.component.html',
  styleUrls: ['./tab-bar.component.scss'],
})
export class TabBarComponent {
  links: Link[] = [
    {
      label: 'Home',
      path: '/app/home',
      icon: 'home',
    },
    {
      label: 'Refeições',
      path: '/app/meals',
      icon: 'cutlery',
    },
    {
      label: 'Receitas',
      path: '/app/foods',
      icon: 'food',
    },
    {
      label: 'Perfil',
      path: '/app/profile',
      icon: 'person',
    },
  ];

  constructor(private route: Router) {}

  isFocused(path: string): boolean {
    const currentPath = this.route.url;

    if (currentPath === '/') {
      return path === '/home';
    }
    return currentPath.startsWith(path);
  }
}
