mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 15:47:44 +00:00
Compare commits
18 Commits
space_mana
...
very_good_
Author | SHA1 | Date | |
---|---|---|---|
e867c29086 | |||
c250fb4469 | |||
59ac1bd74d | |||
bac1450c2b | |||
889461db7d | |||
27dbcb26f1 | |||
0c5db9dfeb | |||
1393a15eca | |||
3c6f88b245 | |||
0b92abff26 | |||
fc86042af7 | |||
cd6bf32aed | |||
e81b9a853e | |||
d66921c615 | |||
f7f3843fa7 | |||
a1b20078a3 | |||
ed06a760d2 | |||
662fe211eb |
@ -1,33 +1,27 @@
|
|||||||
# This file configures the analyzer, which statically analyzes Dart code to
|
include: package:very_good_analysis/analysis_options.yaml
|
||||||
# check for errors, warnings, and lints.
|
|
||||||
#
|
|
||||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
|
||||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
|
||||||
# invoked from the command line by running `flutter analyze`.
|
|
||||||
|
|
||||||
# The following line activates a set of recommended lints for Flutter apps,
|
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
|
||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
constant_identifier_names: ignore
|
strict_raw_type: warning
|
||||||
overridden_fields: ignore
|
argument_type_not_assignable: warning
|
||||||
include: package:flutter_lints/flutter.yaml
|
invalid_assignment: warning
|
||||||
|
return_of_invalid_type: warning
|
||||||
|
return_of_invalid_type_from_closure: warning
|
||||||
|
list_element_type_not_assignable: warning
|
||||||
|
for_in_of_invalid_type: warning
|
||||||
|
cast_nullable_to_non_nullable: warning
|
||||||
|
non_bool_condition: warning
|
||||||
|
field_initializer_not_assignable: warning
|
||||||
|
non_bool_negation_expression: warning
|
||||||
|
non_bool_operand: warning
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
# The lint rules applied to this project can be customized in the
|
|
||||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
|
||||||
# included above or to enable additional rules. A list of all available lints
|
|
||||||
# and their documentation is published at https://dart.dev/lints.
|
|
||||||
#
|
|
||||||
# Instead of disabling a lint rule for the entire project in the
|
|
||||||
# section below, it can also be suppressed for a single line of code
|
|
||||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
|
||||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
|
||||||
# producing the lint.
|
|
||||||
rules:
|
rules:
|
||||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
prefer_single_quotes: true
|
||||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
avoid_print: false
|
||||||
prefer_const_constructors: true
|
public_member_api_docs: false
|
||||||
|
sort_pub_dependencies: false
|
||||||
# Additional information about this file can be found at
|
one_member_abstracts: false
|
||||||
# https://dart.dev/guides/language/analysis-options
|
prefer_int_literals: false
|
||||||
|
sort_constructors_first: false
|
||||||
|
avoid_redundant_argument_values: false
|
||||||
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
@ -267,7 +267,8 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
effectiveTimeTimeStamp = null;
|
effectiveTimeTimeStamp = null;
|
||||||
expirationTimeTimeStamp = null;
|
expirationTimeTimeStamp = null;
|
||||||
add(FetchTableData());
|
filteredData = List.from(data);
|
||||||
|
emit(TableLoaded(filteredData));
|
||||||
}
|
}
|
||||||
|
|
||||||
String timestampToDate(dynamic timestamp) {
|
String timestampToDate(dynamic timestamp) {
|
||||||
|
@ -34,7 +34,8 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
|||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
children: [
|
children: [
|
||||||
_buildSearchField("Space Name", _unitNameController, 200),
|
_buildSearchField("Space Name", _unitNameController, 200),
|
||||||
_buildSearchField("Device Name / Product Name", _productNameController, 300),
|
_buildSearchField(
|
||||||
|
"Device Name / Product Name", _productNameController, 300),
|
||||||
_buildSearchResetButtons(),
|
_buildSearchResetButtons(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -74,9 +75,7 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
|||||||
onReset: () {
|
onReset: () {
|
||||||
_unitNameController.clear();
|
_unitNameController.clear();
|
||||||
_productNameController.clear();
|
_productNameController.clear();
|
||||||
context.read<DeviceManagementBloc>()
|
context.read<DeviceManagementBloc>().add(ResetFilters());
|
||||||
..add(ResetFilters())
|
|
||||||
..add(FetchDevices(context));
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/device_info_model.dart';
|
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/device_info_model.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/settings_model/sub_space_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/device_setting/sub_space_dialog.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/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/web_layout/default_container.dart';
|
import 'package:syncrow_web/web_layout/default_container.dart';
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
Widget? trailing,
|
Widget? trailing,
|
||||||
required Color? valueColor}) {
|
required Color? valueColor}) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -39,6 +41,7 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
value,
|
value,
|
||||||
@ -48,7 +51,7 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 12),
|
||||||
trailing ?? const SizedBox.shrink(),
|
trailing ?? const SizedBox.shrink(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -75,13 +78,13 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
child: infoRow(
|
child: infoRow(
|
||||||
label: 'Sub-Space:',
|
label: 'Sub-Space:',
|
||||||
value: deviceInfo.subspace.subspaceName,
|
value: deviceInfo.subspace.subspaceName,
|
||||||
valueColor: ColorsManager.textGray,
|
valueColor: ColorsManager.blackColor,
|
||||||
trailing: const Icon(
|
trailing: SvgPicture.asset(
|
||||||
Icons.arrow_forward_ios,
|
Assets.arrowDown,
|
||||||
size: 16,
|
width: 10,
|
||||||
|
height: 10,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
),
|
)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(color: ColorsManager.dividerColor),
|
const Divider(color: ColorsManager.dividerColor),
|
||||||
@ -104,7 +107,7 @@ class DeviceManagementContent extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.copy,
|
Icons.copy,
|
||||||
size: 16,
|
size: 15,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -51,8 +51,7 @@ class DeviceSettingsPanel extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.3,
|
width: MediaQuery.of(context).size.width * 0.3,
|
||||||
color: ColorsManager.grey25,
|
color: ColorsManager.grey25,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.all(10),
|
||||||
horizontal: 20, vertical: 24),
|
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -70,22 +69,26 @@ class DeviceSettingsPanel extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Device Settings',
|
'Device Settings',
|
||||||
style:
|
style: context.theme.textTheme.titleLarge!
|
||||||
context.theme.textTheme.titleLarge!.copyWith(
|
.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w700,
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.vividBlue
|
||||||
),
|
.withOpacity(0.7),
|
||||||
|
fontSize: 24),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
DefaultContainer(
|
DefaultContainer(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
Padding(
|
||||||
radius: 40,
|
padding: const EdgeInsets.only(left: 15),
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: 38,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
const Color.fromARGB(177, 213, 213, 213),
|
ColorsManager.grayBorder.withOpacity(0.5),
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
radius: 36,
|
radius: 36,
|
||||||
@ -95,12 +98,14 @@ class DeviceSettingsPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
),
|
||||||
|
const SizedBox(width: 25),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(height: 15),
|
||||||
Text(
|
Text(
|
||||||
'Device Name:',
|
'Device Name:',
|
||||||
style: context.textTheme.bodyMedium!
|
style: context.textTheme.bodyMedium!
|
||||||
@ -108,10 +113,19 @@ class DeviceSettingsPanel extends StatelessWidget {
|
|||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextFormField(
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: 190,
|
||||||
|
child: TextFormField(
|
||||||
|
scrollPadding: EdgeInsets.zero,
|
||||||
maxLength: 30,
|
maxLength: 30,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
focusNode: _bloc.focusNode,
|
focusNode: _bloc.focusNode,
|
||||||
@ -121,37 +135,57 @@ class DeviceSettingsPanel extends StatelessWidget {
|
|||||||
_bloc.add(const ChangeNameEvent(
|
_bloc.add(const ChangeNameEvent(
|
||||||
value: false));
|
value: false));
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white10,
|
fillColor: Colors.white10,
|
||||||
counterText: '',
|
counterText: '',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 15,
|
||||||
|
height: 25,
|
||||||
|
child: Visibility(
|
||||||
|
visible:
|
||||||
|
_bloc.editName != true,
|
||||||
|
replacement: const SizedBox(),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
_bloc.add(
|
||||||
|
const ChangeNameEvent(
|
||||||
|
value: true));
|
||||||
|
},
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
Assets
|
||||||
|
.editNameIconSettings,
|
||||||
|
color: ColorsManager
|
||||||
|
.lightGrayBorderColor,
|
||||||
|
height: 15,
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
],
|
||||||
Visibility(
|
|
||||||
visible: _bloc.editName != true,
|
|
||||||
replacement: const SizedBox(),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
_bloc.add(
|
|
||||||
const ChangeNameEvent(value: true));
|
|
||||||
},
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.editNameIconSettings,
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
Text('Device Management', style: sectionTitle),
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 10),
|
||||||
|
child: Text('Device Management', style: sectionTitle),
|
||||||
|
),
|
||||||
DeviceManagementContent(
|
DeviceManagementContent(
|
||||||
device: device,
|
device: device,
|
||||||
subSpaces: subSpaces.cast<SubSpaceModel>(),
|
subSpaces: subSpaces.cast<SubSpaceModel>(),
|
||||||
|
@ -379,7 +379,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorState> {
|
|||||||
}
|
}
|
||||||
emit(GarageDoorLoadedState(status: deviceStatus));
|
emit(GarageDoorLoadedState(status: deviceStatus));
|
||||||
add(GarageDoorControlEvent(
|
add(GarageDoorControlEvent(
|
||||||
deviceId: event.deviceId,
|
deviceId: deviceId,
|
||||||
value: deviceStatus.delay.inSeconds,
|
value: deviceStatus.delay.inSeconds,
|
||||||
code: 'countdown_1'));
|
code: 'countdown_1'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -396,7 +396,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorState> {
|
|||||||
_updateLocalValue(event.code, event.value);
|
_updateLocalValue(event.code, event.value);
|
||||||
emit(GarageDoorLoadedState(status: deviceStatus));
|
emit(GarageDoorLoadedState(status: deviceStatus));
|
||||||
final success = await _runDeBouncer(
|
final success = await _runDeBouncer(
|
||||||
deviceId: event.deviceId,
|
deviceId: deviceId,
|
||||||
code: event.code,
|
code: event.code,
|
||||||
value: event.value,
|
value: event.value,
|
||||||
oldValue: oldValue,
|
oldValue: oldValue,
|
||||||
|
@ -36,7 +36,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
|
|
||||||
if (user != null && user!.project != null) {
|
if (user != null && user!.project != null) {
|
||||||
await ProjectManager.setProjectUUID(user!.project!.uuid);
|
await ProjectManager.setProjectUUID(user!.project!.uuid);
|
||||||
// NavigationService.navigatorKey.currentContext!.read<SpaceTreeBloc>().add(InitialEvent());
|
|
||||||
}
|
}
|
||||||
add(FetchTermEvent());
|
add(FetchTermEvent());
|
||||||
add(FetchPolicyEvent());
|
add(FetchPolicyEvent());
|
||||||
|
@ -20,12 +20,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
|
|||||||
// Flag to track whether the dialog is already shown.
|
// Flag to track whether the dialog is already shown.
|
||||||
bool _dialogShown = false;
|
bool _dialogShown = false;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
|
||||||
// homeBloc.add(const FetchUserInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,29 +1,73 @@
|
|||||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/create_new_routines/dropdown_menu_content.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'space_tree_dropdown_bloc.dart';
|
||||||
|
|
||||||
class CommunityDropdown extends StatelessWidget {
|
class SpaceTreeDropdown extends StatefulWidget {
|
||||||
final String? selectedValue;
|
final String? selectedSpaceId;
|
||||||
final List<CommunityModel> communities;
|
final Function(String?)? onChanged;
|
||||||
final Function(String?) onChanged;
|
|
||||||
final TextEditingController _searchController = TextEditingController();
|
|
||||||
|
|
||||||
CommunityDropdown({
|
const SpaceTreeDropdown({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.selectedValue,
|
this.selectedSpaceId,
|
||||||
required this.onChanged,
|
this.onChanged,
|
||||||
required this.communities,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
@override
|
||||||
|
State<SpaceTreeDropdown> createState() => _SpaceTreeDropdownState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SpaceTreeDropdownState extends State<SpaceTreeDropdown> {
|
||||||
|
late SpaceTreeDropdownBloc _dropdownBloc;
|
||||||
|
final LayerLink _layerLink = LayerLink();
|
||||||
|
OverlayEntry? _overlayEntry;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_dropdownBloc = SpaceTreeDropdownBloc(widget.selectedSpaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_dropdownBloc.close();
|
||||||
|
_removeOverlay();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _removeOverlay() {
|
||||||
|
_overlayEntry?.remove();
|
||||||
|
_overlayEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return BlocProvider.value(
|
||||||
padding: const EdgeInsets.all(10.0),
|
value: _dropdownBloc,
|
||||||
child: Column(
|
child: BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||||
|
builder: (context, spaceTreeState) {
|
||||||
|
final communities = spaceTreeState.searchQuery.isNotEmpty
|
||||||
|
? spaceTreeState.filteredCommunity
|
||||||
|
: spaceTreeState.communityList;
|
||||||
|
|
||||||
|
return BlocBuilder<SpaceTreeDropdownBloc, SpaceTreeDropdownState>(
|
||||||
|
builder: (context, dropdownState) {
|
||||||
|
final selectedCommunity = _findCommunity(
|
||||||
|
communities,
|
||||||
|
dropdownState.selectedSpaceId,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
|
child: Text(
|
||||||
"Community",
|
"Community",
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
@ -31,126 +75,107 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
SizedBox(
|
CompositedTransformTarget(
|
||||||
|
link: _layerLink,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => _toggleDropdown(context, communities),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
height: 46,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(10),
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
),
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: DropdownButton2<String>(
|
|
||||||
underline: const SizedBox(),
|
|
||||||
value: selectedValue,
|
|
||||||
items: communities.map((community) {
|
|
||||||
return DropdownMenuItem<String>(
|
|
||||||
value: community.uuid,
|
|
||||||
child: Text(
|
|
||||||
' ${community.name}',
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
onChanged: onChanged,
|
|
||||||
style: const TextStyle(color: Colors.black),
|
|
||||||
hint: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 10),
|
|
||||||
child: Text(
|
|
||||||
" Please Select",
|
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
color: ColorsManager.textGray,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
customButton: Container(
|
|
||||||
height: 45,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: ColorsManager.textGray, width: 1.0),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
),
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Padding(
|
||||||
flex: 5,
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
selectedValue != null
|
selectedCommunity?.name ?? 'Please Select',
|
||||||
? " ${communities.firstWhere((element) => element.uuid == selectedValue).name}"
|
style: TextStyle(
|
||||||
: ' Please Select',
|
color: selectedCommunity != null
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
? ColorsManager.blackColor
|
||||||
color: selectedValue != null
|
|
||||||
? Colors.black
|
|
||||||
: ColorsManager.textGray,
|
: ColorsManager.textGray,
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[100],
|
color: Colors.grey[200],
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topRight: Radius.circular(10),
|
topRight: Radius.circular(10),
|
||||||
bottomRight: Radius.circular(10),
|
bottomRight: Radius.circular(10),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
height: 45,
|
height: 45,
|
||||||
|
width: 33,
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.keyboard_arrow_down,
|
Icons.keyboard_arrow_down,
|
||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
dropdownStyleData: DropdownStyleData(
|
|
||||||
maxHeight: MediaQuery.of(context).size.height * 0.4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
dropdownSearchData: DropdownSearchData(
|
|
||||||
searchController: _searchController,
|
|
||||||
searchInnerWidgetHeight: 50,
|
|
||||||
searchInnerWidget: Container(
|
|
||||||
height: 50,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
||||||
child: TextFormField(
|
|
||||||
style: const TextStyle(color: Colors.black),
|
|
||||||
controller: _searchController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
isDense: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 10,
|
|
||||||
vertical: 12,
|
|
||||||
),
|
|
||||||
hintText: 'Search for community...',
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
searchMatchFn: (item, searchValue) {
|
|
||||||
final communityName =
|
|
||||||
(item.child as Text).data?.toLowerCase() ?? '';
|
|
||||||
return communityName
|
|
||||||
.contains(searchValue.toLowerCase().trim());
|
|
||||||
},
|
|
||||||
),
|
|
||||||
onMenuStateChange: (isOpen) {
|
|
||||||
if (!isOpen) {
|
|
||||||
_searchController.clear();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
menuItemStyleData: const MenuItemStyleData(
|
|
||||||
height: 40,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _toggleDropdown(BuildContext context, List<CommunityModel> communities) {
|
||||||
|
if (_overlayEntry != null) {
|
||||||
|
_removeOverlay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_overlayEntry = OverlayEntry(
|
||||||
|
builder: (context) => Positioned(
|
||||||
|
width: 300,
|
||||||
|
child: CompositedTransformFollower(
|
||||||
|
link: _layerLink,
|
||||||
|
showWhenUnlinked: false,
|
||||||
|
offset: const Offset(0, 48),
|
||||||
|
child: Material(
|
||||||
|
elevation: 8,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: DropdownMenuContent(
|
||||||
|
selectedSpaceId: _dropdownBloc.state.selectedSpaceId,
|
||||||
|
onChanged: (id) {
|
||||||
|
if (id != null && mounted) {
|
||||||
|
_dropdownBloc.add(SpaceTreeDropdownSelectEvent(id));
|
||||||
|
widget.onChanged?.call(id);
|
||||||
|
_removeOverlay();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClose: _removeOverlay,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Overlay.of(context).insert(_overlayEntry!);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommunityModel? _findCommunity(
|
||||||
|
List<CommunityModel> communities, String? communityId) {
|
||||||
|
if (communityId == null) return null;
|
||||||
|
try {
|
||||||
|
return communities.firstWhere((c) => c.uuid == communityId);
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ class CreateNewRoutinesDialog extends StatefulWidget {
|
|||||||
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||||
String? _selectedCommunity;
|
String? _selectedCommunity;
|
||||||
String? _selectedSpace;
|
String? _selectedSpace;
|
||||||
|
String? _selectedId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -30,7 +31,7 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
final spaces = _bloc.spacesOnlyWithDevices;
|
final spaces = _bloc.spacesOnlyWithDevices;
|
||||||
final isLoadingCommunities = state is CommunitiesLoadingState;
|
final isLoadingCommunities = state is CommunitiesLoadingState;
|
||||||
final isLoadingSpaces = state is SpaceWithDeviceLoadingState;
|
final isLoadingSpaces = state is SpaceWithDeviceLoadingState;
|
||||||
String spaceHint = 'Select a community first';
|
String spaceHint = 'Please Select';
|
||||||
if (_selectedCommunity != null) {
|
if (_selectedCommunity != null) {
|
||||||
if (isLoadingSpaces) {
|
if (isLoadingSpaces) {
|
||||||
spaceHint = 'Loading spaces...';
|
spaceHint = 'Loading spaces...';
|
||||||
@ -40,7 +41,10 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
spaceHint = 'Select Space';
|
spaceHint = 'Select Space';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_selectedId != null && _selectedCommunity != _selectedId) {
|
||||||
|
_selectedSpace = null;
|
||||||
|
_selectedCommunity = _selectedId;
|
||||||
|
}
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
insetPadding: EdgeInsets.zero,
|
insetPadding: EdgeInsets.zero,
|
||||||
@ -51,7 +55,9 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
'Create New Routines',
|
'Create New Routines',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.spaceColor,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
content: Stack(
|
content: Stack(
|
||||||
@ -60,27 +66,28 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
padding:
|
||||||
child: CommunityDropdown(
|
const EdgeInsets.only(left: 13, right: 8),
|
||||||
communities: _bloc.communities..sort(
|
child: Column(
|
||||||
(a, b) => a.name.toLowerCase().compareTo(
|
children: [
|
||||||
b.name.toLowerCase(),
|
SpaceTreeDropdown(
|
||||||
),
|
selectedSpaceId: _selectedId,
|
||||||
),
|
|
||||||
selectedValue: _selectedCommunity,
|
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() => _selectedId = newValue!);
|
||||||
_selectedCommunity = newValue;
|
if (_selectedId != null) {
|
||||||
_selectedSpace = null;
|
_bloc.add(SpaceOnlyWithDevicesEvent(
|
||||||
});
|
_selectedId!));
|
||||||
if (newValue != null) {
|
|
||||||
_bloc.add(SpaceOnlyWithDevicesEvent(newValue));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
|
)),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
|
const SizedBox(height: 8),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||||
child: SpaceDropdown(
|
child: SpaceDropdown(
|
||||||
@ -94,6 +101,9 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
@ -0,0 +1,148 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||||
|
|
||||||
|
class DropdownMenuContent extends StatefulWidget {
|
||||||
|
final String? selectedSpaceId;
|
||||||
|
final ValueChanged<String?> onChanged;
|
||||||
|
final VoidCallback onClose;
|
||||||
|
|
||||||
|
const DropdownMenuContent({
|
||||||
|
required this.selectedSpaceId,
|
||||||
|
required this.onChanged,
|
||||||
|
required this.onClose,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DropdownMenuContent> createState() => _DropdownMenuContentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DropdownMenuContentState extends State<DropdownMenuContent> {
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_scrollController.addListener(_onScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
_searchController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onScroll() {
|
||||||
|
final bloc = context.read<SpaceTreeBloc>();
|
||||||
|
final state = bloc.state;
|
||||||
|
if (_scrollController.position.pixels >=
|
||||||
|
_scrollController.position.maxScrollExtent - 30) {
|
||||||
|
if (state is SpaceTreeState && !state.paginationIsLoading) {
|
||||||
|
bloc.add(PaginationEvent(state.paginationModel, state.communityList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxHeight: 300),
|
||||||
|
child: BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final communities = state.searchQuery.isNotEmpty
|
||||||
|
? state.filteredCommunity
|
||||||
|
: state.communityList;
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Search bar
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _searchController,
|
||||||
|
onChanged: (query) {
|
||||||
|
context.read<SpaceTreeBloc>().add(SearchQueryEvent(query));
|
||||||
|
},
|
||||||
|
style: const TextStyle(fontSize: 14, color: Colors.black),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Search for space...',
|
||||||
|
prefixIcon: const Icon(Icons.search, size: 20),
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Community list
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: _scrollController,
|
||||||
|
itemCount:
|
||||||
|
communities.length + (state.paginationIsLoading ? 1 : 0),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index >= communities.length) {
|
||||||
|
return state.paginationIsLoading
|
||||||
|
? const Padding(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
child: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child:
|
||||||
|
CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
final community = communities[index];
|
||||||
|
final isSelected = community.uuid == widget.selectedSpaceId;
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
community.name,
|
||||||
|
style: TextStyle(
|
||||||
|
color: isSelected ? Colors.blue : Colors.black,
|
||||||
|
fontWeight:
|
||||||
|
isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
_searchController.clear();
|
||||||
|
_searchController.text.isEmpty
|
||||||
|
? context
|
||||||
|
.read<SpaceTreeBloc>()
|
||||||
|
.add(SearchQueryEvent(''))
|
||||||
|
: context.read<SpaceTreeBloc>().add(
|
||||||
|
SearchQueryEvent(_searchController.text));
|
||||||
|
});
|
||||||
|
// Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
widget.onChanged(community.uuid);
|
||||||
|
widget.onClose();
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
|
||||||
class SpaceDropdown extends StatelessWidget {
|
class SpaceDropdown extends StatelessWidget {
|
||||||
final List<SpaceModel> spaces;
|
final List<SpaceModel> spaces;
|
||||||
final String? selectedValue;
|
final String? selectedValue;
|
||||||
@ -21,7 +20,7 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.only(left: 10),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -33,7 +32,6 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -90,7 +88,7 @@ class SpaceDropdown extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 5,
|
flex: 6,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 10),
|
padding: const EdgeInsets.only(left: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
part 'space_tree_dropdown_event.dart';
|
||||||
|
part 'space_tree_dropdown_state.dart';
|
||||||
|
|
||||||
|
class SpaceTreeDropdownBloc
|
||||||
|
extends Bloc<SpaceTreeDropdownEvent, SpaceTreeDropdownState> {
|
||||||
|
SpaceTreeDropdownBloc(String? initialId)
|
||||||
|
: super(SpaceTreeDropdownState(selectedSpaceId: initialId)) {
|
||||||
|
on<SpaceTreeDropdownSelectEvent>(_onSelect);
|
||||||
|
on<SpaceTreeDropdownResetEvent>(_onReset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSelect(
|
||||||
|
SpaceTreeDropdownSelectEvent event,
|
||||||
|
Emitter<SpaceTreeDropdownState> emit,
|
||||||
|
) {
|
||||||
|
emit(SpaceTreeDropdownState(selectedSpaceId: event.spaceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onReset(
|
||||||
|
SpaceTreeDropdownResetEvent event,
|
||||||
|
Emitter<SpaceTreeDropdownState> emit,
|
||||||
|
) {
|
||||||
|
emit(SpaceTreeDropdownState(selectedSpaceId: event.initialId));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
part of 'space_tree_dropdown_bloc.dart';
|
||||||
|
|
||||||
|
abstract class SpaceTreeDropdownEvent {}
|
||||||
|
|
||||||
|
class SpaceTreeDropdownSelectEvent extends SpaceTreeDropdownEvent {
|
||||||
|
final String? spaceId;
|
||||||
|
|
||||||
|
SpaceTreeDropdownSelectEvent(this.spaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SpaceTreeDropdownResetEvent extends SpaceTreeDropdownEvent {
|
||||||
|
final String? initialId;
|
||||||
|
|
||||||
|
SpaceTreeDropdownResetEvent(this.initialId);
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
part of 'space_tree_dropdown_bloc.dart';
|
||||||
|
|
||||||
|
class SpaceTreeDropdownState {
|
||||||
|
final String? selectedSpaceId;
|
||||||
|
|
||||||
|
SpaceTreeDropdownState({this.selectedSpaceId});
|
||||||
|
}
|
@ -171,4 +171,13 @@ extension SpaceExtensions on SpaceModel {
|
|||||||
|
|
||||||
return tagValues;
|
return tagValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNoChangesSubmited(String name, icon, SpaceTemplateModel? spaceModel,
|
||||||
|
List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||||
|
return (name == this.name &&
|
||||||
|
icon == this.icon &&
|
||||||
|
spaceModel == this.spaceModel &&
|
||||||
|
subspaces == this.subspaces &&
|
||||||
|
tags == this.tags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
SpaceTemplateModel? spaceModel,
|
SpaceTemplateModel? spaceModel,
|
||||||
List<SubspaceModel>? subspaces,
|
List<SubspaceModel>? subspaces,
|
||||||
List<Tag>? tags) {
|
List<Tag>? tags) {
|
||||||
|
if (widget.selectedSpace!.isNoChangesSubmited(
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
spaceModel,
|
||||||
|
subspaces,
|
||||||
|
tags,
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
// Update the space's properties
|
// Update the space's properties
|
||||||
widget.selectedSpace!.name = name;
|
widget.selectedSpace!.name = name;
|
||||||
|
@ -302,13 +302,6 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
? enteredName
|
? enteredName
|
||||||
: (widget.name ?? '');
|
: (widget.name ?? '');
|
||||||
if (newName.isNotEmpty) {
|
if (newName.isNotEmpty) {
|
||||||
if (tags != null && tags!.isNotEmpty) {
|
|
||||||
if (tags!.any(
|
|
||||||
(tag) => tag.uuid == null || tag.uuid!.isEmpty,
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
widget.onCreateSpace(
|
widget.onCreateSpace(
|
||||||
newName,
|
newName,
|
||||||
selectedIcon,
|
selectedIcon,
|
||||||
|
@ -30,7 +30,10 @@ class CenterBodyWidget extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: state is CommunityStructureState ||
|
||||||
|
state is CommunitySelectedState
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
context
|
context
|
||||||
.read<CenterBodyBloc>()
|
.read<CenterBodyBloc>()
|
||||||
.add(CommunityStructureSelectedEvent());
|
.add(CommunityStructureSelectedEvent());
|
||||||
|
@ -15,7 +15,7 @@ import shared_preferences_foundation
|
|||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin"))
|
FirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FirebaseAnalyticsPlugin"))
|
||||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||||
FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin"))
|
FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin"))
|
||||||
FLTFirebaseDatabasePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseDatabasePlugin"))
|
FLTFirebaseDatabasePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseDatabasePlugin"))
|
||||||
|
@ -69,12 +69,7 @@ dev_dependencies:
|
|||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
very_good_analysis: ^9.0.0
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
|
||||||
# package. See that file for information about deactivating specific lint
|
|
||||||
# rules and activating additional ones.
|
|
||||||
flutter_lints: ^5.0.0
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
Reference in New Issue
Block a user