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

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