Fixed design issues

This commit is contained in:
Abdullah Alassaf
2024-08-01 13:27:50 +03:00
parent 8d6da30d09
commit 2a2e609601
5 changed files with 170 additions and 222 deletions

View File

@ -5,109 +5,84 @@ import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart';
import 'package:syncrow_app/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart';
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.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/font_manager.dart';
class SceneAutoSettings extends StatelessWidget {
const SceneAutoSettings({super.key});
@override
Widget build(BuildContext context) {
final sceneSettings =
ModalRoute.of(context)!.settings.arguments as Map<String, dynamic>? ??
{};
final sceneSettings = ModalRoute.of(context)!.settings.arguments as Map<String, dynamic>? ?? {};
final sceneId = sceneSettings['sceneId'] as String? ?? '';
final isAutomation = context.read<CreateSceneBloc>().sceneType ==
CreateSceneEnum.deviceStatusChanges;
final isAutomation =
context.read<CreateSceneBloc>().sceneType == CreateSceneEnum.deviceStatusChanges;
final sceneName = sceneSettings['sceneName'] as String? ?? '';
return Scaffold(
backgroundColor: ColorsManager.backgroundColor,
appBar: AppBar(
centerTitle: true,
backgroundColor: ColorsManager.backgroundColor,
title: const BodyLarge(
text: "Settings",
fontColor: ColorsManager.secondaryColor,
fontWeight: FontsManager.bold,
),
),
body: Stack(
children: [
Container(
width: double.infinity,
height: context.height,
decoration: const BoxDecoration(
color: ColorsManager.backgroundColor,
image: DecorationImage(
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(16)),
),
constraints: const BoxConstraints(
maxWidth: 600,
maxHeight: 300,
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
height: 8,
),
Visibility(
visible: isAutomation == true,
child: SceneListTile(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
titleString: "Effective Period",
trailingWidget:
const Icon(Icons.arrow_forward_ios_rounded),
onPressed: () {
context.customBottomSheet(
child: const EffectPeriodBottomSheetContent(),
);
},
return DefaultScaffold(
title: 'Settings',
padding: EdgeInsets.zero,
leading: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(
Icons.arrow_back_ios,
)),
child: SizedBox(
height: MediaQuery.sizeOf(context).height,
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: DefaultContainer(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
height: 8,
),
),
Visibility(
visible: sceneName.isNotEmpty,
child: SizedBox(
width: context.width * 0.9,
child: const Divider(
color: ColorsManager.greyColor,
Visibility(
visible: isAutomation,
child: SceneListTile(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
titleString: "Effective Period",
trailingWidget: const Icon(Icons.arrow_forward_ios_rounded),
onPressed: () {
context.customBottomSheet(
child: const EffectPeriodBottomSheetContent(),
);
},
),
),
),
Visibility(
visible: sceneName.isNotEmpty,
child: DeleteBottomSheetContent(
isAutomation: isAutomation,
sceneId: sceneId,
Visibility(
visible: sceneName.isNotEmpty && isAutomation,
child: SizedBox(
width: context.width * 0.9,
child: const Divider(
color: ColorsManager.greyColor,
),
),
),
),
const SizedBox(
height: 16,
),
],
Visibility(
visible: sceneName.isNotEmpty,
child: DeleteBottomSheetContent(
isAutomation: isAutomation,
sceneId: sceneId,
),
),
const SizedBox(
height: 16,
),
],
),
),
),
),
],
],
),
),
);
}

View File

@ -29,55 +29,58 @@ class SmartAutomationSelectView extends StatelessWidget {
icon: const Icon(
Icons.arrow_back_ios,
)),
height: sceneType.name == CreateSceneEnum.deviceStatusChanges.name
? 260
: 200,
child: DefaultContainer(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Visibility(
visible:
sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
child: SceneListTile(
assetPath: Assets.handClickIcon,
titleString: "Tap To Run",
subtitleString: '',
trailingWidget: const Icon(
Icons.arrow_forward_ios_rounded,
color: ColorsManager.greyColor,
// height: sceneType.name == CreateSceneEnum.deviceStatusChanges.name
// ? 260
// : 200,
height: MediaQuery.sizeOf(context).height,
child: Column(
children: [
DefaultContainer(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Visibility(
visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
child: SceneListTile(
assetPath: Assets.handClickIcon,
titleString: "Tap To Run",
subtitleString: '',
trailingWidget: const Icon(
Icons.arrow_forward_ios_rounded,
color: ColorsManager.greyColor,
),
onPressed: () {
context.customBottomSheet(
child: const SmartEnableTabRun(),
);
},
),
),
onPressed: () {
context.customBottomSheet(
child: const SmartEnableTabRun(),
);
},
),
Visibility(
visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
child: const Divider(
color: ColorsManager.dividerColor,
),
),
SceneListTile(
assetPath: Assets.refreshIcon,
titleString: "Automation",
subtitleString: '',
trailingWidget: const Icon(
Icons.arrow_forward_ios_rounded,
color: ColorsManager.greyColor,
),
onPressed: () {
context.customBottomSheet(
child: const SmartEnableAutomation(),
);
},
),
],
),
Visibility(
visible:
sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
child: const Divider(
color: ColorsManager.dividerColor,
),
),
SceneListTile(
assetPath: Assets.refreshIcon,
titleString: "Automation",
subtitleString: '',
trailingWidget: const Icon(
Icons.arrow_forward_ios_rounded,
color: ColorsManager.greyColor,
),
onPressed: () {
context.customBottomSheet(
child: const SmartEnableAutomation(),
);
},
),
],
),
),
],
),
);
}

