Start to add an appimage script

This commit is contained in:
zontreck 2024-07-23 03:29:43 -07:00
parent 10f18668de
commit b2747c7610
4 changed files with 80 additions and 25 deletions

3
.gitignore vendored
View file

@ -29,3 +29,6 @@ doc/api/
out out
.idea .idea
*.iml *.iml
AppDir
appimage-build

50
AppImageBuilder.yml Normal file
View file

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

View file

@ -1,5 +1,7 @@
import 'package:file_picker/file_picker.dart'; import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
import 'package:flutter_treeview/flutter_treeview.dart'; import 'package:flutter_treeview/flutter_treeview.dart';
import 'package:libac_dart/nbt/NbtIo.dart'; import 'package:libac_dart/nbt/NbtIo.dart';
import 'package:libac_dart/nbt/SnbtIo.dart'; import 'package:libac_dart/nbt/SnbtIo.dart';
@ -87,10 +89,9 @@ class EditorState extends State<Editor> {
leading: const Icon(Icons.folder), leading: const Icon(Icons.folder),
subtitle: const Text("Open an existing NBT Document for editing"), subtitle: const Text("Open an existing NBT Document for editing"),
onTap: () async { onTap: () async {
FilePickerResult? result = await FilePicker.platform.pickFiles(); String? filePath = await FlutterFileDialog.pickFile(
String? filePath; params: OpenFileDialogParams());
if (result != null) { if (filePath != null) {
filePath = result.files.single.path;
// Do something with the selected file path // Do something with the selected file path
print('Selected file path: $filePath'); print('Selected file path: $filePath');
} else { } else {
@ -129,16 +130,6 @@ class EditorState extends State<Editor> {
image: AssetImage("Icons/PNG/nbteditor.png"), image: AssetImage("Icons/PNG/nbteditor.png"),
), ),
onTap: () async { 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( var result = await showDialog(
context: context, context: context,
builder: (builder) { builder: (builder) {
@ -159,14 +150,25 @@ class EditorState extends State<Editor> {
); );
}); });
Uint8List u8l = Uint8List(0);
if (result == null) { if (result == null) {
// Save uncompressed // Save uncompressed
NbtIo.write( u8l = await NbtIo.writeToStream(
filePath, controller.children[0].data as CompoundTag); controller.children[0].data as CompoundTag);
} else { } else {
NbtIo.writeCompressed( u8l = await NbtIo.writeToStreamCompressed(
filePath, controller.children[0].data as CompoundTag); 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( ListTile(
@ -178,8 +180,8 @@ class EditorState extends State<Editor> {
onTap: () async { onTap: () async {
// Prompt for where to save // Prompt for where to save
print("Begin picking file to save to"); print("Begin picking file to save to");
String? filePath = await FilePicker.platform String? filePath = await FlutterFileDialog.saveFile(
.saveFile(dialogTitle: "Where do you want to save the file?"); params: SaveFileDialogParams());
if (filePath == null) { if (filePath == null) {
print("No file selected"); print("No file selected");
return; return;

View file

@ -1,22 +1,22 @@
name: nbteditor name: nbteditor
description: A Minecraft NBT Editor written in Flutter description: A Minecraft NBT Editor written in Flutter
publish_to: 'none' publish_to: 'none'
version: 1.0722.24+1506 version: 1.0722.24+1907
environment: environment:
sdk: '>=3.1.5 <4.0.0' sdk: '>=3.1.5 <4.0.0'
dependencies: dependencies:
file_picker: ^8.0.6
flutter: flutter:
sdk: flutter sdk: flutter
flutter_code_editor: ^0.3.2 flutter_code_editor: ^0.3.2
flutter_file_dialog: ^3.0.2
flutter_highlight: ^0.7.0 flutter_highlight: ^0.7.0
flutter_treeview: ^1.0.7+1 flutter_treeview: ^1.0.7+1
libac_dart: libac_dart:
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/ hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
version: 1.2.072224+0449 version: 1.2.072224+1906
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: