mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-26 02:17:55 +00:00
connected rest of the devices and functions and trigger api
This commit is contained in:
@@ -97,7 +97,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
iconsSize: 32,
|
||||
iconsSize: 22,
|
||||
minLeadingWidth: 20,
|
||||
assetPath: functions[index].icon,
|
||||
titleString: functions[index].operationName,
|
||||
@@ -118,7 +118,12 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
alertBody: functions[index].code == 'temp_set'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index, functions: functions)
|
||||
: functions[index].code.contains('countdown')
|
||||
: (functions[index]
|
||||
.code
|
||||
.contains('countdown') ||
|
||||
functions[index]
|
||||
.code
|
||||
.contains('presence_time'))
|
||||
? AlertDialogCountdown(
|
||||
durationValue: functions[index]
|
||||
.operationalValues
|
||||
|
||||
@@ -3,14 +3,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/create_unit.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.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/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
class SceneView extends StatelessWidget {
|
||||
const SceneView({super.key});
|
||||
@@ -20,113 +17,48 @@ class SceneView extends StatelessWidget {
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => SceneBloc()
|
||||
..add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!)),
|
||||
child: HomeCubit.getInstance().spaces?.isEmpty ?? true
|
||||
? const CreateUnitWidget()
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const TitleMedium(
|
||||
text: StringsManager.routine,
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const BodySmall(
|
||||
text: StringsManager.tapToRunRoutine,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
BlocBuilder<SceneBloc, SceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is SceneLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
if (state is SceneError) {
|
||||
return Center(
|
||||
child: Text(state.message),
|
||||
);
|
||||
}
|
||||
if (state is SceneLoaded) {
|
||||
return Expanded(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
childAspectRatio: 1.5,
|
||||
child: BlocListener<SceneBloc, SceneState>(
|
||||
listener: (context, state) {
|
||||
if (state is SceneTriggerSuccess) {
|
||||
context.showCustomSnackbar(
|
||||
message: 'Scene ${state.sceneName} triggered successfully!');
|
||||
}
|
||||
},
|
||||
child: HomeCubit.getInstance().spaces?.isEmpty ?? true
|
||||
? const CreateUnitWidget()
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SceneHeader(),
|
||||
const SizedBox(height: 8),
|
||||
BlocBuilder<SceneBloc, SceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is SceneLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
if (state is SceneError) {
|
||||
return Center(
|
||||
child: Text(state.message),
|
||||
);
|
||||
}
|
||||
if (state is SceneLoaded) {
|
||||
return Expanded(
|
||||
child: SceneGrid(
|
||||
scenes: state.scenes,
|
||||
loadingSceneId: state.loadingSceneId,
|
||||
),
|
||||
itemCount: state.scenes.length,
|
||||
itemBuilder: (context, index) {
|
||||
final scene = state.scenes[index];
|
||||
return DefaultContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
height: 32,
|
||||
width: 32,
|
||||
Assets.assetsIconsLogo,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
BlocBuilder<SceneBloc, SceneState>(
|
||||
builder: (context, state) {
|
||||
return IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
// context
|
||||
// .read<SceneBloc>()
|
||||
// .add(SceneTrigger(scene.id));
|
||||
},
|
||||
icon: state is SceneTriggerLoading
|
||||
? const Center(
|
||||
child:
|
||||
CircularProgressIndicator())
|
||||
: const Icon(
|
||||
Icons.play_circle,
|
||||
size: 40,
|
||||
color:
|
||||
ColorsManager.greyColor,
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyMedium(
|
||||
text: scene.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.fade,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user