Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete format tags #396

Closed
wants to merge 3 commits into from
Closed

Conversation

matthewwong525
Copy link
Collaborator

Closes #138

var caretIndex = widget.controller.selection.baseOffset;
String lastLine = text.substring(0, caretIndex).split('\n').last;
RegExp r = RegExp(r'\[\[((?!([\]])).)*$');
bool showTitleLinks = r.hasMatch(lastLine);
return showTitleLinks;
}

bool checkIsTagsVisible(String text) {
Copy link
Collaborator Author

@matthewwong525 matthewwong525 Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge this function with checkIsTitleLinksVisible and add a regex parameter as an input. Not sure what time name it tho lol

Copy link
Collaborator Author

@matthewwong525 matthewwong525 Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool checkIsSuggestionsVisible(String text, RegExp r)

if (isVisible) {
bool isTitleLinksVisible = checkIsTitleLinksVisible(text);
bool isTagsVisible = checkIsTagsVisible(text);
if (isTitleLinksVisible) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if it's possible to put everything within this if statement into a function. it looks identical to the if statement below. we want to reuse logic as much as possible so it'll be easier to make changes in the future :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be hard with the titleLinksVisible = true

@@ -109,6 +119,20 @@ class _ContentFieldState extends State<ContentField> {
titleLinksVisible = false;
removeOverlay();
}

if (isTagsVisible) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the identical if statement

@@ -124,14 +148,22 @@ class _ContentFieldState extends State<ContentField> {
}

// Helper Functions
bool isTitleLinksVisible(String text) {
bool checkIsTitleLinksVisible(String text) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkIsSuggestionsVisible

@@ -185,9 +217,55 @@ class _ContentFieldState extends State<ContentField> {
child: ValueListenableBuilder(
valueListenable: titleLinkQuery,
builder: (context, value, child) {
return LinkSuggestions(
return Suggestions(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good on you to rename this ;)

@@ -41,6 +41,12 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
<!-- "Take a note" command https://developer.android.com/guide/components/intents-common#NewNote -->
<intent-filter>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be here, the google assistant stuff.

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK

class MainActivity: FlutterActivity() {
private var savedNote: String? = null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be here, the google assistant stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

@@ -112,6 +112,21 @@ class Database {
return linkSet.toList();
}

Future<List<String>> getAllTags() async {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol can we make another function Future<List<String>> getAllRegex(Regexp r) and have these two functions call that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should be ez to merge the logic tho


void showTagsOverlay(context, BoxConstraints size) async {
print('e');
_onLinkSelect(String link) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably rename this to _onTagSelect

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again i'd really like it if we could merge the logic but it seems like it might be a lot of work. ill let you decide if it's worth your time

t.substring(0, tagIndex) + '#$tag' + t.substring(caretI, t.length);
widget.controller.selection = TextSelection.fromPosition(
TextPosition(offset: tagIndex + tag.length + 1));
widget.db.firebase.analytics
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

@ransurf
Copy link
Contributor

ransurf commented Oct 26, 2022

Closes #396

@matthewwong525
Copy link
Collaborator Author

matthewwong525 commented Oct 29, 2022

when I type the word out, the autocomplete disappears. Also, I will pick up this ticket. i think it's more worth your time to work on other things

Screen.Recording.2022-10-29.at.7.35.12.AM.mov

@matthewwong525
Copy link
Collaborator Author

I want to create a new widget called TextFieldWithAutoComplete that takes in a regex where the first group is where the text actually lies and is used to determine when to hide or show the autocomplete

@matthewwong525
Copy link
Collaborator Author

Closed by #609

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I want better support for tags
2 participants