mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
71 lines
2.6 KiB
Dart
71 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view_list.dart';
|
|
|
|
import '../../../../../generated/assets.dart';
|
|
import '../../../../../utils/resource_manager/color_manager.dart';
|
|
import '../../../../app_layout/view/widgets/default_app_bar.dart';
|
|
import '../../../../app_layout/view/widgets/default_nav_bar.dart';
|
|
import '../../../bloc/devices_cubit.dart';
|
|
import '../../../bloc/lights/lights_cubit.dart';
|
|
import '../../../model/light_model.dart';
|
|
import 'light_interface.dart';
|
|
|
|
class LightsView extends StatelessWidget {
|
|
const LightsView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => LightsCubit(),
|
|
child: BlocBuilder<LightsCubit, LightsState>(
|
|
builder: (context, state) {
|
|
LightModel? selectedLight;
|
|
if (DevicesCubit.get(context).getSelectedDevice() is LightModel) {
|
|
selectedLight =
|
|
DevicesCubit.get(context).getSelectedDevice() as LightModel;
|
|
}
|
|
List<LightModel> lights = [];
|
|
for (var device in DevicesCubit.categories[1].devices) {
|
|
if (device is LightModel) {
|
|
lights.add(device);
|
|
}
|
|
}
|
|
return AnnotatedRegion(
|
|
value: SystemUiOverlayStyle(
|
|
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
|
statusBarIconBrightness: Brightness.light,
|
|
),
|
|
child: SafeArea(
|
|
child: Scaffold(
|
|
backgroundColor: ColorsManager.backgroundColor,
|
|
extendBodyBehindAppBar: true,
|
|
extendBody: true,
|
|
appBar: const DefaultAppBar(),
|
|
body: Container(
|
|
width: MediaQuery.sizeOf(context).width,
|
|
height: MediaQuery.sizeOf(context).height,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(
|
|
Assets.imagesBackground,
|
|
),
|
|
fit: BoxFit.cover,
|
|
opacity: 0.4,
|
|
),
|
|
),
|
|
child: selectedLight != null
|
|
? LightInterface(light: selectedLight)
|
|
: LightsViewList(lights: lights),
|
|
),
|
|
bottomNavigationBar: const DefaultNavBar(),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|