mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 07:38:05 +00:00
Compare commits
17 Commits
feat/updat
...
bugfix/emp
Author | SHA1 | Date | |
---|---|---|---|
de65f79ccf | |||
eb0490fb16 | |||
a73fc04712 | |||
dee07ebb06 | |||
5237f3ae5b | |||
e017633b9b | |||
e8e5e9bcb7 | |||
a1d15c9cea | |||
16c006e7a9 | |||
24280549ec | |||
8359642a1a | |||
ada19a5992 | |||
c6702d4d5f | |||
f78e2e2d36 | |||
83b9555920 | |||
8af24e575c | |||
4301d7f62f |
@ -101,7 +101,7 @@ class CustomExpansionTileState extends State<CustomExpansionTile> {
|
||||
widget.children != null &&
|
||||
widget.children!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0), // Indented children
|
||||
padding: const EdgeInsets.only(left: 24.0), // Indented children
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: widget.children!,
|
||||
|
@ -83,7 +83,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
||||
),
|
||||
if (isExpanded && children != null && children!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0),
|
||||
padding: const EdgeInsets.only(left: 24.0),
|
||||
child: Column(
|
||||
children: children ?? [],
|
||||
),
|
||||
|
@ -52,14 +52,24 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
||||
|
||||
Future<void> _updateSpaceModelCache(
|
||||
UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async {
|
||||
if (_cachedSpaceModels != null) {
|
||||
_cachedSpaceModels = _cachedSpaceModels!.map((model) {
|
||||
return model.uuid == event.updatedModel.uuid ? event.updatedModel : model;
|
||||
}).toList();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<SpaceTemplateModel> allSpaceModels = [];
|
||||
|
||||
bool hasNext = true;
|
||||
int page = 1;
|
||||
|
||||
while (hasNext) {
|
||||
final spaceModels = await _spaceModelApi.listSpaceModels(page: page, projectId: projectUuid);
|
||||
if (spaceModels.isNotEmpty) {
|
||||
allSpaceModels.addAll(spaceModels);
|
||||
page++;
|
||||
} else {
|
||||
_cachedSpaceModels = await fetchSpaceModels();
|
||||
hasNext = false;
|
||||
}
|
||||
}
|
||||
|
||||
_cachedSpaceModels = allSpaceModels;
|
||||
await fetchTags();
|
||||
|
||||
emit(SpaceModelLoaded(
|
||||
|
@ -22,7 +22,7 @@ class CommunityTile extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CustomExpansionTile(
|
||||
title: title,
|
||||
initiallyExpanded: isExpanded,
|
||||
|
@ -1,5 +1,6 @@
|
||||
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/view/space_tree_view.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
@ -80,15 +81,15 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
widget.shouldNavigateToSpaceModelPage
|
||||
? _spaceModels.isNotEmpty
|
||||
? Row(
|
||||
children: [
|
||||
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (context) => SpaceModelBloc(
|
||||
BlocProvider.of<SpaceTreeBloc>(context),
|
||||
api: SpaceModelManagementApi(),
|
||||
initialSpaceModels: _spaceModels,
|
||||
initialSpaceModels: widget.spaceModels ?? [],
|
||||
),
|
||||
child: SpaceModelPage(
|
||||
products: widget.products,
|
||||
@ -99,13 +100,13 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: const Center(child: CircularProgressIndicator())
|
||||
: Row(
|
||||
children: [
|
||||
SidebarWidget(
|
||||
communities: widget.communities,
|
||||
selectedSpaceUuid:
|
||||
widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '',
|
||||
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
||||
widget.selectedCommunity?.uuid ??
|
||||
'',
|
||||
),
|
||||
CommunityStructureArea(
|
||||
selectedCommunity: widget.selectedCommunity,
|
||||
|
@ -205,9 +205,11 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community) {
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) {
|
||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
||||
return SpaceTile(
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: depth * 16.0),
|
||||
child: SpaceTile(
|
||||
title: space.name,
|
||||
key: ValueKey(space.uuid),
|
||||
isSelected: _selectedId == space.uuid,
|
||||
@ -228,7 +230,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
children: space.children.isNotEmpty
|
||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
||||
: [], // Recursively render child spaces if available
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
void _handleExpansionChange(String uuid, bool expanded) {}
|
||||
|
@ -35,7 +35,9 @@ class _SpaceTileState extends State<SpaceTile> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomExpansionTile(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0),
|
||||
child: CustomExpansionTile(
|
||||
isSelected: widget.isSelected,
|
||||
title: widget.title,
|
||||
initiallyExpanded: _isExpanded,
|
||||
@ -47,6 +49,6 @@ class _SpaceTileState extends State<SpaceTile> {
|
||||
widget.onExpansionChanged(expanded);
|
||||
},
|
||||
children: widget.children ?? [],
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ abstract class LinkSpaceToModelState {
|
||||
class SpaceModelInitial extends LinkSpaceToModelState {}
|
||||
|
||||
class SpaceModelLoading extends LinkSpaceToModelState {}
|
||||
class LinkSpaceModelLoading extends LinkSpaceToModelState {}
|
||||
|
||||
|
||||
class SpaceModelSelectedState extends LinkSpaceToModelState {
|
||||
final int selectedIndex;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.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/spaces_management/space_model/bloc/space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
@ -9,8 +9,10 @@ import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||
|
||||
class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
final SpaceModelManagementApi api;
|
||||
final SpaceTreeBloc _spaceTreeBloc;
|
||||
|
||||
SpaceModelBloc({
|
||||
SpaceModelBloc(
|
||||
this._spaceTreeBloc, {
|
||||
required this.api,
|
||||
required List<SpaceTemplateModel> initialSpaceModels,
|
||||
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
||||
@ -50,6 +52,7 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
final updatedSpaceModels = currentState.spaceModels.map((model) {
|
||||
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
|
||||
}).toList();
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||
}
|
||||
} catch (e) {
|
||||
@ -71,7 +74,7 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
final updatedSpaceModels = currentState.spaceModels
|
||||
.where((model) => model.uuid != event.spaceModelUuid)
|
||||
.toList();
|
||||
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -11,7 +11,7 @@ class SpaceTemplateModel extends Equatable {
|
||||
List<SubspaceTemplateModel>? subspaceModels;
|
||||
final List<Tag>? tags;
|
||||
String internalId;
|
||||
String? createdAt;
|
||||
DateTime? createdAt;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [modelName, subspaceModels, tags];
|
||||
@ -24,17 +24,18 @@ class SpaceTemplateModel extends Equatable {
|
||||
this.tags,
|
||||
this.createdAt,
|
||||
}) : internalId = internalId ?? const Uuid().v4();
|
||||
|
||||
factory SpaceTemplateModel.fromJson(Map<String, dynamic> json) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
|
||||
return SpaceTemplateModel(
|
||||
uuid: json['uuid'] ?? '',
|
||||
createdAt: json['createdAt'] ?? '',
|
||||
createdAt: json['createdAt'] != null
|
||||
? DateTime.tryParse(json['createdAt'])
|
||||
: null,
|
||||
internalId: internalId,
|
||||
modelName: json['modelName'] ?? '',
|
||||
subspaceModels: (json['subspaceModels'] as List<dynamic>?)
|
||||
?.where((e) => e is Map<String, dynamic>) // Validate type
|
||||
?.where((e) => e is Map<String, dynamic>)
|
||||
.map((e) =>
|
||||
SubspaceTemplateModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_event.dart';
|
||||
@ -45,6 +46,12 @@ class _LinkSpaceModelSpacesDialogState
|
||||
}
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
widget.spaceModel.createdAt.toString();
|
||||
String formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
|
||||
String formattedTime =
|
||||
DateFormat('HH:mm:ss').format(widget.spaceModel.createdAt!);
|
||||
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
@ -75,8 +82,31 @@ class _LinkSpaceModelSpacesDialogState
|
||||
const SizedBox(height: 16),
|
||||
_buildDetailRow(
|
||||
"Space model name:", widget.spaceModel.modelName),
|
||||
_buildDetailRow("Creation date and time:",
|
||||
widget.spaceModel.createdAt.toString()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
"Creation date and time:",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"$formattedDate $formattedTime",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// _buildDetailRow("Creation date and time:",
|
||||
// widget.spaceModel.createdAt.toString()),
|
||||
_buildDetailRow("Created by:", "Admin"),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
|
@ -85,6 +85,7 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (!topActionsDisabled)
|
||||
Row(
|
||||
children: [
|
||||
InkWell(
|
||||
@ -96,6 +97,9 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
create: (_) => LinkSpaceToModelBloc(),
|
||||
child: BlocListener<LinkSpaceToModelBloc,
|
||||
LinkSpaceToModelState>(
|
||||
listenWhen: (previous, current) {
|
||||
return previous != current;
|
||||
},
|
||||
listener: (context, state) {
|
||||
final _bloc =
|
||||
BlocProvider.of<LinkSpaceToModelBloc>(
|
||||
@ -108,7 +112,8 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(20)),
|
||||
BorderRadius.circular(
|
||||
20)),
|
||||
elevation: 10,
|
||||
backgroundColor: Colors.white,
|
||||
child: Padding(
|
||||
@ -117,19 +122,10 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
vertical: 30,
|
||||
horizontal: 50),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize:
|
||||
MainAxisSize.min,
|
||||
children: [
|
||||
CustomLoadingIndicator(),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"Linking in progress",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -147,8 +143,8 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
isOverWrite: false,
|
||||
selectedSpaceMode: model.uuid));
|
||||
|
||||
Future.delayed(const Duration(seconds: 1),
|
||||
() {
|
||||
Future.delayed(
|
||||
const Duration(seconds: 1), () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
@ -156,7 +152,8 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
builder:
|
||||
(BuildContext dialogContext) {
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
).then((v) {
|
||||
@ -165,12 +162,21 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
Navigator.of(dialogContext).pop();
|
||||
});
|
||||
});
|
||||
} else if (state is SpaceModelLinkSuccess) {
|
||||
} else if (state
|
||||
is SpaceModelLinkSuccess) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext
|
||||
successDialogContext) {
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2), () {
|
||||
Navigator.of(successDialogContext)
|
||||
.pop();
|
||||
});
|
||||
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
);
|
||||
@ -189,7 +195,6 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
if (!topActionsDisabled)
|
||||
InkWell(
|
||||
onTap: () {
|
||||
_showDeleteDialog(context);
|
||||
@ -201,47 +206,6 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// model.modelName,
|
||||
// style:
|
||||
// Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
// color: Colors.black,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// if (!topActionsDisabled)
|
||||
// GestureDetector(
|
||||
// onTap: () => _showDeleteDialog(context),
|
||||
// child: Container(
|
||||
// width: 36, // Adjust size as needed
|
||||
// height: 36,
|
||||
// decoration: BoxDecoration(
|
||||
// shape: BoxShape.circle,
|
||||
// color: Colors.white,
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.1),
|
||||
// spreadRadius: 2,
|
||||
// blurRadius: 5,
|
||||
// offset: const Offset(0, 2),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: Center(
|
||||
// child: SvgPicture.asset(
|
||||
// Assets.deleteSpaceModel, // Your actual SVG path
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// colorFilter: const ColorFilter.mode(
|
||||
// Colors.grey, BlendMode.srcIn),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
if (!showOnlyName) ...[
|
||||
|
@ -52,7 +52,7 @@ abstract class ColorsManager {
|
||||
static const Color semiTransparentBlackColor = Color(0x3F000000);
|
||||
static const Color transparentColor = Color(0x00000000);
|
||||
static const Color spaceColor = Color(0xB2023DFE);
|
||||
static const Color counterBackgroundColor = Color.fromARGB(204, 105, 2, 2);
|
||||
static const Color counterBackgroundColor = Color(0xCCF4F4F4);
|
||||
static const Color neutralGray = Color(0xFFE5E5E5);
|
||||
static const Color warningRed = Color(0xFFFF6465);
|
||||
static const Color borderColor = Color(0xFFE5E5E5);
|
||||
|
Reference in New Issue
Block a user