/*
 * @Author: ChenYaJin
 * @Date: 2023-04-12 10:20:34
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-04-13 16:12:56
 * @Description: 点位/区域 tab切换
 */

import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import 'package:task_package/src/view_models/work_statistic_store.dart';

class TabbarComponent extends GetView<WorkStatisticStore> {
  @override
  Widget build(BuildContext context) {
    final WorkStatisticStore store = Get.find<WorkStatisticStore>();
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;

    return Wisdom.row(
      color: Colors.white,
      borderRadius: BorderRadius.circular(13.pt),
      border: Border.all(color: colorScheme.primary, width: 1.pt),
      margin: EdgeInsets.symmetric(horizontal: 70.pt, vertical: 5.pt),
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Obx(
          () => Wisdom(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(12.pt),
              bottomLeft: Radius.circular(12.pt),
            ),
            onTap: store.isPoint.value ? null : () => store.setIsPoint(true),
            alignment: Alignment.center,
            color: !store.isPoint.value ? null : colorScheme.primary,
            padding: EdgeInsets.symmetric(vertical: 6.pt),
            child: Text(
              '点位异常',
              style: TextStyle(
                fontSize: 15.pt,
                fontWeight: FontWeight.w300,
                color: store.isPoint.value ? Colors.white : colorScheme.primary,
              ),
            ),
          ),
        ).asExpanded(),
        Obx(
          () => Wisdom(
            borderRadius: BorderRadius.only(
              topRight: Radius.circular(12.pt),
              bottomRight: Radius.circular(12.pt),
            ),
            onTap: !store.isPoint.value ? null : () => store.setIsPoint(false),
            alignment: Alignment.center,
            color: store.isPoint.value ? null : colorScheme.primary,
            padding: EdgeInsets.symmetric(vertical: 6.pt),
            child: Text(
              '区域异常',
              style: TextStyle(
                fontSize: 15.pt,
                fontWeight: FontWeight.w300,
                color:
                    !store.isPoint.value ? Colors.white : colorScheme.primary,
              ),
            ),
          ),
        ).asExpanded(),
      ],
    );
  }
}
