/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2021-05-15 16:55:58
 * @LastEditTime : 2022-01-19 14:45:34
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/schedule/components/tabmonth.dart
 * @Description  : 我的日程-月份tab
 */
part of '../index.dart';

class _BuildTabMonth extends StatelessWidget {
  const _BuildTabMonth({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Wisdom.row(
      height: 54.pt,
      children: [
        Expanded(
          child: ListView(
            scrollDirection: Axis.horizontal,
            children: [
              _BuildMonthItem(title: '一月', index: 0),
              _BuildMonthItem(title: '二月', index: 1),
              _BuildMonthItem(title: '三月', index: 2),
              _BuildMonthItem(title: '四月', index: 3),
              _BuildMonthItem(title: '五月', index: 4),
              _BuildMonthItem(title: '六月', index: 5),
              _BuildMonthItem(title: '七月', index: 6),
              _BuildMonthItem(title: '八月', index: 7),
              _BuildMonthItem(title: '九月', index: 8),
              _BuildMonthItem(title: '十月', index: 9),
              _BuildMonthItem(title: '十一月', index: 10),
              _BuildMonthItem(title: '十二月', index: 11),
            ],
          ),
        ),
      ],
    );
  }
}

/// 月份顶部项
class _BuildMonthItem extends StatelessWidget {
  const _BuildMonthItem({Key? key, this.title, this.index}) : super(key: key);
  final title;
  final index;
  @override
  Widget build(BuildContext context) {
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final store = Provider.of<ScheduleStore>(context, listen: false);

    return Wisdom(
      onTap: () => store.onSetMonthIndex(index),
      border: Border(bottom: Divider.createBorderSide(context)),
      color: Colors.white,
      width: 65.pt,
      height: 54.pt,
      child: Wisdom.column(
        height: 54.pt,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Observer(builder: (_) {
            return WisText(
              title,
              color: index == store.monthIndex
                  ? colorScheme.primary
                  : colorScheme.minor,
            );
          }),
          Observer(builder: (_) {
            return Wisdom(
              margin: EdgeInsets.only(
                top: 5.pt,
              ),
              child: Icon(
                store.isCurrentEmpty(index + 1)!
                    ? Icons.radio_button_unchecked
                    : Icons.circle,
                color: index == store.monthIndex
                    ? colorScheme.primary
                    : colorScheme.minor,
                size: 4.pt,
              ),
            );
          }),
        ],
      ),
    );
  }
}
