mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Removed community view
This commit is contained in:
@ -1,132 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
||||
|
||||
class CommunityListViewWidget extends StatelessWidget {
|
||||
final List<CommunityModel> communities;
|
||||
final Function(CommunityModel?) onCommunitySelected;
|
||||
|
||||
const CommunityListViewWidget({
|
||||
super.key,
|
||||
required this.communities,
|
||||
required this.onCommunitySelected,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
// Increase the item count by 1 to include the blank community
|
||||
return Expanded(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3, // Three containers per row
|
||||
crossAxisSpacing: size.height * 0.041,
|
||||
mainAxisSpacing: size.width * 0.015,
|
||||
childAspectRatio: 361 / 239, // Aspect ratio based on container size
|
||||
),
|
||||
itemCount: communities.length +
|
||||
1, // One additional item for the blank community
|
||||
itemBuilder: (context, index) {
|
||||
// If the index is 0, display the blank community, otherwise display the normal ones
|
||||
if (index == 0) {
|
||||
return GestureDetector(
|
||||
onTap: () =>
|
||||
onCommunitySelected(null), // Pass null for blank community
|
||||
child: _buildBlankCommunityCard(size),
|
||||
);
|
||||
} else {
|
||||
return GestureDetector(
|
||||
onTap: () => onCommunitySelected(
|
||||
communities[index - 1]), // Trigger callback when tapped
|
||||
child: _buildCommunityCard(communities[index - 1], size),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Build the blank community container
|
||||
Widget _buildBlankCommunityCard(Size size) {
|
||||
return SizedBox(
|
||||
width: size.width * .18,
|
||||
height: size.height * .22,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Inner blank container with white background and border
|
||||
Container(
|
||||
width: size.width * .18,
|
||||
height: size.height * .16,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 5,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
size.height * 0.02), // Add spacing between container and text
|
||||
// Text saying "Blank" for the blank community
|
||||
const Text(
|
||||
'Blank',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18,
|
||||
fontFamily: 'Aftika',
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Build a single community container based on the format provided
|
||||
Widget _buildCommunityCard(CommunityModel community, Size size) {
|
||||
return SizedBox(
|
||||
width: size.width * .18,
|
||||
height: size.height * .22,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Inner container with white background and border
|
||||
Container(
|
||||
width: size.width * .18,
|
||||
height: size.height * .16,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 5,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
size.height * 0.02), // Add spacing between container and text
|
||||
// Community name text
|
||||
Text(
|
||||
community.name ?? 'Blank', // Display community name
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18,
|
||||
fontFamily: 'Aftika',
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.
|
||||
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/view/community_list_view.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/view/curved_line_painter.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_space_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/widgets/gradient_canvas_border_widget.dart';
|
||||
@ -30,7 +29,6 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
List<Connection> connections = [];
|
||||
|
||||
// Track whether to show the community list view or community structure
|
||||
bool showCommunityStructure = false;
|
||||
|
||||
// Selected community
|
||||
CommunityModel? selectedCommunity;
|
||||
@ -84,19 +82,13 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
children: [
|
||||
SidebarWidget(
|
||||
communities: communities,
|
||||
onCommunitySelected: (community) {},
|
||||
onCommunitySelected: (community) {
|
||||
setState(() {
|
||||
selectedCommunity = community; // Set the selected community
|
||||
});
|
||||
},
|
||||
),
|
||||
showCommunityStructure
|
||||
? _buildCommunityStructureArea(context, screenSize)
|
||||
: CommunityListViewWidget(
|
||||
communities: communities,
|
||||
onCommunitySelected: (community) {
|
||||
setState(() {
|
||||
selectedCommunity = community;
|
||||
showCommunityStructure = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
_buildCommunityStructureArea(context, screenSize)
|
||||
],
|
||||
),
|
||||
const GradientCanvasBorderWidget()
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_type_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/widgets/counter_widget.dart';
|
||||
|
@ -14,10 +14,11 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class SidebarWidget extends StatefulWidget {
|
||||
final Function(String)? onCommunitySelected;
|
||||
final Function(CommunityModel)? onCommunitySelected;
|
||||
final List<CommunityModel> communities;
|
||||
|
||||
const SidebarWidget({super.key, this.onCommunitySelected, required this.communities});
|
||||
const SidebarWidget(
|
||||
{super.key, this.onCommunitySelected, required this.communities});
|
||||
|
||||
@override
|
||||
_SidebarWidgetState createState() => _SidebarWidgetState();
|
||||
@ -185,6 +186,9 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
debugPrint(
|
||||
'CommunityTile onExpansionChanged called for $title, expanded: $expanded');
|
||||
_handleExpansionChange(community.uuid, expanded);
|
||||
if (widget.onCommunitySelected != null) {
|
||||
widget.onCommunitySelected!(community); // Pass the entire community
|
||||
}
|
||||
},
|
||||
children: hasChildren
|
||||
? community.spaces.map((space) => _buildSpaceTile(space)).toList()
|
||||
|
Reference in New Issue
Block a user