mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
SP-1435
This commit is contained in:
@ -12,8 +12,7 @@ class FetchRoutineScenesAutomation extends StatefulWidget {
|
||||
const FetchRoutineScenesAutomation({super.key});
|
||||
|
||||
@override
|
||||
State<FetchRoutineScenesAutomation> createState() =>
|
||||
_FetchRoutineScenesState();
|
||||
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
||||
}
|
||||
|
||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
@ -55,20 +54,17 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
),
|
||||
if (state.scenes.isNotEmpty)
|
||||
SizedBox(
|
||||
height: 200,
|
||||
height: 200,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.scenes.length,
|
||||
itemBuilder: (context, index) {
|
||||
final scene = state.scenes[index];
|
||||
final isLoading =
|
||||
state.loadingSceneId == scene.id;
|
||||
final isLoading = state.loadingSceneId == scene.id;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right:
|
||||
isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@ -76,31 +72,28 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
isLoading: isLoading,
|
||||
sceneOnTap: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
SceneTrigger(
|
||||
SceneTrigger(
|
||||
sceneId: scene.id,
|
||||
name: scene.name));
|
||||
name: scene.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
status: state.scenes[index].status,
|
||||
communityId:
|
||||
state.scenes[index].communityId ??
|
||||
'',
|
||||
communityId: state.scenes[index].communityId,
|
||||
spaceId: state.scenes[index].spaceId,
|
||||
sceneId:
|
||||
state.scenes[index].sceneTuyaId!,
|
||||
sceneId: state.scenes[index].sceneTuyaId!,
|
||||
automationId: state.scenes[index].id,
|
||||
cardType: 'scenes',
|
||||
spaceName:
|
||||
state.scenes[index].spaceName,
|
||||
spaceName: state.scenes[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
createRoutineView: true,
|
||||
),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetSceneDetails(
|
||||
sceneId:
|
||||
state.scenes[index].id,
|
||||
sceneId: state.scenes[index].id,
|
||||
isTabToRun: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
@ -110,8 +103,7 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
icon: state.scenes[index].icon ??
|
||||
Assets.logoHorizontal,
|
||||
isFromScenes: true,
|
||||
iconInBytes:
|
||||
state.scenes[index].iconInBytes,
|
||||
iconInBytes: state.scenes[index].iconInBytes,
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -136,77 +128,69 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
),
|
||||
if (state.automations.isNotEmpty)
|
||||
SizedBox(
|
||||
height: 200,
|
||||
|
||||
height: 200,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isLoading = state.automations!
|
||||
.contains(state.automations[index].id);
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isLoading = state.automations
|
||||
.contains(state.automations[index].id);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context)
|
||||
? 4.0
|
||||
: 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
onChanged: (v) {
|
||||
context.read<RoutineBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationId: state
|
||||
.automations[index].id,
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: state
|
||||
.automations[
|
||||
index]
|
||||
.spaceId,
|
||||
isEnable: v),
|
||||
communityId: state
|
||||
.automations[index]
|
||||
.communityId,
|
||||
),
|
||||
);
|
||||
},
|
||||
status: state.automations[index].status,
|
||||
communityId: '',
|
||||
spaceId:
|
||||
state.automations[index].spaceId,
|
||||
sceneId: '',
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
cardType: 'automations',
|
||||
spaceName:
|
||||
state.automations[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId: state
|
||||
.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true),
|
||||
);
|
||||
},
|
||||
textString:
|
||||
state.automations[index].name,
|
||||
icon: state.automations[index].icon ??
|
||||
Assets.automation,
|
||||
),
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
child: RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
onChanged: (v) {
|
||||
context.read<RoutineBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: state
|
||||
.automations[index].spaceId,
|
||||
isEnable: v,
|
||||
),
|
||||
communityId: state
|
||||
.automations[index].communityId,
|
||||
),
|
||||
);
|
||||
},
|
||||
status: state.automations[index].status,
|
||||
communityId: '',
|
||||
spaceId: state.automations[index].spaceId,
|
||||
sceneId: '',
|
||||
automationId: state.automations[index].id,
|
||||
cardType: 'automations',
|
||||
spaceName: state.automations[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true,
|
||||
),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
textString: state.automations[index].name,
|
||||
icon: state.automations[index].icon ??
|
||||
Assets.automation,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -66,7 +67,6 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Use widget.<mixinMethod> instead of just <mixinMethod>
|
||||
final double cardWidth = widget.isSmallScreenSize(context)
|
||||
? 120
|
||||
: widget.isMediumScreenSize(context)
|
||||
@ -127,22 +127,23 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
)
|
||||
else
|
||||
CupertinoSwitch(
|
||||
activeColor: ColorsManager.primaryColor,
|
||||
activeTrackColor: ColorsManager.primaryColor,
|
||||
value: widget.status == 'enable',
|
||||
onChanged: widget.onChanged,
|
||||
)
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
InkWell(
|
||||
onTap: widget.onTap,
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
Column(
|
||||
children: [
|
||||
Center(
|
||||
child: InkWell(
|
||||
customBorder: const CircleBorder(),
|
||||
onTap: widget.onTap,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(120),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 2.0,
|
||||
@ -158,7 +159,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (context, error, stackTrace) => Image.asset(
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
Image.asset(
|
||||
Assets.logo,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
@ -171,7 +173,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
: (widget.icon is String && widget.icon.endsWith('.svg'))
|
||||
: (widget.icon is String &&
|
||||
widget.icon.endsWith('.svg'))
|
||||
? SvgPicture.asset(
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
@ -181,51 +184,54 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
: Icon(
|
||||
widget.icon,
|
||||
color: ColorsManager.dialogBlueTitle,
|
||||
size: widget.isSmallScreenSize(context) ? 30 : 40,
|
||||
size: widget.isSmallScreenSize(context)
|
||||
? 30
|
||||
: 40,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.textString,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.textString,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
if (widget.spaceName != '')
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.spaceLocationIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
if (widget.spaceName != '')
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.spaceLocationIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Text(
|
||||
widget.spaceName,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize:
|
||||
widget.isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
Text(
|
||||
widget.spaceName,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user