improved input usability

This commit is contained in:
Fabian Freund
2024-06-03 04:34:08 +02:00
parent 1617c746ef
commit 9a63a4c91c
7 changed files with 73 additions and 30 deletions
+1
View File
@@ -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
@@ -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) {
@@ -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 =
@@ -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,
),
+16
View File
@@ -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:
+1
View File
@@ -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
+2 -1
View File
@@ -1,3 +1,4 @@
* Added landing page
* Adjusted routing for back navigation and landing page
* Added link to Kagi Acoount in Settings
* Added link to Kagi Acoount in Settings
* Improved input usability for Kagi Tools