mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 04:19:40 +00:00
Refactor device name display in Action and Condition models
This commit is contained in:
@ -12,12 +12,10 @@ import 'package:syncrow_app/features/scene/widgets/scene_list_tile.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/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';
|
||||
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DeviceFunctionsView extends StatelessWidget
|
||||
@ -69,14 +67,13 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
itemCount: functions.length,
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
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 (device.productType!.name.toString() == 'ThreeGang' ||
|
||||
device.productType!.name.toString() == 'TwoGang') {
|
||||
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(
|
||||
@ -124,9 +121,73 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
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 && index == functions.length - 1
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
bottomLeft: Radius.circular(20),
|
||||
bottomRight: Radius.circular(20),
|
||||
)
|
||||
: 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(
|
||||
Icons.arrow_forward_ios_rounded,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
if (isAutomation) {
|
||||
_showAutomationDialog(
|
||||
context, functions[index], device);
|
||||
} else {
|
||||
_showTabToRunDialog(
|
||||
context, functions[index], device);
|
||||
}
|
||||
},
|
||||
);
|
||||
}),
|
||||
index != functions.length - 1
|
||||
? SizedBox(
|
||||
width: context.width * 0.8,
|
||||
child: const LightDivider())
|
||||
: const SizedBox(),
|
||||
],
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user