import 'dart:io';
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';

class DeviceAppbar extends StatelessWidget implements PreferredSizeWidget {
  final String deviceName;
  final String deviceUuid;
  final bool? value;

  final double appBarHeight = 56.0;
  final void Function()? onPressed;
  const DeviceAppbar(
      {super.key,
      required this.deviceName,
      this.value,
      required this.deviceUuid,
      this.onPressed});

  @override
  Widget build(BuildContext context) {
    return AppBar(
      leading: IconButton(
          onPressed: () {
            Navigator.of(context).pop(value ?? true);
          },
          icon: Icon(
            Platform.isIOS ? Icons.arrow_back_ios : Icons.arrow_back,
          )),
      backgroundColor: Colors.transparent,
      centerTitle: true,
      title: BodyLarge(
        text: deviceName,
        fontColor: ColorsManager.primaryColor,
        fontWeight: FontsManager.bold,
      ),
      actions: [
        // IconButton(
        //     onPressed: () {
        //       showPopupMenu(context: context, items: [
        //         PopupMenuItem(
        //           onTap: () async {
        //             HomeCubit.getInstance().updateDevice(deviceUuid);
        //           },
        //           value: 'Update',
        //           child: const Text('Update'),
        //         )
        //       ]);
        //     },
        //     icon: Icon(Icons.edit))
      ],
    );
  }

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