|
1 | 1 | import 'package:cookethflow/core/helpers/date_time_helper.dart'; |
| 2 | +import 'package:cookethflow/core/router/app_route_const.dart'; |
2 | 3 | import 'package:cookethflow/features/dashboard/providers/dashboard_provider.dart'; |
| 4 | +import 'package:cookethflow/features/workspace/pages/workspace.dart'; |
| 5 | +import 'package:cookethflow/features/workspace/providers/workspace_provider.dart'; |
3 | 6 | import 'package:flutter/material.dart'; |
4 | 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 8 | +import 'package:go_router/go_router.dart'; |
5 | 9 | import 'package:phosphor_flutter/phosphor_flutter.dart'; |
6 | 10 | import 'package:provider/provider.dart'; |
7 | 11 |
|
8 | 12 | class ProjectCard extends StatelessWidget { |
9 | | - const ProjectCard({super.key, required this.idx}); |
10 | | - final int idx; |
| 13 | + const ProjectCard({super.key, required this.workspaceId}); |
| 14 | + final String workspaceId; |
11 | 15 |
|
12 | 16 | @override |
13 | 17 | Widget build(BuildContext context) { |
14 | 18 | DateTimeHelper dth = DateTimeHelper(); |
15 | | - return Consumer<DashboardProvider>( |
16 | | - builder: (context, provider, child) { |
17 | | - return Container( |
18 | | - decoration: BoxDecoration( |
19 | | - color: Colors.white, |
20 | | - borderRadius: BorderRadius.circular(12.r), |
21 | | - border: Border.all(color: const Color(0xFFD9D9D9), width: 1.2), |
22 | | - ), |
23 | | - child: Column( |
24 | | - crossAxisAlignment: CrossAxisAlignment.stretch, |
25 | | - children: [ |
26 | | - Expanded( |
27 | | - flex: 2, |
28 | | - child: Container( |
29 | | - decoration: BoxDecoration( |
30 | | - color: const Color(0xFFD3D3D3), |
31 | | - borderRadius: BorderRadius.only( |
32 | | - topLeft: Radius.circular(12.r), |
33 | | - topRight: Radius.circular(12.r), |
| 19 | + return Consumer2<DashboardProvider, WorkspaceProvider>( |
| 20 | + builder: (context, provider, workspaceProvider, child) { |
| 21 | + return GestureDetector( |
| 22 | + onTap: () { |
| 23 | + workspaceProvider.setWorkspace(workspaceId); |
| 24 | + context.goNamed(RouteName.workspace,pathParameters: {'workspace_id':workspaceId}); |
| 25 | + }, |
| 26 | + child: Container( |
| 27 | + decoration: BoxDecoration( |
| 28 | + color: Colors.white, |
| 29 | + borderRadius: BorderRadius.circular(12.r), |
| 30 | + border: Border.all(color: const Color(0xFFD9D9D9), width: 1.2), |
| 31 | + ), |
| 32 | + child: Column( |
| 33 | + crossAxisAlignment: CrossAxisAlignment.stretch, |
| 34 | + children: [ |
| 35 | + Expanded( |
| 36 | + flex: 2, |
| 37 | + child: Container( |
| 38 | + decoration: BoxDecoration( |
| 39 | + color: const Color(0xFFD3D3D3), |
| 40 | + borderRadius: BorderRadius.only( |
| 41 | + topLeft: Radius.circular(12.r), |
| 42 | + topRight: Radius.circular(12.r), |
| 43 | + ), |
34 | 44 | ), |
35 | | - ), |
36 | | - child: Stack( |
37 | | - children: [ |
38 | | - // Center( |
39 | | - // child: Image.asset( |
40 | | - // 'assets/images/Frame 400.png', |
41 | | - // fit: BoxFit.cover, |
42 | | - // ), |
43 | | - // ), |
44 | | - Positioned( |
45 | | - top: 12.h, |
46 | | - right: 12.w, |
47 | | - child: Container( |
48 | | - padding: EdgeInsets.all(8.w), |
49 | | - decoration: BoxDecoration( |
50 | | - color: Colors.white, |
51 | | - borderRadius: BorderRadius.circular(12.r), |
52 | | - ), |
53 | | - child: IconButton( |
54 | | - onPressed: () {}, |
55 | | - icon: Icon( |
56 | | - PhosphorIconsRegular.dotsThree, |
57 | | - size: 32.sp, |
58 | | - color: Colors.black, |
| 45 | + child: Stack( |
| 46 | + children: [ |
| 47 | + // Center( |
| 48 | + // child: Image.asset( |
| 49 | + // 'assets/images/Frame 400.png', |
| 50 | + // fit: BoxFit.cover, |
| 51 | + // ), |
| 52 | + // ), |
| 53 | + Positioned( |
| 54 | + top: 12.h, |
| 55 | + right: 12.w, |
| 56 | + child: Container( |
| 57 | + padding: EdgeInsets.all(8.w), |
| 58 | + decoration: BoxDecoration( |
| 59 | + color: Colors.white, |
| 60 | + borderRadius: BorderRadius.circular(12.r), |
| 61 | + ), |
| 62 | + child: IconButton( |
| 63 | + onPressed: () {}, |
| 64 | + icon: Icon( |
| 65 | + PhosphorIconsRegular.dotsThree, |
| 66 | + size: 32.sp, |
| 67 | + color: Colors.black, |
| 68 | + ), |
59 | 69 | ), |
60 | 70 | ), |
61 | 71 | ), |
62 | | - ), |
63 | | - ], |
| 72 | + ], |
| 73 | + ), |
64 | 74 | ), |
65 | 75 | ), |
66 | | - ), |
67 | | - Expanded( |
68 | | - flex: 1, |
69 | | - child: Padding( |
70 | | - padding: EdgeInsets.symmetric(horizontal: 24, vertical: 16), |
71 | | - child: Row( |
72 | | - crossAxisAlignment: CrossAxisAlignment.start, |
73 | | - children: [ |
74 | | - Expanded( |
75 | | - child: Column( |
76 | | - crossAxisAlignment: CrossAxisAlignment.start, |
77 | | - mainAxisAlignment: MainAxisAlignment.center, |
78 | | - children: [ |
79 | | - Text( |
80 | | - provider.workspaceList[idx].name ?? |
81 | | - "Name not fetched", |
82 | | - style: TextStyle( |
83 | | - fontFamily: 'Fredrik', |
84 | | - fontSize: 20.sp, |
85 | | - color: Colors.black, |
86 | | - fontWeight: FontWeight.w600, |
87 | | - ), |
88 | | - ), |
89 | | - SizedBox(height: 4.h), |
90 | | - Text( |
91 | | - dth.formatLastEdited( |
92 | | - provider.workspaceList[idx].lastEdited, |
| 76 | + Expanded( |
| 77 | + flex: 1, |
| 78 | + child: Padding( |
| 79 | + padding: EdgeInsets.symmetric(horizontal: 24, vertical: 16), |
| 80 | + child: Row( |
| 81 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 82 | + children: [ |
| 83 | + Expanded( |
| 84 | + child: Column( |
| 85 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 86 | + mainAxisAlignment: MainAxisAlignment.center, |
| 87 | + children: [ |
| 88 | + Text( |
| 89 | + provider.workspaceList[workspaceId]?.name ?? |
| 90 | + "Name not fetched", |
| 91 | + style: TextStyle( |
| 92 | + fontFamily: 'Fredrik', |
| 93 | + fontSize: 20.sp, |
| 94 | + color: Colors.black, |
| 95 | + fontWeight: FontWeight.w600, |
| 96 | + ), |
93 | 97 | ), |
94 | | - style: TextStyle( |
95 | | - fontFamily: 'Fredrik', |
96 | | - color: Colors.grey[600], |
97 | | - fontSize: 14.sp, |
98 | | - fontWeight: FontWeight.w500, |
| 98 | + SizedBox(height: 4.h), |
| 99 | + Text( |
| 100 | + dth.formatLastEdited( |
| 101 | + provider |
| 102 | + .workspaceList[workspaceId] |
| 103 | + ?.lastEdited, |
| 104 | + ), |
| 105 | + style: TextStyle( |
| 106 | + fontFamily: 'Fredrik', |
| 107 | + color: Colors.grey[600], |
| 108 | + fontSize: 14.sp, |
| 109 | + fontWeight: FontWeight.w500, |
| 110 | + ), |
99 | 111 | ), |
100 | | - ), |
101 | | - ], |
| 112 | + ], |
| 113 | + ), |
102 | 114 | ), |
103 | | - ), |
104 | | - IconButton( |
105 | | - onPressed: () {}, |
106 | | - icon: Icon( |
107 | | - PhosphorIconsRegular.star, |
108 | | - size: 32.sp, |
109 | | - color: Colors.black54, |
| 115 | + IconButton( |
| 116 | + onPressed: () {}, |
| 117 | + icon: Icon( |
| 118 | + PhosphorIconsRegular.star, |
| 119 | + size: 32.sp, |
| 120 | + color: Colors.black54, |
| 121 | + ), |
110 | 122 | ), |
111 | | - ), |
112 | | - ], |
| 123 | + ], |
| 124 | + ), |
113 | 125 | ), |
114 | 126 | ), |
115 | | - ), |
116 | | - ], |
| 127 | + ], |
| 128 | + ), |
117 | 129 | ), |
118 | 130 | ); |
119 | 131 | }, |
|
0 commit comments