import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tone_snap/components/view_state_widget.dart';
import 'package:tone_snap/data/models/playlist_model.dart';
import 'package:tone_snap/data/storage/collect_playlists_box.dart';

class CollectPlaylistsController extends GetxController {
  static CollectPlaylistsController get to => Get.find<CollectPlaylistsController>();
  var viewState = ViewState.loading.obs;
  var scrollController = ScrollController();
  var playLists = <PlaylistModel>[].obs;

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

  @override
  void onClose() {
    scrollController.dispose();
    super.onClose();
  }

  void getList() {
    playLists.value = CollectPlaylistsBox().getReversedList();
    viewState.value = playLists.isNotEmpty ? ViewState.normal : ViewState.empty;
  }
}
