diff --git a/CHANGELOG.md b/CHANGELOG.md index a55d1665..0613c05e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Added landing page * Adjusted routing for back navigation and landing page * Added link to Kagi Acoount in Settings +* Improved input usability for Kagi Tools ## 0.2.0 diff --git a/app/lib/features/search_browser/presentation/widgets/tabs/assistant_tab.dart b/app/lib/features/search_browser/presentation/widgets/tabs/assistant_tab.dart index 081d90b4..6562748a 100644 --- a/app/lib/features/search_browser/presentation/widgets/tabs/assistant_tab.dart +++ b/app/lib/features/search_browser/presentation/widgets/tabs/assistant_tab.dart @@ -129,6 +129,8 @@ class AssistantTab extends HookConsumerWidget { decoration: const InputDecoration( // border: OutlineInputBorder(), label: Text('Prompt'), + hintText: 'Enter your prompt...', + floatingLabelBehavior: FloatingLabelBehavior.always, ), maxLines: null, validator: (value) { diff --git a/app/lib/features/search_browser/presentation/widgets/tabs/search_tab.dart b/app/lib/features/search_browser/presentation/widgets/tabs/search_tab.dart index 9b4390bf..aa80893e 100644 --- a/app/lib/features/search_browser/presentation/widgets/tabs/search_tab.dart +++ b/app/lib/features/search_browser/presentation/widgets/tabs/search_tab.dart @@ -157,6 +157,8 @@ class SearchTab extends HookConsumerWidget { decoration: InputDecoration( // border: OutlineInputBorder(), label: const Text('Query'), + hintText: 'Ask anything...', + floatingLabelBehavior: FloatingLabelBehavior.always, suffixIcon: IconButton( onPressed: () async { final isServiceAvailable = diff --git a/app/lib/features/search_browser/presentation/widgets/tabs/summarize_tab.dart b/app/lib/features/search_browser/presentation/widgets/tabs/summarize_tab.dart index d45774e9..35ffcd97 100644 --- a/app/lib/features/search_browser/presentation/widgets/tabs/summarize_tab.dart +++ b/app/lib/features/search_browser/presentation/widgets/tabs/summarize_tab.dart @@ -7,11 +7,40 @@ import 'package:bang_navigator/features/search_browser/utils/url_builder.dart' import 'package:bang_navigator/features/share_intent/domain/entities/shared_content.dart'; import 'package:bang_navigator/presentation/widgets/website_title_tile.dart'; import 'package:bang_navigator/utils/uri_parser.dart' as uri_parser; +import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_material_design_icons/flutter_material_design_icons.dart'; +import 'package:flutter_pdf_text/flutter_pdf_text.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +class _InputField extends StatelessWidget { + final TextEditingController? controller; + + const _InputField({required this.controller, super.key}); + + @override + Widget build(BuildContext context) { + return TextFormField( + controller: controller, + decoration: const InputDecoration( + label: Text('Document'), + hintText: 'Enter URL or text to summarize', + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + maxLines: null, + autovalidateMode: AutovalidateMode.onUserInteraction, + validator: (value) { + if (value?.isEmpty ?? true) { + return ''; + } + + return null; + }, + ); + } +} + class SummarizeTab extends HookConsumerWidget { final SharedContent? sharedContent; final OnSubmitUri onSubmit; @@ -59,21 +88,7 @@ class SummarizeTab extends HookConsumerWidget { ), ...switch (sharedContent) { SharedUrl() => [ - TextFormField( - controller: textController, - decoration: const InputDecoration( - // border: OutlineInputBorder(), - label: Text('Document'), - ), - autovalidateMode: AutovalidateMode.onUserInteraction, - validator: (value) { - if (value?.isEmpty ?? true) { - return ''; - } - - return null; - }, - ), + _InputField(controller: textController), HookBuilder( builder: (context) { final url = @@ -108,22 +123,27 @@ class SummarizeTab extends HookConsumerWidget { ), ], SharedText() || null => [ - TextFormField( - controller: textController, - decoration: const InputDecoration( - // border: OutlineInputBorder(), - label: Text('Document'), - ), - maxLines: null, - autovalidateMode: AutovalidateMode.onUserInteraction, - validator: (value) { - if (value?.isEmpty ?? true) { - return ''; - } + SizedBox( + width: double.infinity, + child: OutlinedButton.icon( + onPressed: () async { + final pickResult = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['pdf'], + ); - return null; - }, + if (pickResult?.files.first.path + case final String filePath) { + final content = await PDFDoc.fromPath(filePath) + .then((doc) => doc.text); + textController.text = content; + } + }, + icon: const Icon(MdiIcons.fileUpload), + label: const Text('Read PDF document'), + ), ), + _InputField(controller: textController), const SizedBox( height: 12, ), diff --git a/app/pubspec.lock b/app/pubspec.lock index 488721aa..0813ff67 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -321,6 +321,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + file_picker: + dependency: "direct main" + description: + name: file_picker + sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a" + url: "https://pub.dev" + source: hosted + version: "8.0.3" fixnum: dependency: transitive description: @@ -430,6 +438,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: c6b0b4c05c458e1c01ad9bcc14041dd7b1f6783d487be4386f793f47a8a4d03e + url: "https://pub.dev" + source: hosted + version: "2.0.20" flutter_riverpod: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 5dd96df8..2af238e7 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: exceptions: ^0.6.0 expandable_page_view: ^1.0.17 fast_equatable: ^1.1.0 + file_picker: ^8.0.3 flutter: sdk: flutter flutter_hooks: ^0.20.5 diff --git a/metadata/android/en-US/changelogs/4.txt b/metadata/android/en-US/changelogs/4.txt index 5f3478cf..0224e15f 100644 --- a/metadata/android/en-US/changelogs/4.txt +++ b/metadata/android/en-US/changelogs/4.txt @@ -1,3 +1,4 @@ * Added landing page * Adjusted routing for back navigation and landing page -* Added link to Kagi Acoount in Settings \ No newline at end of file +* Added link to Kagi Acoount in Settings +* Improved input usability for Kagi Tools \ No newline at end of file