/*
 * @Author: ChenYaJin
 * @Date: 2023-08-07 09:14:02
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-08-18 09:37:52
 * @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 TabbarDateComponent 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(
      margin: EdgeInsets.only(top: 10.pt, left: 15.pt, right: 15.pt),
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Wisdom(
          child: Wisdom.row(
            width: 100.pt,
            mainAxisAlignment: MainAxisAlignment.start,
            color: Colors.white,
            borderRadius: BorderRadius.circular(13.pt),
            border: Border.all(color: colorScheme.primary, width: 1.pt),
            children: [
              Obx(
                () => Wisdom(
                  onTap: store.isDateType.value
                      ? null
                      : () => store.setIsDateType(true),
                  alignment: Alignment.center,
                  color: !store.isDateType.value ? null : colorScheme.primary,
                  padding: EdgeInsets.symmetric(vertical: 2.pt),
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(12.pt),
                    bottomLeft: Radius.circular(12.pt),
                  ),
                  child: Text(
                    '日历',
                    style: TextStyle(
                      fontSize: 15.pt,
                      fontWeight: FontWeight.w300,
                      color: store.isDateType.value
                          ? Colors.white
                          : colorScheme.primary,
                    ),
                  ),
                ).asExpanded(),
              ),
              Obx(
                () => Wisdom(
                  onTap: !store.isDateType.value
                      ? null
                      : () => store.setIsDateType(false),
                  alignment: Alignment.center,
                  color: store.isDateType.value ? null : colorScheme.primary,
                  padding: EdgeInsets.symmetric(vertical: 2.pt),
                  borderRadius: BorderRadius.only(
                    topRight: Radius.circular(12.pt),
                    bottomRight: Radius.circular(12.pt),
                  ),
                  child: Text(
                    '排名',
                    style: TextStyle(
                      fontSize: 15.pt,
                      fontWeight: FontWeight.w300,
                      color: !store.isDateType.value
                          ? Colors.white
                          : colorScheme.primary,
                    ),
                  ),
                ).asExpanded(),
              ),
            ],
          ),
        ),
        Wisdom(
          child: Obx(
            () => WisText.c999(
              '统计时间：${store.isDateType == true ? store.focusedDay : store.getShowDateRange()}',
              size: 13.pt,
              weight: FontWeight.w300,
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ),
      ],
    );
  }
}
