import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tone_snap/routes/app_routes.dart';

class MusicBarController extends GetxController with GetSingleTickerProviderStateMixin {
  static MusicBarController get to => Get.find<MusicBarController>();
  var bottom = 0.0.obs;

  @override
  void onInit() {
    super.onInit();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      if (Get.currentRoute == AppRoutes.initialB) {
        bottom.value = kBottomNavigationBarHeight;
      }
    });
  }

  /// 底部导航栏消失时沉底
  void toBottom() {
    bottom.value = 0.0;
  }

  /// 底部导航栏出现时抬高
  void riseUp() {
    bottom.value = kBottomNavigationBarHeight;
  }

  /// 打开播放页面
  void openPlayPage() {
    Get.toNamed(AppRoutes.playPage, arguments: {
      'isFormMusicBar': true,
    });
  }
}
