mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 01:02:14 +08:00
@ -52,20 +52,36 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
|||||||
return [
|
return [
|
||||||
const PopupMenuItem<String>(
|
const PopupMenuItem<String>(
|
||||||
child: Text("Rename Folder"),
|
child: Text("Rename Folder"),
|
||||||
value: "Rename Folder",
|
value: "Rename",
|
||||||
|
),
|
||||||
|
const PopupMenuItem<String>(
|
||||||
|
child: Text("Create Sub-Folder"),
|
||||||
|
value: "Create",
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onSelected: (String _) async {
|
onSelected: (String value) async {
|
||||||
var folderName = await showDialog(
|
if (value == "Rename") {
|
||||||
context: context,
|
var folderName = await showDialog(
|
||||||
builder: (_) => RenameFolderDialog(selectedFolder),
|
context: context,
|
||||||
);
|
builder: (_) => RenameFolderDialog(selectedFolder),
|
||||||
if (folderName is String) {
|
);
|
||||||
final container = StateContainer.of(context);
|
if (folderName is String) {
|
||||||
container.renameFolder(selectedFolder, folderName);
|
final container = StateContainer.of(context);
|
||||||
_folderTreeViewKey.currentState.resetSelection();
|
container.renameFolder(selectedFolder, folderName);
|
||||||
|
}
|
||||||
|
} else if (value == "Create") {
|
||||||
|
var folderName = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => CreateFolderAlertDialog(),
|
||||||
|
);
|
||||||
|
if (folderName is String) {
|
||||||
|
final container = StateContainer.of(context);
|
||||||
|
container.createFolder(selectedFolder, folderName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_folderTreeViewKey.currentState.resetSelection();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -97,21 +113,16 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreateFolderButton extends StatefulWidget {
|
class CreateFolderButton extends StatelessWidget {
|
||||||
@override
|
|
||||||
_CreateFolderButtonState createState() => _CreateFolderButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CreateFolderButtonState extends State<CreateFolderButton> {
|
|
||||||
final TextEditingController _textController = TextEditingController();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
key: const ValueKey("FAB"),
|
key: const ValueKey("FAB"),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var folderName =
|
var folderName = await showDialog(
|
||||||
await showDialog(context: context, builder: _buildAlert);
|
context: context,
|
||||||
|
builder: (_) => CreateFolderAlertDialog(),
|
||||||
|
);
|
||||||
if (folderName is String) {
|
if (folderName is String) {
|
||||||
final container = StateContainer.of(context);
|
final container = StateContainer.of(context);
|
||||||
final notesFolder = Provider.of<NotesFolder>(context);
|
final notesFolder = Provider.of<NotesFolder>(context);
|
||||||
@ -122,14 +133,19 @@ class _CreateFolderButtonState extends State<CreateFolderButton> {
|
|||||||
child: Icon(Icons.add),
|
child: Icon(Icons.add),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CreateFolderAlertDialog extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_CreateFolderAlertDialogState createState() =>
|
||||||
|
_CreateFolderAlertDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
|
||||||
|
final TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
Widget build(BuildContext context) {
|
||||||
_textController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildAlert(BuildContext context) {
|
|
||||||
var form = Form(
|
var form = Form(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -167,6 +183,12 @@ class _CreateFolderButtonState extends State<CreateFolderButton> {
|
|||||||
content: form,
|
content: form,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenameFolderDialog extends StatefulWidget {
|
class RenameFolderDialog extends StatefulWidget {
|
||||||
|
Reference in New Issue
Block a user