mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor routine_view_card.dart to adjust the size o
This commit is contained in:
@ -31,165 +31,185 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
? const Center(
|
? const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
)
|
)
|
||||||
: Padding(
|
: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
child: Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
Text(
|
children: [
|
||||||
"Scenes (Tab to Run)",
|
Text(
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
"Scenes (Tab to Run)",
|
||||||
color: ColorsManager.grayColor,
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
color: ColorsManager.grayColor,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
if (state.scenes.isEmpty)
|
const SizedBox(height: 10),
|
||||||
Expanded(
|
if (state.scenes.isEmpty)
|
||||||
child: Text(
|
Text(
|
||||||
"No scenes found",
|
"No scenes found",
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (state.scenes.isNotEmpty)
|
||||||
if (state.scenes.isNotEmpty)
|
SizedBox(
|
||||||
ConstrainedBox(
|
height: 200,
|
||||||
constraints: BoxConstraints(
|
child: ListView.builder(
|
||||||
maxHeight: isSmallScreenSize(context) ? 190 : 200,
|
shrinkWrap: true,
|
||||||
maxWidth: MediaQuery.sizeOf(context).width * 0.8),
|
scrollDirection: Axis.horizontal,
|
||||||
child: ListView.builder(
|
itemCount: state.scenes.length,
|
||||||
scrollDirection: Axis.horizontal,
|
itemBuilder: (context, index) {
|
||||||
itemCount: state.scenes.length,
|
final scene = state.scenes[index];
|
||||||
itemBuilder: (context, index) {
|
final isLoading =
|
||||||
final scene = state.scenes[index];
|
state.loadingSceneId == scene.id;
|
||||||
final isLoading =
|
|
||||||
state.loadingSceneId == scene.id;
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
right:
|
||||||
),
|
isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
child: RoutineViewCard(
|
),
|
||||||
isLoading: isLoading,
|
child: Column(
|
||||||
sceneOnTap: () {
|
children: [
|
||||||
context.read<RoutineBloc>().add(
|
RoutineViewCard(
|
||||||
SceneTrigger(
|
isLoading: isLoading,
|
||||||
sceneId: scene.id,
|
sceneOnTap: () {
|
||||||
name: scene.name));
|
context.read<RoutineBloc>().add(
|
||||||
},
|
SceneTrigger(
|
||||||
status: state.scenes[index].status,
|
sceneId: scene.id,
|
||||||
communityId:
|
name: scene.name));
|
||||||
state.scenes[index].communityId ?? '',
|
},
|
||||||
spaceId: state.scenes[index].spaceId,
|
status: state.scenes[index].status,
|
||||||
sceneId: state.scenes[index].sceneTuyaId!,
|
communityId:
|
||||||
automationId: state.scenes[index].id,
|
state.scenes[index].communityId ??
|
||||||
cardType: 'scenes',
|
'',
|
||||||
spaceName: state.scenes[index].spaceName,
|
spaceId: state.scenes[index].spaceId,
|
||||||
onTap: () {
|
sceneId:
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
state.scenes[index].sceneTuyaId!,
|
||||||
const CreateNewRoutineViewEvent(
|
automationId: state.scenes[index].id,
|
||||||
createRoutineView: true),
|
cardType: 'scenes',
|
||||||
);
|
spaceName:
|
||||||
context.read<RoutineBloc>().add(
|
state.scenes[index].spaceName,
|
||||||
GetSceneDetails(
|
onTap: () {
|
||||||
sceneId: state.scenes[index].id,
|
BlocProvider.of<RoutineBloc>(context)
|
||||||
isTabToRun: true,
|
.add(
|
||||||
isUpdate: true,
|
const CreateNewRoutineViewEvent(
|
||||||
),
|
createRoutineView: true),
|
||||||
);
|
);
|
||||||
},
|
context.read<RoutineBloc>().add(
|
||||||
textString: state.scenes[index].name,
|
GetSceneDetails(
|
||||||
icon: state.scenes[index].icon ??
|
sceneId:
|
||||||
Assets.logoHorizontal,
|
state.scenes[index].id,
|
||||||
isFromScenes: true,
|
isTabToRun: true,
|
||||||
iconInBytes: state.scenes[index].iconInBytes,
|
isUpdate: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
textString: state.scenes[index].name,
|
||||||
|
icon: state.scenes[index].icon ??
|
||||||
|
Assets.logoHorizontal,
|
||||||
|
isFromScenes: true,
|
||||||
|
iconInBytes:
|
||||||
|
state.scenes[index].iconInBytes,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"Automations",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 3),
|
||||||
Text(
|
if (state.automations.isEmpty)
|
||||||
"Automations",
|
Text(
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
if (state.automations.isEmpty)
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
"No automations found",
|
"No automations found",
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (state.automations.isNotEmpty)
|
||||||
if (state.automations.isNotEmpty)
|
SizedBox(
|
||||||
ConstrainedBox(
|
height: 200,
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: isSmallScreenSize(context) ? 190 : 195,
|
|
||||||
),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.automations.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final isLoading = state.automations!
|
|
||||||
.contains(state.automations[index].id);
|
|
||||||
|
|
||||||
return Padding(
|
child: ListView.builder(
|
||||||
padding: EdgeInsets.only(
|
shrinkWrap: true,
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
scrollDirection: Axis.horizontal,
|
||||||
),
|
itemCount: state.automations.length,
|
||||||
child: RoutineViewCard(
|
itemBuilder: (context, index) {
|
||||||
isLoading: isLoading,
|
final isLoading = state.automations!
|
||||||
onChanged: (v) {
|
.contains(state.automations[index].id);
|
||||||
// BlocProvider.of<RoutineBloc>(context)
|
|
||||||
context.read<RoutineBloc>().add(
|
return Column(
|
||||||
UpdateAutomationStatus(
|
children: [
|
||||||
automationId:
|
Padding(
|
||||||
state.automations[index].id,
|
padding: EdgeInsets.only(
|
||||||
automationStatusUpdate:
|
right: isSmallScreenSize(context)
|
||||||
AutomationStatusUpdate(
|
? 4.0
|
||||||
spaceUuid: state
|
: 8.0,
|
||||||
.automations[index]
|
),
|
||||||
.spaceId,
|
child: RoutineViewCard(
|
||||||
isEnable: v),
|
isLoading: isLoading,
|
||||||
communityId: state
|
onChanged: (v) {
|
||||||
.automations[index].communityId,
|
context.read<RoutineBloc>().add(
|
||||||
),
|
UpdateAutomationStatus(
|
||||||
);
|
automationId: state
|
||||||
},
|
.automations[index].id,
|
||||||
status: state.automations[index].status,
|
automationStatusUpdate:
|
||||||
communityId: '',
|
AutomationStatusUpdate(
|
||||||
spaceId: state.automations[index].spaceId,
|
spaceUuid: state
|
||||||
sceneId: '',
|
.automations[
|
||||||
automationId: state.automations[index].id,
|
index]
|
||||||
cardType: 'automations',
|
.spaceId,
|
||||||
spaceName: state.scenes[index].spaceName,
|
isEnable: v),
|
||||||
onTap: () {
|
communityId: state
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
.automations[index]
|
||||||
const CreateNewRoutineViewEvent(
|
.communityId,
|
||||||
createRoutineView: true),
|
),
|
||||||
);
|
);
|
||||||
context.read<RoutineBloc>().add(
|
},
|
||||||
GetAutomationDetails(
|
status: state.automations[index].status,
|
||||||
automationId:
|
communityId: '',
|
||||||
state.automations[index].id,
|
spaceId:
|
||||||
isAutomation: true,
|
state.automations[index].spaceId,
|
||||||
isUpdate: true),
|
sceneId: '',
|
||||||
);
|
automationId:
|
||||||
},
|
state.automations[index].id,
|
||||||
textString: state.automations[index].name,
|
cardType: 'automations',
|
||||||
icon: state.automations[index].icon ??
|
spaceName:
|
||||||
Assets.automation,
|
state.scenes[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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -177,6 +177,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
: (widget.icon is String &&
|
: (widget.icon is String &&
|
||||||
widget.icon.endsWith('.svg'))
|
widget.icon.endsWith('.svg'))
|
||||||
? SvgPicture.asset(
|
? SvgPicture.asset(
|
||||||
|
height: iconSize,
|
||||||
|
width: iconSize,
|
||||||
widget.icon,
|
widget.icon,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user