import 'package:flutter/material.dart';
import 'package:flyinsono/lab/color/lab_colors.dart';
import 'package:flyinsono/lab/pages/lab_record_info/controller.dart';
import 'package:fis_theme/theme.dart';
import 'package:get/get.dart';

class RecordTabsBar extends GetView<LabRecordInfoController> {
  const RecordTabsBar({
    Key? key,
    this.tabHashCode,
  }) : super(key: key);
  final String? tabHashCode;
  @override
  String? get tag => tabHashCode;
  @override
  Widget build(BuildContext context) {
    return Container(
      color: LabColors.base800,
      child: Row(
        children: [
          Flexible(
            child: Container(
              constraints: BoxConstraints(
                  maxWidth: controller.state.isPerson ? 800 : 140),
              child: TabBar(
                  controller: TabController(
                    initialIndex: controller.initRecordInfoFieldIndex,
                    length: 5,
                    vsync: controller,
                  ),
                  labelStyle: TextStyle(
                    fontFamily: FTheme.ins.localeSetting.fontFamily,
                    fontSize: 18,
                  ),
                  labelColor: LabColors.base100,
                  unselectedLabelColor: LabColors.base400,
                  indicatorWeight: 4,
                  indicatorColor: LabColors.base200,
                  indicatorPadding: EdgeInsets.symmetric(horizontal: 10),
                  onTap: (value) {
                    print("tab index: $value");
                    controller.updateRecordInfoFields(value);
                  },
                  tabs: (controller.state.isPerson
                          ? LabRecordInfoController.tabLists
                          : ["Routine"])
                      .map(
                        (e) => Tab(text: controller.getValues(e)),
                      )
                      .toList()),
            ),
          ),
        ],
      ),
    );
  }
}
