diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 814bf01..61c716f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,6 +12,11 @@ on: required: true default: false type: boolean + buildLinux: + description: Build for Linux + required: true + default: false + type: boolean jobs: analyze: @@ -52,15 +57,13 @@ jobs: run: flutter build apk --obfuscate --split-debug-info=build/debugAndroid - name: Preparing files run: | - cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/ollama.apk - cp build/app/outputs/flutter-apk/app-release.apk.sha1 build/app/outputs/flutter-apk/ollama.apk.sha1 + cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/ollama-android-v${{ steps.get_flutter_version.outputs.version_number }}.apk - name: Uploading APK uses: actions/upload-artifact@v4 with: name: ollama-android path: | - build/app/outputs/flutter-apk/ollama.apk - build/app/outputs/flutter-apk/ollama.apk.sha1 + build/app/outputs/flutter-apk/ollama-android-v${{ steps.get_flutter_version.outputs.version_number }}.apk build-windows-x64: name: Building for Windows x64 if: ${{ github.event.inputs.buildWindowsX64 == 'true' }} @@ -88,12 +91,43 @@ jobs: uses: actions/upload-artifact@v4 with: name: ollama-windows-x64 - path: build\windows\x64\runner\ollama-v${{ steps.get_flutter_version.outputs.version_number }}-x64.exe + path: build\windows\x64\runner\ollama-windows-x64-v${{ steps.get_flutter_version.outputs.version_number }}.exe + build-linux: + name: Building for Linux + if: ${{ github.event.inputs.buildLinux == 'true' }} + runs-on: ubuntu-latest + needs: analyze + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + flutter-version: 3.22.1 + - name: Get flutter version + id: get_flutter_version + uses: its404/get-flutter-version@v1.0.0 + - name: Disabling flutter analytics + run: flutter config --no-analytics + - name: Installing linux dependencies + run: | + sudo apt-get install ninja-build + sudo apt-get install build-essential libgtk-3-dev + - name: Running build + id: compile + run: flutter build linux --obfuscate --split-debug-info=build/debugLinux + - name: Creating archive + run: | + cd build/linux/x64/release/bundle + tar -czf ollama-linux-x64-v${{ steps.get_flutter_version.outputs.version_number }}.tar.gz * + - name: Uploading archive + uses: actions/upload-artifact@v4 + with: + name: ollama-linux-x64 + path: build/linux/x64/release/bundle/ollama-linux-x64-v${{ steps.get_flutter_version.outputs.version_number }}.tar.gz bundle: name: Creating bundle runs-on: ubuntu-latest if: ${{ always() }} - needs: [build-android, build-windows-x64] + needs: [build-android, build-windows-x64, build-linux] steps: - name: Adding builds uses: actions/download-artifact@v4 @@ -105,4 +139,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ollama - path: ./ + path: ./ \ No newline at end of file diff --git a/lib/settings/export.dart b/lib/settings/export.dart index 4ddc9f1..2a73f55 100644 --- a/lib/settings/export.dart +++ b/lib/settings/export.dart @@ -13,6 +13,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:file_picker/file_picker.dart'; +import 'package:file_selector/file_selector.dart' as file_selector; import 'package:intl/intl.dart'; import 'package:dynamic_color/dynamic_color.dart'; @@ -49,6 +50,7 @@ class _ScreenSettingsExportState extends State { var content = jsonEncode(prefs!.getStringList("chats") ?? []); if (kIsWeb) { + // web fallback final bytes = utf8.encode(content); final blob = html.Blob([bytes]); final url = html.Url.createObjectUrlFromBlob(blob); @@ -64,12 +66,22 @@ class _ScreenSettingsExportState extends State { html.document.body!.children.remove(anchor); html.Url.revokeObjectUrl(url); } else { - var path = await FilePicker.platform.saveFile( - type: FileType.custom, - allowedExtensions: ["json"], - fileName: name, - bytes: utf8.encode(jsonEncode( - prefs!.getStringList("chats") ?? []))); + String? path = ""; + try { + path = (await file_selector + .getSaveLocation(acceptedTypeGroups: [ + const file_selector.XTypeGroup( + label: "Ollama App File", extensions: ["json"]) + ], suggestedName: name)) + ?.path; + } catch (_) { + path = await FilePicker.platform.saveFile( + type: FileType.custom, + allowedExtensions: ["json"], + fileName: name, + bytes: utf8.encode(jsonEncode( + prefs!.getStringList("chats") ?? []))); + } selectionHaptic(); if (path == null) return; if (desktopFeature()) { @@ -103,30 +115,54 @@ class _ScreenSettingsExportState extends State { TextButton( onPressed: () async { selectionHaptic(); - FilePickerResult? result = - await FilePicker.platform - .pickFiles( - type: FileType.custom, - allowedExtensions: [ - "json" - ]); - if (result == null) { - // ignore: use_build_context_synchronously - Navigator.of(context).pop(); - return; - } - String content; try { - File file = File( - result.files.single.path!); + if (kIsWeb) { + throw Exception( + "web must use file picker"); + } + file_selector.XFile? result = + await file_selector.openFile( + acceptedTypeGroups: [ + const file_selector + .XTypeGroup( + label: + "Ollama App File", + extensions: ["json"]) + ]); + if (result == null) { + // ignore: use_build_context_synchronously + Navigator.of(context).pop(); + return; + } content = - await file.readAsString(); + await result.readAsString(); } catch (_) { - content = utf8.decode(result - .files - .single - .bytes as List); + FilePickerResult? result = + await FilePicker.platform + .pickFiles( + type: + FileType.custom, + allowedExtensions: [ + "json" + ]); + if (result == null) { + // ignore: use_build_context_synchronously + Navigator.of(context).pop(); + return; + } + try { + File file = File(result + .files.single.path!); + content = + await file.readAsString(); + } catch (_) { + // web fallback + content = utf8.decode(result + .files + .single + .bytes as List); + } } List tmpHistory = jsonDecode(content); diff --git a/pubspec.lock b/pubspec.lock index 98ac637..a886f4c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -225,6 +225,30 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.2" + file_selector: + dependency: "direct main" + description: + name: file_selector + sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + file_selector_android: + dependency: transitive + description: + name: file_selector_android + sha256: "77f23eb5916fd0875946720d1f286f809a28a867d4882db6ac2cf053e2d5f7c6" + url: "https://pub.dev" + source: hosted + version: "0.5.1+6" + file_selector_ios: + dependency: transitive + description: + name: file_selector_ios + sha256: "38ebf91ecbcfa89a9639a0854ccaed8ab370c75678938eebca7d34184296f0bb" + url: "https://pub.dev" + source: hosted + version: "0.5.3" file_selector_linux: dependency: transitive description: @@ -249,6 +273,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.6.2" + file_selector_web: + dependency: transitive + description: + name: file_selector_web + sha256: c4c0ea4224d97a60a7067eca0c8fd419e708ff830e0c83b11a48faf566cec3e7 + url: "https://pub.dev" + source: hosted + version: "0.9.4+2" file_selector_windows: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9e3d92a..bfec6db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,6 +28,7 @@ dependencies: restart_app: ^1.2.1 flutter_markdown: ^0.7.1 file_picker: ^8.0.3 + file_selector: ^1.0.3 bitsdojo_window: ^0.1.6 install_referrer: ^1.2.1 package_info_plus: ^8.0.0 diff --git a/windows_installer/arm64.iss b/windows_installer/arm64.iss index 8d8cc8f..c1c1122 100644 --- a/windows_installer/arm64.iss +++ b/windows_installer/arm64.iss @@ -1,7 +1,7 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -; #define AppVersion "1.0.1" +;#define AppVersion "1.0.1" #define AppName "Ollama App" #define AppPublisher "JHubi1" @@ -27,7 +27,7 @@ UninstallDisplayName={#AppName} DefaultDirName={autopf}\OllamaApp OutputDir=build\windows\{#AppArchitectures}\runner -OutputBaseFilename=ollama-v{#AppVersion}-{#AppArchitectures} +OutputBaseFilename=ollama-windows-{#AppArchitectures}-v{#AppVersion} AppSupportURL=https://github.com/JHubi1/ollama-app/issues AppUpdatesURL=https://github.com/JHubi1/ollama-app/releases diff --git a/windows_installer/x64.iss b/windows_installer/x64.iss index 97d3cf0..e8b25c2 100644 --- a/windows_installer/x64.iss +++ b/windows_installer/x64.iss @@ -28,7 +28,7 @@ UninstallDisplayName={#AppName} DefaultDirName={autopf}\OllamaApp OutputDir=build\windows\{#AppArchitectures}\runner -OutputBaseFilename=ollama-v{#AppVersion}-{#AppArchitectures} +OutputBaseFilename=ollama-windows-{#AppArchitectures}-v{#AppVersion} AppSupportURL=https://github.com/JHubi1/ollama-app/issues AppUpdatesURL=https://github.com/JHubi1/ollama-app/releases