import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_contols.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_switch.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_timer.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 LightInterface extends StatelessWidget {
  const LightInterface({super.key, required this.light});

  final DeviceModel light;

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<DevicesCubit, DevicesState>(
      builder: (context, state) {
        return AnnotatedRegion(
          value: SystemUiOverlayStyle(
            statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
            statusBarIconBrightness: Brightness.light,
          ),
          child: Scaffold(
            backgroundColor: ColorsManager.backgroundColor,
            extendBodyBehindAppBar: true,
            extendBody: true,
            appBar: AppBar(
              backgroundColor: Colors.transparent,
              centerTitle: true,
              title: BodyLarge(
                text: light.name ?? "",
                fontColor: ColorsManager.primaryColor,
                fontWeight: FontsManager.bold,
              ),
            ),
            body: Padding(
              padding: const EdgeInsets.only(top: 70, right: 20, left: 20),
              child: SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    LightInterfaceSwitch(light: light),
                    LightInterfaceContols(light: light),
                    const LightInterfaceTimer(),
                  ],
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
