mind-co / comind

think something
https://www.comind.me/
MIT License
6 stars 0 forks source link

Add command processing to text field #12

Closed cpfiffer closed 7 months ago

cpfiffer commented 9 months ago

Add the command processing stuff back in. Can't use the following code because enabling the onChange function breaks backspacing on android/linux. See https://stackoverflow.com/questions/71783012/backspace-text-field-flutter-on-android-devices-not-working

https://github.com/mind-co/comind-flutter/blob/335976f7c501ad53ff95e09301d0143011c9ef84/lib/input_field.dart#L221

The old code was this:

// If it starts with /, it's a command
                        onChanged: (value) async {
                          // Check for mode changes first, but only
                          // if the type is main
                          if (widget.type == TextFieldType.main) {
                            if (value == "/search" || value == "/s") {
                              setState(() {
                                uiMode = "search";
                              });

                              // Clear the text field
                              // _primaryController.clear();
                            } else if (value == "/users" || value == "/u") {
                              setState(() {
                                uiMode = "users";
                              });

                              // Clear the text field
                              // _primaryController.clear();
                            } else if (value == "/t" || value == ";") {
                              setState(() {
                                uiMode = "think";
                              });
                              // _primaryController.clear();
                            }

                            // Next, handle the commands
                            if (uiMode == "search") {
                              // Search
                              var res = await searchThoughts(context, value);
                              setState(() {
                                searchResults = res;
                              });
                            }
                          }
                        },
cpfiffer commented 7 months ago

Please see #30 and #13. This works for now. I'm going to ignore the "users" stuff until there's more social/networking functionality.