Skip to content

Commit edf7795

Browse files
committed
feat: other dashboard tabs
1 parent f459835 commit edf7795

File tree

2 files changed

+76
-30
lines changed

2 files changed

+76
-30
lines changed

lib/features/dashboard/pages/desktop/dashboard_desktop.dart

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ class DashboardDesktop extends StatelessWidget {
1717
rh.DeviceType deviceType = rh.ResponsiveLayoutHelper.getDeviceType(context);
1818
return Consumer<DashboardProvider>(
1919
builder: (context, provider, child) {
20-
// NEW: Get the filtered list of workspaces
21-
final displayedWorkspaces = provider.displayedWorkspaces;
22-
2320
return LayoutBuilder(
2421
builder:
2522
(context, constraints) => Row(
2623
crossAxisAlignment: CrossAxisAlignment.start,
2724
children: [
2825
AnimatedContainer(
2926
curve: Curves.easeInOut,
30-
duration: Duration(milliseconds: 500),
27+
duration: const Duration(milliseconds: 500),
3128
height:
3229
provider.isDrawerOpen
3330
? constraints.maxHeight
3431
: 0.185.sh,
3532
width: deviceType == rh.DeviceType.desktop ? 400.w : 600.w,
36-
child: DashboardDrawer(),
33+
child: const DashboardDrawer(),
3734
),
3835

3936
Expanded(
@@ -47,27 +44,12 @@ class DashboardDesktop extends StatelessWidget {
4744
children: [
4845
Padding(
4946
padding: EdgeInsets.only(bottom: 20.h),
50-
child: StartProject(),
47+
child: const StartProject(),
5148
),
52-
SizedBox(height: 32),
49+
const SizedBox(height: 32),
5350
Expanded(
54-
child: GridView.builder(
55-
shrinkWrap: true,
56-
// UPDATE: Use the length of the filtered list
57-
itemCount: displayedWorkspaces.length,
58-
gridDelegate:
59-
SliverGridDelegateWithFixedCrossAxisCount(
60-
crossAxisCount: 3,
61-
crossAxisSpacing: 20.w,
62-
mainAxisSpacing: 20.h,
63-
childAspectRatio: 4.5 / 3,
64-
),
65-
itemBuilder: (context, index) {
66-
// UPDATE: Get the workspace from the filtered list
67-
final workspace = displayedWorkspaces[index];
68-
return ProjectCard(workspaceId: workspace.id);
69-
},
70-
),
51+
// NEW: Conditionally build the main content area
52+
child: _buildMainContent(provider),
7153
),
7254
],
7355
),
@@ -79,4 +61,69 @@ class DashboardDesktop extends StatelessWidget {
7961
},
8062
);
8163
}
64+
65+
// NEW: Helper widget to build content based on the selected tab
66+
Widget _buildMainContent(DashboardProvider provider) {
67+
switch (provider.tabIndex) {
68+
case 2: // Trash Tab
69+
return Center(
70+
child: Text(
71+
'Feature Coming Soon',
72+
style: TextStyle(
73+
fontFamily: 'Fredrik',
74+
fontSize: 24.sp,
75+
fontWeight: FontWeight.w600,
76+
color: Colors.grey[600],
77+
),
78+
),
79+
);
80+
case 3: // About Us Tab
81+
return SingleChildScrollView(
82+
padding: EdgeInsets.symmetric(horizontal: 40.w, vertical: 20.h),
83+
child: Text(
84+
"Cooketh Flow is an open-source, powerful visual thinking tool designed for teams and individuals to brainstorm, sketch, and organize ideas effortlessly. Whether you're mapping out ideas, designing user flows, or organizing tasks, Cooketh Flow provides an intuitive drag-and-drop interface that makes building and refining workflows effortless.\n\nWith features like customizable nodes and cloud sync with Supabase, Cooketh Flow is built to streamline complex processes and enhance productivity. Developed with Flutter for cross-platform support, it offers a fast, responsive, and visually engaging experience.\n\nAs an open-source project, Cooketh Flow is community-driven and extensible, inviting developers and creators to contribute, innovate, and shape the future of workflow automation.",
85+
textAlign: TextAlign.justify,
86+
style: TextStyle(
87+
fontFamily: 'Fredrik',
88+
fontSize: 18.sp,
89+
height: 1.6,
90+
color: Colors.black.withOpacity(0.75),
91+
),
92+
),
93+
);
94+
default: // All and Starred Tabs
95+
final displayedWorkspaces = provider.displayedWorkspaces;
96+
97+
// Show a message if the "Starred" tab is empty
98+
if (displayedWorkspaces.isEmpty && provider.tabIndex == 1) {
99+
return Center(
100+
child: Text(
101+
'No starred workspaces yet!',
102+
style: TextStyle(
103+
fontFamily: 'Fredrik',
104+
fontSize: 24.sp,
105+
fontWeight: FontWeight.w600,
106+
color: Colors.grey[600],
107+
),
108+
),
109+
);
110+
}
111+
112+
return GridView.builder(
113+
shrinkWrap: true,
114+
itemCount: displayedWorkspaces.length,
115+
gridDelegate:
116+
SliverGridDelegateWithFixedCrossAxisCount(
117+
crossAxisCount: 3,
118+
crossAxisSpacing: 20.w,
119+
mainAxisSpacing: 20.h,
120+
childAspectRatio: 4.5 / 3,
121+
),
122+
itemBuilder: (context, index) {
123+
final workspace = displayedWorkspaces[index];
124+
return ProjectCard(workspaceId: workspace.id);
125+
},
126+
);
127+
}
128+
}
82129
}

lib/features/dashboard/providers/dashboard_provider.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ class DashboardProvider extends StateHandler {
2727
bool get isInitialized => _isInitialized;
2828
Map<String, WorkspaceModel> get workspaceList => _workspaceList;
2929

30-
// NEW: Getter for the filtered list of workspaces
3130
List<WorkspaceModel> get displayedWorkspaces {
3231
final allWorkspaces = _workspaceList.values.toList();
33-
// Sort by last edited date, newest first
3432
allWorkspaces.sort((a, b) => (b.lastEdited ?? DateTime(0)).compareTo(a.lastEdited ?? DateTime(0)));
3533

3634
switch (_tabIndex) {
3735
case 1: // Starred
3836
return allWorkspaces.where((ws) => ws.isStarred).toList();
37+
case 2: // Trash
38+
case 3: // About Us
39+
// Return an empty list for non-project tabs
40+
return [];
3941
case 0: // All
4042
default:
4143
return allWorkspaces;
@@ -122,12 +124,10 @@ class DashboardProvider extends StateHandler {
122124
}
123125
}
124126

125-
// NEW: Method to toggle the star status and save to DB
126127
Future<void> toggleStar(String workspaceId) async {
127128
final workspace = _workspaceList[workspaceId];
128129
if (workspace == null) return;
129130

130-
// Toggle status locally first for immediate UI feedback
131131
final updatedWorkspace = workspace.copyWith(isStarred: !workspace.isStarred);
132132
_workspaceList[workspaceId] = updatedWorkspace;
133133
notifyListeners();
@@ -141,7 +141,6 @@ class DashboardProvider extends StateHandler {
141141
print("Workspace $workspaceId star status updated in DB.");
142142
} catch (e) {
143143
print("Error updating star status for $workspaceId: $e");
144-
// Revert on error
145144
_workspaceList[workspaceId] = workspace;
146145
notifyListeners();
147146
}
@@ -163,7 +162,7 @@ class DashboardProvider extends StateHandler {
163162
"name": "New Project",
164163
"editorId": [],
165164
"viewerId": [],
166-
"data": {'isStarred': false}, // Initialize with isStarred
165+
"data": {'isStarred': false},
167166
};
168167

169168
await supabase!.from('workspace').insert(newWorkspaceData);

0 commit comments

Comments
 (0)