|
| 1 | +import 'dart:ffi'; |
1 | 2 | import 'dart:io'; |
2 | 3 |
|
3 | 4 | import 'package:corecoder_develop/filebrowser/utils/utils.dart'; |
@@ -221,84 +222,39 @@ class _HomePageState extends State<HomePage> { |
221 | 222 |
|
222 | 223 | List<Widget> get projectsWidgetList { |
223 | 224 | var result = <Widget>[]; |
| 225 | + |
| 226 | + /// The create button |
| 227 | + result.add(ProjectItem( |
| 228 | + isListView: isListView, menuButton: null, |
| 229 | + icon: const Icon(Icons.add, size: 48,), |
| 230 | + title: "Create project", subtitle: "", |
| 231 | + onPressed: ()=>showCreateProjectDialog())); |
| 232 | + |
224 | 233 | for (HistoryItem p in RecentProjectsManager.instance.projects) { |
225 | 234 | // if (p.name == "") { |
226 | 235 | // continue; |
227 | 236 | // } // TODO: add better way to check if project is corrupt |
228 | 237 | //debugPrint(p.name); |
229 | | - result.add(Card( |
230 | | - //TODO: refactor this as a widget elsewhere, then reference that widget from here |
231 | | - child: isListView |
232 | | - ? ListTile( |
233 | | - shape: RoundedRectangleBorder( |
234 | | - borderRadius: BorderRadius.circular(4), |
235 | | - side: BorderSide(color: Theme.of(context).dividerColor), |
236 | | - ), |
237 | | - onTap: () => onHistoryItemTap(p), |
238 | | - leading: p.type == HistoryItemType.solution |
239 | | - ? p.solution!.image ?? |
240 | | - const Icon( |
241 | | - Icons.insert_drive_file, |
242 | | - size: 48, |
243 | | - ) |
244 | | - : const Icon( |
245 | | - Icons.insert_drive_file, |
246 | | - size: 48, |
247 | | - ), |
248 | | - title: Text( |
249 | | - p.name, |
250 | | - style: const TextStyle(fontWeight: FontWeight.bold), |
251 | | - ), |
252 | | - subtitle: Text("Last Modified: " + |
253 | | - Utils.getFormattedDateTime(dateTime: p.dateModified)), |
254 | | - trailing: PopupMenuButton<String>( |
255 | | - onSelected: (String result) => |
256 | | - onMenuItemSelected(result, p), |
257 | | - itemBuilder: (BuildContext context) => getPopupMenu(p))) |
258 | | - : SizedBox( |
259 | | - width: 128, |
260 | | - height: 128, |
261 | | - child: OutlinedButton( |
262 | | - onPressed: () => onHistoryItemTap(p), |
263 | | - child: Stack(children: [ |
264 | | - Column( |
265 | | - mainAxisAlignment: MainAxisAlignment.center, |
266 | | - children: [ |
267 | | - p.type == HistoryItemType.solution |
268 | | - ? p.solution!.image ?? |
269 | | - const Icon( |
270 | | - Icons.insert_drive_file, |
271 | | - size: 48, |
272 | | - ) |
273 | | - : const Icon( |
274 | | - Icons.insert_drive_file, |
275 | | - size: 48, |
276 | | - ), |
277 | | - const SizedBox(height: 8,), |
278 | | - Text( |
279 | | - p.name, |
280 | | - style: TextStyle( |
281 | | - color: Theme.of(context) |
282 | | - .textTheme |
283 | | - .bodyText1! |
284 | | - .color!, |
285 | | - fontSize: 12.0), |
286 | | - ), |
287 | | - Text( |
288 | | - Utils.getFormattedDateTime( |
289 | | - dateTime: p.dateModified), |
290 | | - style: TextStyle( |
291 | | - color: Theme.of(context).focusColor, |
292 | | - fontSize: 12.0), |
293 | | - ) |
294 | | - ], |
295 | | - ), |
296 | | - Positioned( |
297 | | - top: 0,right: -16, |
298 | | - child: PopupMenuButton<String>( |
299 | | - onSelected: (String result) => onMenuItemSelected(result, p), |
300 | | - itemBuilder: (BuildContext context) => getPopupMenu(p))) |
301 | | - ]))))); |
| 238 | + result.add(ProjectItem( |
| 239 | + isListView: isListView, |
| 240 | + menuButton: PopupMenuButton<String>( |
| 241 | + onSelected: (String result) => |
| 242 | + onMenuItemSelected(result, p), |
| 243 | + itemBuilder: (BuildContext context) => getPopupMenu(p)), |
| 244 | + icon: p.type == HistoryItemType.solution |
| 245 | + ? p.solution!.image ?? |
| 246 | + const Icon( |
| 247 | + Icons.insert_drive_file, |
| 248 | + size: 48, |
| 249 | + ) |
| 250 | + : const Icon( |
| 251 | + Icons.insert_drive_file, |
| 252 | + size: 48, |
| 253 | + ), |
| 254 | + title: p.name, |
| 255 | + subtitle: "Last Modified: " + |
| 256 | + Utils.getFormattedDateTime(dateTime: p.dateModified), |
| 257 | + onPressed:()=> onHistoryItemTap(p))); |
302 | 258 | } |
303 | 259 | return result; |
304 | 260 | } |
|
0 commit comments