import 'package:flutter/material.dart';
import 'pump_card.dart';
import 'sensor_limit_card.dart';

class DeviceControlSection extends StatelessWidget {
  final bool isPumpOn;
  final bool isOnline;
  final double suhuMinLimit;
  final double suhuMaxLimit;
  final double kelembapanLimit;
  final int? activePumpDuration;
  final DateTime? pumpTurnedOnAt;
  final VoidCallback onPumpToggle;
  final Future<void> Function(double suhuMin, double suhuMax, double kelembapan) onSaveThreshold;

  const DeviceControlSection({
    super.key,
    required this.isPumpOn,
    required this.isOnline,
    required this.suhuMinLimit,
    required this.suhuMaxLimit,
    required this.kelembapanLimit,
    this.activePumpDuration,
    this.pumpTurnedOnAt,
    required this.onPumpToggle,
    required this.onSaveThreshold,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        SensorLimitCard(
          suhuMinLimit: suhuMinLimit,
          suhuMaxLimit: suhuMaxLimit,
          kelembapanLimit: kelembapanLimit,
          onSave: onSaveThreshold,
        ),
        const SizedBox(height: 12),
        PumpCard(
          isPumpOn: isPumpOn,
          isOnline: isOnline,
          activePumpDuration: activePumpDuration,
          pumpTurnedOnAt: pumpTurnedOnAt,
          onToggle: onPumpToggle,
        ),
      ],
    );
  }
}
