From b2747c7610e77ef7f603cb880f08b84995998ed0 Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 23 Jul 2024 03:29:43 -0700 Subject: [PATCH] Start to add an appimage script --- .gitignore | 5 ++++- AppImageBuilder.yml | 50 +++++++++++++++++++++++++++++++++++++++++++++ lib/Editor.dart | 44 ++++++++++++++++++++------------------- pubspec.yaml | 6 +++--- 4 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 AppImageBuilder.yml diff --git a/.gitignore b/.gitignore index 6b0ed97..8fea2bd 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,7 @@ doc/api/ out .idea -*.iml \ No newline at end of file +*.iml + +AppDir +appimage-build \ No newline at end of file diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml new file mode 100644 index 0000000..a483acd --- /dev/null +++ b/AppImageBuilder.yml @@ -0,0 +1,50 @@ +# appimage-builder recipe see https://appimage-builder.readthedocs.io for details +version: 1 +script: + - rm -rf AppDir || true + - flutter pub get + - rm -rf build || true + - flutter build linux + - cp -r build/linux/x64/release/bundle AppDir + - mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps + - cp Icons/PNG/nbteditor.png AppDir/usr/share/icons/hicolor/64x64/apps/ +AppDir: + path: AppDir + app_info: + id: dev.zontreck.nbteditor + name: NBT Editor + icon: nbteditor + version: latest + exec: nbteditor + exec_args: $@ + pacman: + include: [] + exclude: [] + files: + include: + - /lib64/ld-linux-x86-64.so.2 + exclude: + - usr/share/man + - usr/share/doc/*/README.* + - usr/share/doc/*/changelog.* + - usr/share/doc/*/NEWS.* + - usr/share/doc/*/TODO.* + test: + fedora-30: + image: appimagecrafters/tests-env:fedora-30 + command: ./AppRun + debian-stable: + image: appimagecrafters/tests-env:debian-stable + command: ./AppRun + archlinux-latest: + image: appimagecrafters/tests-env:archlinux-latest + command: ./AppRun + centos-7: + image: appimagecrafters/tests-env:centos-7 + command: ./AppRun + ubuntu-xenial: + image: appimagecrafters/tests-env:ubuntu-xenial + command: ./AppRun +AppImage: + arch: x86_64 + update-information: guess diff --git a/lib/Editor.dart b/lib/Editor.dart index 40df70b..754123d 100644 --- a/lib/Editor.dart +++ b/lib/Editor.dart @@ -1,5 +1,7 @@ -import 'package:file_picker/file_picker.dart'; +import 'dart:typed_data'; + import 'package:flutter/material.dart'; +import 'package:flutter_file_dialog/flutter_file_dialog.dart'; import 'package:flutter_treeview/flutter_treeview.dart'; import 'package:libac_dart/nbt/NbtIo.dart'; import 'package:libac_dart/nbt/SnbtIo.dart'; @@ -87,10 +89,9 @@ class EditorState extends State { leading: const Icon(Icons.folder), subtitle: const Text("Open an existing NBT Document for editing"), onTap: () async { - FilePickerResult? result = await FilePicker.platform.pickFiles(); - String? filePath; - if (result != null) { - filePath = result.files.single.path; + String? filePath = await FlutterFileDialog.pickFile( + params: OpenFileDialogParams()); + if (filePath != null) { // Do something with the selected file path print('Selected file path: $filePath'); } else { @@ -129,16 +130,6 @@ class EditorState extends State { image: AssetImage("Icons/PNG/nbteditor.png"), ), onTap: () async { - // Prompt for where to save - print("Begin picking file to save to"); - String? filePath = await FilePicker.platform - .saveFile(dialogTitle: "Where do you want to save the file?"); - if (filePath == null) { - print("No file selected"); - return; - } - print(filePath); - var result = await showDialog( context: context, builder: (builder) { @@ -159,14 +150,25 @@ class EditorState extends State { ); }); + Uint8List u8l = Uint8List(0); if (result == null) { // Save uncompressed - NbtIo.write( - filePath, controller.children[0].data as CompoundTag); + u8l = await NbtIo.writeToStream( + controller.children[0].data as CompoundTag); } else { - NbtIo.writeCompressed( - filePath, controller.children[0].data as CompoundTag); + u8l = await NbtIo.writeToStreamCompressed( + controller.children[0].data as CompoundTag); } + // Prompt for where to save + print("Begin picking file to save to"); + var params = await SaveFileDialogParams(data: u8l); + var filePath = await FlutterFileDialog.saveFile(params: params); + + if (filePath == null) { + print("No file selected"); + return; + } + print(filePath); }, ), ListTile( @@ -178,8 +180,8 @@ class EditorState extends State { onTap: () async { // Prompt for where to save print("Begin picking file to save to"); - String? filePath = await FilePicker.platform - .saveFile(dialogTitle: "Where do you want to save the file?"); + String? filePath = await FlutterFileDialog.saveFile( + params: SaveFileDialogParams()); if (filePath == null) { print("No file selected"); return; diff --git a/pubspec.yaml b/pubspec.yaml index 686cb8a..1b3ef26 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,22 +1,22 @@ name: nbteditor description: A Minecraft NBT Editor written in Flutter publish_to: 'none' -version: 1.0722.24+1506 +version: 1.0722.24+1907 environment: sdk: '>=3.1.5 <4.0.0' dependencies: - file_picker: ^8.0.6 flutter: sdk: flutter flutter_code_editor: ^0.3.2 + flutter_file_dialog: ^3.0.2 flutter_highlight: ^0.7.0 flutter_treeview: ^1.0.7+1 libac_dart: hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/ - version: 1.2.072224+0449 + version: 1.2.072224+1906 dev_dependencies: flutter_test: