import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/router/desktop/names.dart';
import 'package:flyinsono/architecture/states/states.dart';
import 'package:flyinsono/lab/color/lab_colors.dart';
import 'package:flyinsono/lab/components/pull_down_button/more_pull_down_button.dart';
import 'package:flyinsono/lab/components/pull_down_button/pull_down_button.dart';
import 'package:get/get.dart';

class UserLabel extends StatefulWidget {
  @override
  State<UserLabel> createState() => _UserLabelState();
}

class _UserLabelState extends State<UserLabel> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 150,
      height: 40,
      alignment: Alignment.center,
      child: PullDownButton(
        iconData: Icons.person_outline_sharp,
        child: Container(
          decoration: BoxDecoration(
            color: LabColors.tabBarButtonColor,
          ),
          width: 100,
          height: 40,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                Icons.person_outline_sharp,
                color: LabColors.text300,
                size: 20,
              ),
              SizedBox(width: 5),
              Expanded(
                child: Text(
                  Store.user.displayName,
                  style: TextStyle(color: LabColors.text300),
                  overflow: TextOverflow.ellipsis,
                ),
              ),
            ],
          ),
        ),
        onClick: () {},
        moreOperateButtons: [
          MorePullDownButton(
            icon: Icons.exit_to_app,
            name: '退出登录',
            onClick: () async {
              try {
                await Store.user.handelLogOut();
              } catch (e) {}
              Get.offNamed(RouteNames.Lab.Login);
            },
          ),
        ],
      ),
    );
  }
}
