mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
115 lines
3.5 KiB
Dart
115 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/device_managment/device_setting/bloc/setting_bloc_bloc.dart';
|
|
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
|
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
|
|
class SubSpaceDialogButtons extends StatelessWidget {
|
|
const SubSpaceDialogButtons({
|
|
super.key,
|
|
required String? selectedId,
|
|
required this.widget,
|
|
}) : _selectedId = selectedId;
|
|
|
|
final String? _selectedId;
|
|
final SubSpaceDialog widget;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 50,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
right: BorderSide(
|
|
color: ColorsManager.dividerColor,
|
|
width: 0.5,
|
|
),
|
|
),
|
|
),
|
|
child: TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text(
|
|
'Cancel',
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: ColorsManager.textGray,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
left: BorderSide(
|
|
color: ColorsManager.dividerColor,
|
|
width: 0.5,
|
|
),
|
|
),
|
|
),
|
|
child: TextButton(
|
|
onPressed: _selectedId == null
|
|
? null
|
|
: () {
|
|
final selectedModel = widget.subSpaces.firstWhere(
|
|
(space) => space.id == _selectedId,
|
|
orElse: () =>
|
|
SubSpaceModel(id: null, name: '', devices: []));
|
|
widget.onConfirmed(selectedModel);
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text(
|
|
'Confirm',
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: ColorsManager.secondaryColor,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
void showSubSpaceDialog(
|
|
BuildContext context, {
|
|
required List<SubSpaceModel> subSpaces,
|
|
String? selected,
|
|
required String communityUuid,
|
|
required String spaceUuid,
|
|
}) {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (ctx) => SubSpaceDialog(
|
|
subSpaces: subSpaces,
|
|
selected: selected,
|
|
onConfirmed: (selectedModel) {
|
|
if (selectedModel != null) {
|
|
context.read<SettingDeviceBloc>().add(
|
|
SettingBlocAssignRoom(
|
|
communityUuid: communityUuid,
|
|
spaceUuid: spaceUuid,
|
|
subSpaceUuid: selectedModel.id ?? '',
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|