Skip to content

Commit

Permalink
create WorkspaceView
Browse files Browse the repository at this point in the history
Through this enum we can change the way files are displayed
  • Loading branch information
chesnoksatan committed Jul 16, 2022
1 parent a613958 commit fae31db
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lib/widgets/workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

enum WorkspaceView { table, grid }

class FilesWorkspace extends StatefulWidget {
final WorkspaceController controller;
WorkspaceView view;

const FilesWorkspace({
FilesWorkspace({
required this.controller,
this.view = WorkspaceView.table,
Key? key,
}) : super(key: key);

Expand All @@ -36,6 +40,17 @@ class _FilesWorkspaceState extends State<FilesWorkspace> {

String folderName = ' ';

IconData get viewIcon {
switch (widget.view) {
case WorkspaceView.table:
return Icons.list_outlined;
case WorkspaceView.grid:
return Icons.grid_view_outlined;
default:
return Icons.list_outlined;
}
}

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -119,6 +134,28 @@ class _FilesWorkspaceState extends State<FilesWorkspace> {
),
],
actions: [
IconButton(
icon: Icon(
viewIcon,
size: 18,
color: Colors.white,
),
onPressed: () {
setState(() {
switch (widget.view) {
case WorkspaceView.table:
widget.view = WorkspaceView.grid;
break;
case WorkspaceView.grid:
widget.view = WorkspaceView.table;
break;
default:
break;
}
});
},
splashRadius: 16,
),
PopupMenuButton<String>(
splashRadius: 16,
color: Theme.of(context).colorScheme.surface,
Expand Down

0 comments on commit fae31db

Please sign in to comment.