Skip to content

Commit

Permalink
improved input usability
Browse files Browse the repository at this point in the history
  • Loading branch information
FaFre committed Jun 3, 2024
1 parent 1617c74 commit 9a63a4c
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
),
Expand Down
16 changes: 16 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion metadata/android/en-US/changelogs/4.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9a63a4c

Please sign in to comment.