View File

@ -1,14 +1,11 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/scene/helper/effect_period_helper.dart';
import 'package:syncrow_app/features/scene/widgets/effective_period_setting/period_options.dart';
import 'package:syncrow_app/features/scene/widgets/effective_period_setting/repeat_days.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.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/font_manager.dart';
import '../../helper/effect_period_helper.dart';
class EffectPeriodBottomSheetContent extends StatelessWidget {
const EffectPeriodBottomSheetContent({super.key});
@ -22,17 +19,18 @@ class EffectPeriodBottomSheetContent extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Expanded(
// child: TextButton(
// onPressed: () => Navigator.pop(context),
// child: BodySmall(
// text: 'Save',
// style:
// context.bodySmall.copyWith(color: ColorsManager.primaryColorWithOpacity),
// )),
// ),
const Spacer(),
Expanded(
child: TextButton(
onPressed: () => Navigator.pop(context),
child: BodySmall(
text: 'Save',
style: context.bodySmall.copyWith(
color: ColorsManager.primaryColorWithOpacity),
)),
),
Expanded(
flex: 2,
// flex: 2,
child: BodyMedium(
text: 'Effective Period',
fontColor: ColorsManager.primaryColorWithOpacity,

View File

@ -7,7 +7,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/features/scene/model/smart_scene_enable.dart';
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@ -21,12 +20,10 @@ class SmartSceneSelectAutomationList extends StatefulWidget {
final List<ScenesModel> automationList;
@override
State<SmartSceneSelectAutomationList> createState() =>
_SmartSceneSelectAutomationListState();
State<SmartSceneSelectAutomationList> createState() => _SmartSceneSelectAutomationListState();
}
class _SmartSceneSelectAutomationListState
extends State<SmartSceneSelectAutomationList> {
class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomationList> {
final List<Color> colorList = _generateDarkColors(100);
static List<Color> _generateDarkColors(int count) {
@ -34,8 +31,7 @@ class _SmartSceneSelectAutomationListState
final colors = <Color>[];
while (colors.length < count) {
final color =
Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
final color = Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
if (_isDark(color)) {
colors.add(color);
}
@ -44,8 +40,7 @@ class _SmartSceneSelectAutomationListState
}
static bool _isDark(Color color) {
final brightness =
((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000;
final brightness = ((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000;
return brightness < 128;
}
@ -57,15 +52,16 @@ class _SmartSceneSelectAutomationListState
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextButton(
onPressed: () => Navigator.pop(context),
child: BodySmall(
text: 'Save',
style: context.bodySmall
.copyWith(color: ColorsManager.primaryColorWithOpacity),
)),
),
// Expanded(
// child: TextButton(
// onPressed: () => Navigator.pop(context),
// child: BodySmall(
// text: 'Save',
// style: context.bodySmall
// .copyWith(color: ColorsManager.primaryColorWithOpacity),
// )),
// ),
const Spacer(),
Expanded(
flex: 2,
child: Padding(
@ -74,8 +70,7 @@ class _SmartSceneSelectAutomationListState
text: 'Automation',
textAlign: TextAlign.center,
style: context.bodyMedium.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold),
color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold),
),
),
),
@ -97,12 +92,9 @@ class _SmartSceneSelectAutomationListState
itemCount: widget.automationList.length,
itemBuilder: (context, index) {
final automation = widget.automationList[index];
final isSelected =
smartSceneEnable?.entityId == automation.id;
final isSelected = smartSceneEnable?.entityId == automation.id;
final descriptionSelected = isSelected
? (smartSceneEnable?.actionExecutor == 'rule_enable'
? 'Enable'
: 'Disable')
? (smartSceneEnable?.actionExecutor == 'rule_enable' ? 'Enable' : 'Disable')
: automation.status == 'enable'
? 'Enable'
: 'Disable';
@ -136,17 +128,14 @@ class _SmartSceneSelectAutomationListState
Navigator.pop(context);
},
onDismiss: () {
context
.read<SmartSceneSelectBloc>()
.add(const SmartSceneClearEvent());
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
Navigator.pop(context);
},
);
},
label: BodyMedium(
text: _capitalizeFirst(descriptionSelected),
style: context.bodyMedium
.copyWith(color: ColorsManager.greyColor),
style: context.bodyMedium.copyWith(color: ColorsManager.greyColor),
),
icon: const Icon(
Icons.arrow_forward_ios_rounded,
@ -173,9 +162,7 @@ class _SmartSceneSelectAutomationListState
Navigator.pop(context);
},
onDismiss: () {
context
.read<SmartSceneSelectBloc>()
.add(const SmartSceneClearEvent());
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
Navigator.pop(context);
},
);
@ -211,12 +198,10 @@ class EnableDisableAutomationDialog extends StatefulWidget {
final String type;
@override
State<EnableDisableAutomationDialog> createState() =>
_EnableDisableAutomationDialogState();
State<EnableDisableAutomationDialog> createState() => _EnableDisableAutomationDialogState();
}
class _EnableDisableAutomationDialogState
extends State<EnableDisableAutomationDialog> {
class _EnableDisableAutomationDialogState extends State<EnableDisableAutomationDialog> {
String? groupValue;
final List<SceneOperationalValue> values = [
SceneOperationalValue(
@ -234,16 +219,14 @@ class _EnableDisableAutomationDialogState
@override
void initState() {
super.initState();
groupValue =
widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable';
groupValue = widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable';
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
SmartSceneEnable(
entityId: widget.automationId,
actionExecutor: groupValue!,
sceneORAutomationName: widget.sceneORAutomationName,
type: widget.type,
isAutomation: true)));
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(SmartSceneEnable(
entityId: widget.automationId,
actionExecutor: groupValue!,
sceneORAutomationName: widget.sceneORAutomationName,
type: widget.type,
isAutomation: true)));
}
@override
@ -269,14 +252,11 @@ class _EnableDisableAutomationDialogState
setState(() {
groupValue = value;
});
context
.read<SmartSceneSelectBloc>()
.add(SmartSceneEnableEvent(
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
SmartSceneEnable(
entityId: widget.automationId,
actionExecutor: value!,
sceneORAutomationName:
widget.sceneORAutomationName,
sceneORAutomationName: widget.sceneORAutomationName,
type: widget.type,
isAutomation: true),
));
@ -286,9 +266,7 @@ class _EnableDisableAutomationDialogState
setState(() {
groupValue = operation.value;
});
context
.read<SmartSceneSelectBloc>()
.add(SmartSceneEnableEvent(
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
SmartSceneEnable(
entityId: widget.automationId,
actionExecutor: operation.value,

View File

@ -5,7 +5,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/features/scene/model/smart_scene_enable.dart';
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@ -18,12 +17,10 @@ class SmartSceneSelectTabToRunList extends StatefulWidget {
final List<ScenesModel> scenes;
@override
State<SmartSceneSelectTabToRunList> createState() =>
_SmartSceneSelectTabToRunListState();
State<SmartSceneSelectTabToRunList> createState() => _SmartSceneSelectTabToRunListState();
}
class _SmartSceneSelectTabToRunListState
extends State<SmartSceneSelectTabToRunList> {
class _SmartSceneSelectTabToRunListState extends State<SmartSceneSelectTabToRunList> {
String groupValue = '';
@override
@ -34,15 +31,16 @@ class _SmartSceneSelectTabToRunListState
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextButton(
onPressed: () => Navigator.pop(context),
child: BodySmall(
text: 'Save',
style: context.bodySmall
.copyWith(color: ColorsManager.primaryColorWithOpacity),
)),
),
// Expanded(
// child: TextButton(
// onPressed: () => Navigator.pop(context),
// child: BodySmall(
// text: 'Save',
// style: context.bodySmall
// .copyWith(color: ColorsManager.primaryColorWithOpacity),
// )),
// ),
const Spacer(),
Expanded(
flex: 2,
child: Padding(
@ -51,8 +49,7 @@ class _SmartSceneSelectTabToRunListState
text: 'Tab To Run',
textAlign: TextAlign.center,
style: context.bodyMedium.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold),
color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold),
),
),
),
@ -68,8 +65,7 @@ class _SmartSceneSelectTabToRunListState
itemCount: widget.scenes.length,
itemBuilder: (context, index) {
final scene = widget.scenes[index];
final selectedScene =
context.read<SmartSceneSelectBloc>().smartSceneEnable;
final selectedScene = context.read<SmartSceneSelectBloc>().smartSceneEnable;
if (selectedScene != null) {
if (scene.id == selectedScene.entityId) {
groupValue = scene.id;
@ -111,9 +107,7 @@ class _SmartSceneSelectTabToRunListState
setState(() {
groupValue = scene.id;
});
context
.read<SmartSceneSelectBloc>()
.add(SmartSceneEnableEvent(SmartSceneEnable(
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(SmartSceneEnable(
entityId: scene.id,
actionExecutor: 'rule_enable',
sceneORAutomationName: scene.name,