import 'package:track_common/widget/prelude.dart';

import 'home_controller.dart';

class HomeAppBar extends GetView<HomeController>
    implements PreferredSizeWidget {
  const HomeAppBar({super.key, required this.tab});

  final Widget tab;

  @override
  Widget build(BuildContext context) {
    final statusBarHeight = MediaQuery.of(context).viewPadding.top;

    return SizedBox.expand(
        child: Container(
      padding: EdgeInsets.only(top: statusBarHeight),
      decoration: const BoxDecoration(
          image: DecorationImage(
              image: AssetImage(Assets.imagesBkCommonPage, package: package),
              fit: BoxFit.fitWidth),
          boxShadow: [
            BoxShadow(color: Color(0x33000000), spreadRadius: 4, blurRadius: 4)
          ]),
      child: Row(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SizedBox(width: 660, height: double.infinity, child: tab),
          Expanded(
              child: Obx(() => controller.selectMapName.value.isEmpty
                  ? const SizedBox()
                  : Row(children: [
                      Container(
                        width: 7.11,
                        height: 24.18,
                        margin: const EdgeInsets.only(right: 12),
                        decoration: BoxDecoration(
                            color: Colors.blue,
                            borderRadius: BorderRadius.circular(5)),
                      ),
                      Text(controller.selectMapName.value,
                          style: const TextStyle(
                              color: Colors.white, fontSize: 15.64))
                    ]))),
          TextButton(
              onPressed: () {},
              child: const Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Icon(Icons.radio, color: Colors.white),
                  Text(' 广播',
                      style: TextStyle(color: Colors.white, fontSize: 15.64))
                ],
              ))
        ],
      ),
    ));
  }

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
