Begin adding a search function

This commit is contained in:
zontreck 2025-01-23 12:19:45 -07:00
parent 7000383758
commit 55a3e6859e
5 changed files with 89 additions and 2 deletions

View file

@ -1 +1 @@
const VERSION = "1.1.012225+0420";
const VERSION = "1.1.012325+1215";

View file

@ -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<Editor> {
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,

View file

@ -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<StatefulWidget> createState() {
return InputPromptState(
title: Text(titleText), prompt: Text(PromptText), value: value);
}
}
class InputPromptState extends State<InputPrompt> {
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});

View file

@ -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<SnbtEdit> {
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 {