import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';
import 'widgets.dart';
import 'package:fis_i18n/i18n.dart';

class MicrophoneUI extends GetView<HardwareDetectionController> {
  final double fontSize;
  MicrophoneUI({this.fontSize = 16.0});
  @override
  Widget build(BuildContext context) {
    return Obx(() {
      if (controller.state.microphoneList.isEmpty) {
        return Container();
      }
      return controller.state.isDisplayMicrophoneWave
          ? MicrophoneWave(
              isRecording: controller.state.detectingMicrophone,
              recorder: controller.flutterRecorder,
              onAutoDetectPass: () => controller.setMicrophoneAvailable(true),
              width: 300.0,
              height: 60.0,
              fontSize: fontSize,
            )
          : Container(
              width: 300,
              height: 60,
              child: Align(
                alignment: Alignment.centerLeft,
                child: Text(
                  i18nBook.setting.micInput.t,
                  style: TextStyle(
                    height: 1,
                    color: Colors.black87,
                  ),
                ),
              ),
            );
    });
  }
}
