import 'package:fis_common/env/env.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';
import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/values/font_sizes.dart';

class SpeakerVolumeSetting extends GetView<HardwareDetectionController> {
  final bool fromAssistant;
  SpeakerVolumeSetting({Key? key, this.fromAssistant = false})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    if (!FPlatform.isWindows) {
      return Container();
    }

    return Obx(() {
      if (controller.state.speakerList.isEmpty) {
        return Container();
      }
      return controller.state.isDisplaySpeakerWave
          ? _buildSpeakerVolumeSetting(fromAssistant)
          : Container();
    });
  }

  Widget _buildSpeakerVolumeSetting(bool isFromAssistant) {
    return Container(
      width: 300.0,
      height: 40.0,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            i18nBook.setting.speakerVolume.t,
            style: TextStyle(
              fontSize: isFromAssistant ? FFontSizes.H4 : FFontSizes.H6,
              color: Colors.black87,
            ),
          ),
          Expanded(
            child: Slider(
              value: controller.state.speakerVolume,
              onChanged: controller.setSpeakerVolume,
              min: 0,
              max: 100,
              divisions: 100,
              label: '${controller.state.speakerVolume.toInt()}%',
            ),
          ),
        ],
      ),
    );
  }
}
