mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 04:29:40 +00:00
add tow gang and change gang device ui
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
@ -12,6 +13,7 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/light_divider.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
@ -51,22 +53,14 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
.add(AddTaskEvent(isAutomation: isAutomation));
|
||||
navigateToRoute(context, Routes.sceneTasksRoute);
|
||||
},
|
||||
child: BodyMedium(
|
||||
text: 'Save',
|
||||
fontWeight: FontWeight.normal,
|
||||
fontColor: ColorsManager.secondaryColor.withOpacity(0.6),
|
||||
),
|
||||
child: SvgPicture.asset(Assets.saveRoutinesIcon),
|
||||
),
|
||||
],
|
||||
leading: TextButton(
|
||||
onPressed: () {
|
||||
_cancelOperation(context, device, isAutomation);
|
||||
},
|
||||
child: BodyMedium(
|
||||
text: 'Cancel',
|
||||
fontWeight: FontWeight.normal,
|
||||
fontColor: ColorsManager.textPrimaryColor.withOpacity(0.6),
|
||||
),
|
||||
child: SvgPicture.asset(Assets.cancelIcon),
|
||||
),
|
||||
leadingWidth: 80,
|
||||
padding: EdgeInsets.zero,
|
||||
@ -75,65 +69,63 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
itemCount: functions.length,
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
return DefaultContainer(
|
||||
padding: index == 0
|
||||
? const EdgeInsets.only(top: 8)
|
||||
: index == functions.length - 1
|
||||
? const EdgeInsets.only(bottom: 8)
|
||||
: EdgeInsets.zero,
|
||||
margin: EdgeInsets.zero,
|
||||
borderRadius: index == 0
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(20), topRight: Radius.circular(20))
|
||||
: index == functions.length - 1
|
||||
? const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(20),
|
||||
bottomRight: Radius.circular(20))
|
||||
: BorderRadius.zero,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
iconsSize: 22,
|
||||
minLeadingWidth: 20,
|
||||
assetPath: functions[index].icon,
|
||||
titleString: functions[index].operationName,
|
||||
trailingWidget: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
final bool isFirstInPair = index % 2 == 0;
|
||||
final bool isLastInPair =
|
||||
index % 2 == 1 || index == functions.length - 1;
|
||||
final bool isLastItem = index == functions.length - 1;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (isFirstInPair && index != 0) const SizedBox(height: 16),
|
||||
DefaultContainer(
|
||||
padding: EdgeInsets.only(
|
||||
top: isFirstInPair ? 8 : 0,
|
||||
bottom: isLastInPair ? 8 : 0,
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(isFirstInPair ? 20 : 0),
|
||||
topRight: Radius.circular(isFirstInPair ? 20 : 0),
|
||||
bottomLeft: Radius.circular(isLastInPair ? 20 : 0),
|
||||
bottomRight: Radius.circular(isLastInPair ? 20 : 0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
iconsSize: 22,
|
||||
minLeadingWidth: 20,
|
||||
assetPath: functions[index].icon,
|
||||
titleString: functions[index].operationName,
|
||||
trailingWidget: const Icon(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
if (isAutomation) {
|
||||
_showAutomationDialog(
|
||||
context,
|
||||
functions[index],
|
||||
device,
|
||||
);
|
||||
} else {
|
||||
_showTabToRunDialog(
|
||||
context,
|
||||
functions[index],
|
||||
device,
|
||||
);
|
||||
}
|
||||
onPressed: () {
|
||||
if (isAutomation) {
|
||||
_showAutomationDialog(
|
||||
context, functions[index], device);
|
||||
} else {
|
||||
_showTabToRunDialog(
|
||||
context, functions[index], device);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (isFirstInPair && !isLastItem)
|
||||
SizedBox(
|
||||
width: context.width * 0.8,
|
||||
child: const LightDivider(),
|
||||
),
|
||||
],
|
||||
),
|
||||
index != functions.length - 1
|
||||
? SizedBox(
|
||||
width: context.width * 0.8, child: const LightDivider())
|
||||
: const SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user