import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_screen.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';

class OneGangInterface extends StatelessWidget {
  const OneGangInterface({super.key, this.gangSwitch});

  final DeviceModel? gangSwitch;
  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
      value: SystemUiOverlayStyle(
        statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
        statusBarIconBrightness: Brightness.light,
      ),
      child: Scaffold(
        backgroundColor: ColorsManager.backgroundColor,
        extendBodyBehindAppBar: true,
        extendBody: true,
        appBar: gangSwitch != null
            ? DeviceAppbar(
                deviceName: gangSwitch!.name!,
                deviceUuid: gangSwitch!.uuid!,
              )
            : AppBar(
                backgroundColor: Colors.transparent,
                centerTitle: true,
                title: BodyLarge(
                  text: gangSwitch?.name ?? 'Lights',
                  fontColor: ColorsManager.primaryColor,
                  fontWeight: FontsManager.bold,
                ),
              ),
        body: Container(
          width: MediaQuery.sizeOf(context).width,
          height: MediaQuery.sizeOf(context).height,
          decoration: const BoxDecoration(
            image: DecorationImage(
              image: AssetImage(
                Assets.assetsImagesBackground,
              ),
              fit: BoxFit.cover,
              opacity: 0.4,
            ),
          ),
          child: SafeArea(
            child: Padding(
              padding: EdgeInsets.only(
                left: Constants.defaultPadding,
                right: Constants.defaultPadding,
                bottom: Constants.bottomNavBarHeight,
              ),
              child: OneGangScreen(device: gangSwitch),
            ),
          ),
        ),
      ),
    );
  }
}
