/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2021-03-04 16:06:21
 * @LastEditTime : 2023-05-19 11:00:53
 * @FilePath     : /wisdom-huiguanjia-app/oa_package/lib/src/pages/management/components/tabbar.dart
 * @Description  : Do not edit
 */
part of '../view.dart';

class _TabbarComponent extends StatelessWidget {
  const _TabbarComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<ManagementStore>(context, listen: false);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final names = store.names;
    return Wisdom.row(
      height: 54.pt,
      color: Colors.white,
      children: List.generate(
        names.length,
        (index) => Wisdom.column(
          onTap: () => store.setindexStack(names[index]['type']!),
          alignment: Alignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              height: 50.pt,
              alignment: Alignment.center,
              child: Observer(builder: (_) {
                return Stack(
                  children: [
                    Wisdom(
                      margin: EdgeInsets.symmetric(
                          horizontal:
                              names[index]['type'] == 'waiting' ? 10.pt : 0),
                      child: Text(
                        names[index]['name']!,
                        style: TextStyle(
                          color: store.taskTabType == names[index]['type']
                              ? Colors.black
                              : colorScheme.grey,
                          fontSize: 16.pt,
                          fontWeight: store.taskTabType == names[index]['type']
                              ? FontWeight.bold
                              : null,
                        ),
                      ),
                    ),
                    if (store.waitingList.length > 0 &&
                        names[index]['type'] == 'waiting')
                      Positioned(
                        top: 0,
                        right: 0,
                        child: Container(
                          decoration: BoxDecoration(
                              color: Colors.redAccent,
                              borderRadius: BorderRadius.circular(8)),
                          width: 15,
                          height: 15,
                          child: Center(
                            child: Text(
                              store.waitingList.length < 10
                                  ? '${store.waitingList.length}'
                                  : '...',
                              style: TextStyle(
                                fontSize: 11,
                                color: Colors.white,
                                decoration: TextDecoration.none,
                              ),
                            ),
                          ),
                        ),
                      )
                  ],
                );
              }),
            ),
            Observer(builder: (_) {
              return Wisdom(
                color: store.taskTabType == names[index]['type']
                    ? colorScheme.primary
                    : null,
                height: 4.pt,
                width: 25.pt,
                borderRadius: BorderRadius.circular(2.pt),
              );
            }),
          ],
        ).asExpanded(),
      ),
    );
  }
}
