import SwiftUI

struct TrainingView: View {
    @ObservedObject var controller: PlayerController
    @ObservedObject var catalogVM: CatalogViewModel
    @Binding var continuousPlayback: Bool
    let onFullscreen: () -> Void

    var body: some View {
        ScrollView(showsIndicators: false) {
            VStack(spacing: 0) {
                PlayerSectionView(
                    controller: controller,
                    showsContinuousToggle: true,
                    continuousPlayback: $continuousPlayback,
                    onFullscreen: onFullscreen
                )
                CatalogView(vm: catalogVM)
                    .padding(.bottom, 20)
            }
        }
        .onChange(of: continuousPlayback) { enabled in
            controller.setContinuousPlayback(enabled)
            controller.showTransientMessage(
                enabled
                    ? "已开启连续播放，将按句子顺序连续播放"
                    : "已关闭连续播放，将循环播放当前句子"
            )
        }
    }
}
