import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod/legacy.dart';


final playbackActiveProvider = StateProvider<bool>((ref) => false);


class DetailPageActivity extends Notifier<int> {
  var _disposed = false;

  @override
  int build() {
    ref.onDispose(() => _disposed = true);
    return 0;
  }

  void enter() {
    if (_disposed) return;
    state = state + 1;
  }

  void leave() {
    if (_disposed || state <= 0) return;
    state = state - 1;
  }
}

final detailPageActivityProvider = NotifierProvider<DetailPageActivity, int>(
  DetailPageActivity.new,
);


final detailPageActiveProvider = Provider<bool>(
  (ref) => ref.watch(detailPageActivityProvider) > 0,
);
