mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 23:07:55 +00:00
light interface
This commit is contained in:
@@ -2,15 +2,9 @@ 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/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_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/united_text.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});
|
||||
@@ -28,66 +22,7 @@ class LightInterface extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
LightInterfaceSwitch(light: light),
|
||||
DefaultContainer(
|
||||
boxConstraints: const BoxConstraints(
|
||||
maxHeight: 310,
|
||||
),
|
||||
padding: const EdgeInsets.all(25),
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: StringsManager.dimmerAndColor,
|
||||
style: context.bodyMedium.copyWith(color: Colors.grey),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: UnitedText(
|
||||
value: light.brightness.toString(),
|
||||
unit: "%",
|
||||
valueStyle: context.bodyMedium.copyWith(
|
||||
color: Colors.grey,
|
||||
fontSize: 26,
|
||||
),
|
||||
unitStyle: context.bodyMedium.copyWith(
|
||||
color: Colors.grey,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
thumbColor: ColorsManager.primaryColor,
|
||||
rangeThumbShape:
|
||||
const RoundRangeSliderThumbShape(
|
||||
enabledThumbRadius: 9,
|
||||
),
|
||||
thumbShape: const RoundSliderThumbShape(
|
||||
enabledThumbRadius: 9,
|
||||
),
|
||||
activeTrackColor: Colors.grey.withOpacity(.8),
|
||||
inactiveTrackColor: Colors.grey.withOpacity(.8),
|
||||
trackHeight: 5,
|
||||
),
|
||||
child: Slider(
|
||||
value: light.brightness,
|
||||
onChanged: (value) => LightsCubit.get(context)
|
||||
.setBrightness(light, value),
|
||||
min: 0,
|
||||
max: 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
LightInterfaceContols(light: light),
|
||||
const LightInterfaceTimer(),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_modes.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_recent_color.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_slider.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
|
||||
class LightInterfaceContols extends StatelessWidget {
|
||||
const LightInterfaceContols({
|
||||
super.key,
|
||||
required this.light,
|
||||
});
|
||||
|
||||
final LightModel light;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
boxConstraints: const BoxConstraints(maxHeight: 320),
|
||||
padding: const EdgeInsets.all(25),
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
LightInterfaceSlider(light: light),
|
||||
LightInterfaceRecentColor(light: light),
|
||||
LightInterfaceModes(light: light)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.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_medium.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';
|
||||
|
||||
class LightInterfaceModes extends StatelessWidget {
|
||||
const LightInterfaceModes({
|
||||
super.key,
|
||||
required this.light,
|
||||
});
|
||||
|
||||
final LightModel light;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: StringsManager.lightingModes,
|
||||
style: context.bodyMedium.copyWith(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 25,
|
||||
children: List.generate(
|
||||
LightsCubit.get(context).lightModes.length,
|
||||
(index) => InkWell(
|
||||
onTap: () => LightsCubit.get(context).setLightingMode(
|
||||
light, LightsCubit.get(context).lightModes[index]!),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: ShapeDecoration(
|
||||
shape: const CircleBorder(),
|
||||
color: switch (index) {
|
||||
0 => ColorsManager.dozeColor,
|
||||
1 => ColorsManager.relaxColor,
|
||||
2 => ColorsManager.readingColor,
|
||||
3 => ColorsManager.energizingColor,
|
||||
_ => ColorsManager.primaryColor,
|
||||
},
|
||||
),
|
||||
),
|
||||
BodyMedium(
|
||||
text: switch (index) {
|
||||
0 => StringsManager.doze,
|
||||
1 => StringsManager.relax,
|
||||
2 => StringsManager.reading,
|
||||
3 => StringsManager.energizing,
|
||||
_ => "",
|
||||
},
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: Colors.grey,
|
||||
fontSize: 10,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.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/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
import '../../../../../generated/assets.dart';
|
||||
import '../../../../../utils/resource_manager/strings_manager.dart';
|
||||
import '../../../../shared_widgets/text_widgets/body_medium.dart';
|
||||
|
||||
class LightInterfaceRecentColor extends StatelessWidget {
|
||||
const LightInterfaceRecentColor({
|
||||
super.key,
|
||||
required this.light,
|
||||
});
|
||||
|
||||
final LightModel light;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: StringsManager.recentlyUsed,
|
||||
style: context.bodyMedium.copyWith(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FittedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
...List.generate(
|
||||
light.recentColors.length > 4 ? 4 : light.recentColors.length,
|
||||
(index) => InkWell(
|
||||
onTap: () {
|
||||
LightsCubit.get(context)
|
||||
.setColor(light, light.recentColors[index]);
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: ShapeDecoration(
|
||||
shape: const CircleBorder(),
|
||||
color: Color(light.recentColors[index]),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
width: 1,
|
||||
height: 30,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
SvgPicture.asset(
|
||||
Assets.iconsKalvin,
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
SvgPicture.asset(
|
||||
Assets.iconsColorWheel,
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.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_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/united_text.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';
|
||||
|
||||
class LightInterfaceSlider extends StatelessWidget {
|
||||
const LightInterfaceSlider({
|
||||
super.key,
|
||||
required this.light,
|
||||
});
|
||||
|
||||
final LightModel light;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: StringsManager.dimmerAndColor,
|
||||
style: context.bodyMedium.copyWith(color: Colors.grey),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: UnitedText(
|
||||
value: light.brightness.toString(),
|
||||
unit: "%",
|
||||
valueStyle: context.bodyMedium.copyWith(
|
||||
color: Colors.grey,
|
||||
fontSize: 26,
|
||||
),
|
||||
unitStyle: context.bodyMedium.copyWith(
|
||||
color: Colors.grey,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
thumbColor: ColorsManager.primaryColor,
|
||||
rangeThumbShape: const RoundRangeSliderThumbShape(
|
||||
enabledThumbRadius: 9,
|
||||
),
|
||||
thumbShape: const RoundSliderThumbShape(
|
||||
enabledThumbRadius: 9,
|
||||
),
|
||||
activeTrackColor: ColorsManager.greyColor,
|
||||
inactiveTrackColor: ColorsManager.greyColor,
|
||||
trackHeight: 5,
|
||||
),
|
||||
child: Slider(
|
||||
value: light.brightness,
|
||||
onChanged: (value) =>
|
||||
LightsCubit.get(context).setBrightness(light, value),
|
||||
min: 0,
|
||||
max: 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user