import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';
@Component({
  selector: 'app-home',
  templateUrl: 'Tab1.page.html',
  styleUrls: ['Tab1.page.scss'],
})
export class Tab1Page {
  isSearching = false;
  searchQuery = '';
  filteredItems: string[] = [];
  searchHistory = ['历史搜索项1', '历史搜索项2'];
  searchSuggestions = [
    '比心十周年·免单真金等你拿',
    '十年如初·因你而延续'
  ];

  recommendedPlayers = [
    { name: 'Player 1', info: '技术大神111111111111111111111111111111111111111111111111111111111111111111111111111', avatar: 'assets/avatar1.png' },
    { name: 'Player 2', info: '包赢承诺', avatar: 'assets/avatar2.png' },
    { name: 'Player 3', info: '优质声优', avatar: 'assets/avatar3.png' },
    { name: 'Player 4', info: '同城代练11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111', avatar: 'assets/avatar4.png' },
  ];

  selectedSegment = 'online';

  constructor(private navCtrl: NavController) {}

  showSearch() {
    this.isSearching = true;
  }

  hideSearch() {
    this.isSearching = false;
  }

  segmentChanged(event: any) {
    this.selectedSegment = event.detail.value;
  }

  filterChats() {
    const query = this.searchQuery.toLowerCase();
    this.filteredItems = this.recommendedPlayers.filter(player => player.name.toLowerCase().includes(query)).map(player => player.name);
  }

  loadMorePlayers() {
    this.navCtrl.navigateForward('/hot-recommendations');
  }
}
