Skip to content

Commit

Permalink
Add export
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 12, 2024
1 parent d22a76e commit d542b26
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
35 changes: 35 additions & 0 deletions app/lib/pages/settings/data.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:archive/archive.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:lw_file_system/lw_file_system.dart';
import 'package:lw_sysapi/lw_sysapi.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:setonix/services/file_system.dart';
Expand Down Expand Up @@ -83,6 +86,38 @@ class DataSettingsPage extends StatelessWidget {
}
},
),
ListTile(
title: Text(AppLocalizations.of(context).export),
leading:
const PhosphorIcon(PhosphorIconsLight.export),
onTap: () async {
final worldSystem =
context.read<SetonixFileSystem>().worldSystem;
final archive = Archive();
final keys = await worldSystem.getKeys();
for (final key in keys) {
final entity =
await worldSystem.fileSystem.getFile(key);
if (entity == null) continue;
archive.addFile(
ArchiveFile(
'$key.stnx', entity.length, entity),
);
}
final bytes = ZipEncoder().encode(archive);
if (context.mounted && bytes != null) {
exportFile(
context: context,
bytes: bytes,
fileExtension: 'zip',
mimeType: 'application/zip',
uniformTypeIdentifier: 'public.zip-archive',
fileName: 'output',
label: AppLocalizations.of(context).export,
);
}
},
)
]),
),
),
Expand Down
Binary file modified app/pack/textures/figures/chess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "4d45dc9069dba4619dc0ebd93c7cec5e66d8482cb625a370ac806dcc8165f2ec"
sha256: e5c39a90447e7c81cfec14b041cdbd0d0916bd9ebbc7fe02ab69568be703b9bd
url: "https://pub.dev"
source: hosted
version: "5.5.5"
version: "5.6.0"
win32_registry:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.7",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"astro": "^4.16.1",
"astro": "^4.16.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"remark-gemoji": "^8.0.0",
Expand Down
28 changes: 14 additions & 14 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d542b26

Please sign in to comment.