import 'package:get/get.dart';
import 'package:tone_snap/data/storage/music_box.dart';
import 'package:tone_snap/routes/app_routes.dart';

class SearchMusicController extends GetxController {
  static SearchMusicController get to => Get.find<SearchMusicController>();
  var historyList = <String>[].obs;

  @override
  void onReady() {
    super.onReady();
    getList();
  }

  void getList() {
    historyList.value = MusicBox().getAllSearchHistory();
    update(['history']);
  }

  void deleteHistory() {
    MusicBox().deleteAllSearchHistory();
    getList();
  }

  void onTapHistoryItem(String history) {
    Get.toNamed(AppRoutes.searchResult, arguments: history);
  }

  void openSearch() {
    Get.toNamed(AppRoutes.searchResult);
  }
}
