import 'package:fis_i18n/i18n.dart';
import 'package:flutter/material.dart';
import 'package:fis_ui/index.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
import 'widgets/speaker_volume_setting.dart';
import 'widgets/widgets.dart';
import 'package:fis_theme/theme.dart';
import 'package:fis_ui/values/font_sizes.dart';
import 'index.dart';
import 'package:flyinsono/views/desktop/hardware_detection/widgets/sonopost_detection.dart';

class HardwareDetectionPage extends FisView<HardwareDetectionController> {
  HardwareDetectionPage({Key? key}) : super(key: key);
  final bigTitleStyle = TextStyle(
    fontSize: FFontSizes.H4,
    fontWeight: FontWeight.bold,
  );

  // 主视图
  FWidget _buildView() {
    return QuickFWidget(
      Center(
        child: Container(
          padding: EdgeInsets.only(top: 30, left: 30),
          child: ListView(
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(i18nBook.setting.video.t, style: bigTitleStyle),
                  SizedBox(height: 10),
                  CameraDetection(),
                  SizedBox(height: 20),
                  CameraUI(),
                  SizedBox(height: 20),
                  _decorateLine(),
                  SizedBox(height: 20),
                  Text(i18nBook.setting.audio.t, style: bigTitleStyle),
                  SizedBox(height: 10),
                  SpeakerDetection(),
                  SizedBox(height: 10),
                  SpeakerVolumeSetting(),
                  SizedBox(height: 10),
                  SpeakerUI(),
                  SizedBox(height: 40),
                  MicrophoneDetection(),
                  SizedBox(height: 20),
                  MicrophoneUI(),
                  SizedBox(height: 20),
                  if (CartSystemPlatform.isCartSystemVersion)
                    Column(
                      children: [
                        Obx(() {
                          return (controller.state.searchingCamera ||
                                      controller.state.detectingCamera) &&
                                  controller.state.isOldVBox
                              ? Container()
                              : SonopostDetaction();
                        }),
                        SizedBox(height: 20),
                      ],
                    ),
                  CartSystemPlatform.isCartSystemVersion
                      ? Container()
                      : ElevatedButton(
                          onPressed: controller.startDetectingAll,
                          child: Text(i18nBook.setting.detectAllDevices.t),
                        ),
                  SizedBox(height: 40),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _decorateLine() {
    return FContainer(
      height: 1,
      width: double.infinity,
      margin: EdgeInsets.only(top: 5, bottom: 5),
      decoration: BoxDecoration(
          border: Border(
        bottom: BorderSide(color: FTheme.ins.colorScheme.line),
      )),
    );
  }

  @override
  FWidget build(BuildContext context) {
    return _buildView();
  }
}
