diff --git a/lib/Consts2.dart b/lib/Consts2.dart index 95a7200..354777c 100644 --- a/lib/Consts2.dart +++ b/lib/Consts2.dart @@ -1 +1 @@ -const VERSION = "1.1.012225+0420"; +const VERSION = "1.1.012325+1215"; diff --git a/lib/Editor.dart b/lib/Editor.dart index 42c22cb..c86ad2b 100644 --- a/lib/Editor.dart +++ b/lib/Editor.dart @@ -1,6 +1,7 @@ import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_treeview/flutter_treeview.dart'; import 'package:libac_dart/nbt/NbtIo.dart'; @@ -14,6 +15,7 @@ import 'package:nbteditor/Constants.dart'; import 'package:nbteditor/Consts2.dart'; import 'package:nbteditor/SessionData.dart'; import 'package:nbteditor/main.dart'; +import 'package:nbteditor/pages/EditValue.dart'; import 'package:nbteditor/tags/ArrayEntry.dart'; import 'package:nbteditor/tags/CompoundTag.dart'; import 'package:nbteditor/tags/Tag.dart'; @@ -67,6 +69,21 @@ class EditorState extends State { appBar: AppBar( backgroundColor: Constants.TITLEBAR_COLOR, title: Text("Named Binary Tag Editor${appendCompressed()}"), + actions: [ + IconButton( + onPressed: () async { + // Show input prompt + var searchResponse = await showCupertinoDialog( + context: context, + builder: (dialogBuilder) { + return InputPrompt( + titleText: "What tag name to search for?", + PromptText: + "Enter the tag name you want to search for"); + }); + }, + icon: const Icon(CupertinoIcons.search_circle)) + ], ), drawer: Drawer( backgroundColor: Constants.DRAWER_COLOR, diff --git a/lib/pages/EditValue.dart b/lib/pages/EditValue.dart index 1db4b39..5e3a8fa 100644 --- a/lib/pages/EditValue.dart +++ b/lib/pages/EditValue.dart @@ -2,6 +2,61 @@ import 'package:flutter/material.dart'; import 'package:libac_dart/nbt/Tag.dart'; import 'package:libac_dart/nbt/impl/StringTag.dart'; +class InputPrompt extends StatefulWidget { + String titleText; + String PromptText; + String value; + InputPrompt( + {required this.titleText, + required this.PromptText, + super.key, + this.value = ""}); + + @override + State createState() { + return InputPromptState( + title: Text(titleText), prompt: Text(PromptText), value: value); + } +} + +class InputPromptState extends State { + final Widget title; + final Widget prompt; + TextEditingController _editor = TextEditingController(); + + InputPromptState({required this.title, required this.prompt, String? value}) { + if (value != null) _editor.text = value; + } + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: title, + actions: [ + ElevatedButton( + onPressed: () async { + Navigator.pop(context, _editor.text); + }, + child: Text("Confirm")), + ElevatedButton( + onPressed: () async { + Navigator.pop(context, ""); + }, + child: Text("Cancel")) + ], + content: SizedBox( + width: 200, + height: 100, + child: Column(children: [ + prompt, + TextField( + controller: _editor, + ) + ]), + )); + } +} + class EditValuePrompt extends StatefulWidget { const EditValuePrompt({super.key}); diff --git a/lib/pages/SNBTEditor.dart b/lib/pages/SNBTEditor.dart index c8205aa..2fcb9eb 100644 --- a/lib/pages/SNBTEditor.dart +++ b/lib/pages/SNBTEditor.dart @@ -1,3 +1,4 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_code_editor/flutter_code_editor.dart'; import 'package:flutter_highlight/themes/vs.dart'; @@ -5,6 +6,7 @@ import 'package:libac_dart/nbt/SnbtIo.dart'; import 'package:libac_dart/nbt/impl/CompoundTag.dart'; import 'package:nbteditor/Constants.dart'; import 'package:nbteditor/SessionData.dart'; +import 'package:nbteditor/pages/EditValue.dart'; class SnbtEdit extends StatefulWidget { const SnbtEdit({super.key}); @@ -31,6 +33,19 @@ class SnbtState extends State { appBar: AppBar( title: const Text("SNBT Editor"), backgroundColor: Constants.TITLEBAR_COLOR, + actions: [ + IconButton( + onPressed: () async { + var searchResponse = await showCupertinoDialog( + context: context, + builder: (searchBuilder) { + return InputPrompt( + titleText: "Search", + PromptText: "What do you want to search for?"); + }); + }, + icon: Icon(CupertinoIcons.search)) + ], ), floatingActionButton: ElevatedButton( onPressed: () async { diff --git a/pubspec.yaml b/pubspec.yaml index 69d84f6..64911f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: nbteditor description: A Minecraft NBT Editor written in Flutter publish_to: "none" -version: 1.1.012225+0420 +version: 1.1.012325+1215 environment: sdk: ^3.6.1