mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
100 lines
3.9 KiB
Dart
100 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
|
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
import 'package:syncrow_app/utils/context_extension.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
|
|
|
import '../../../../shared_widgets/default_container.dart';
|
|
|
|
class LightInterface extends StatelessWidget {
|
|
const LightInterface({super.key, required this.light});
|
|
|
|
final LightModel light;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<LightsCubit, LightsState>(
|
|
builder: (context, state) {
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const SizedBox(height: 70),
|
|
Container(
|
|
constraints: const BoxConstraints(
|
|
maxHeight: 65,
|
|
),
|
|
margin:
|
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
child: DefaultContainer(
|
|
child: SizedBox.expand(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
BodyLarge(
|
|
text: light.status ?? false
|
|
? StringsManager.on
|
|
: StringsManager.off,
|
|
style: context.bodyLarge
|
|
.copyWith(color: Colors.grey, fontSize: 24),
|
|
),
|
|
Container(
|
|
width: 35,
|
|
decoration: ShapeDecoration(
|
|
color: light.status ?? false
|
|
? ColorsManager.primaryWithOpacity
|
|
: Colors.grey,
|
|
shape: const CircleBorder(),
|
|
),
|
|
child: Center(
|
|
child: IconButton(
|
|
style: ButtonStyle(
|
|
padding: MaterialStateProperty.all(
|
|
const EdgeInsets.all(0),
|
|
),
|
|
iconSize: MaterialStateProperty.all(25),
|
|
),
|
|
onPressed: () {
|
|
LightsCubit.get(context).toggleLight(light);
|
|
},
|
|
icon: const Icon(
|
|
Icons.power_settings_new,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
),
|
|
const DefaultContainer(
|
|
boxConstraints: BoxConstraints(
|
|
maxHeight: 310,
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
child: SizedBox.expand(
|
|
child: Center(child: Text("Light Controls")),
|
|
),
|
|
),
|
|
const DefaultContainer(
|
|
boxConstraints: BoxConstraints(
|
|
maxHeight: 65,
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
child: Center(child: Text("Timer")),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|