import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/base_define/page.dart';
import 'package:fis_ui/index.dart';
import 'package:fis_ui/usual/tab_button.dart';
import 'package:fis_ui/usual/tab_button_group.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/views/desktop/laboratory/controller.dart';
import 'package:flyinsono/views/desktop/laboratory/widgets/image_analysis.dart';
import 'package:flyinsono/views/desktop/laboratory/widgets/report_analysis.dart';

class LaboratoryMainContent extends FisView<LaboratoryController>
    implements FPage {
  const LaboratoryMainContent({Key? key}) : super(key: key);

  @override
  String get pageName => 'LaboratoryMainContent';
  @override
  FWidget build(BuildContext context) {
    FWidget child = FObx(
      () {
        FWidget child = FContainer();
        final selectedIndex = controller.state.selectIndex;
        if (selectedIndex == 0) {
          child = ImageAnalysis();
        } else if (selectedIndex == 1) {
          child = ReportAnalysis();
        }
        return child;
      },
    );

    return FColumn(
      children: [
        const FSizedBox(
          height: 10,
        ),
        FContainer(
          margin: const EdgeInsets.only(left: 15, right: 15),
          child: FObx(
            () {
              return FTabButtonGroup(
                [
                  FTabButton(
                    tabTitle: i18nBook.laboratory.imageAnalysis.t,
                    index: 0,
                    activeIndex: controller.state.selectIndex,
                    onCallbackTap: () {
                      controller.state.selectIndex = 0;
                    },
                    width: 150,
                    businessParent: this,
                  ),
                  FTabButton(
                    tabTitle:
                        i18nBook.laboratory.comprehensiveAnalysisResults.t,
                    index: 1,
                    activeIndex: controller.state.selectIndex,
                    onCallbackTap: () {
                      controller.state.selectIndex = 1;
                    },
                    width: 150,
                    businessParent: this,
                  ),
                ],
              );
            },
          ),
        ),
        FExpanded(
          child: FContainer(
            color: Colors.white,
            margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15),
            child: FContainer(
              child: FScaffold(
                body: FDefaultTabController(
                  length: 4,
                  child: child,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
