Skip to content

Commit

Permalink
upgraded typeahead controller to fix bug introduced with new flutter …
Browse files Browse the repository at this point in the history
…version, upgraded to flutter version
  • Loading branch information
Benimautner committed Dec 23, 2023
1 parent ccef93c commit 8b7e6a2
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 80 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {

defaultConfig {
applicationId "io.vikunja.app"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 33
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode flutterVersionCode.toInteger()
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
FlutterApplication and put your custom class here. -->
<application
android:label="Vikunja"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<activity
Expand Down
22 changes: 14 additions & 8 deletions lib/pages/list/task_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,28 @@ class _TaskEditPageState extends State<TaskEditPage> {
left: 2.0 + (IconTheme.of(context).size??0))),
Container(
width: MediaQuery.of(context).size.width - 80 - ((IconTheme.of(context).size ?? 0) * 2),
child: TypeAheadFormField(
textFieldConfiguration: TextFieldConfiguration(
child: TypeAheadField(
builder: (builder, controller, focusnode) {
return TextFormField(
controller: _labelTypeAheadController,
focusNode: focusnode,
decoration: InputDecoration(
labelText: 'Add a new label')),
labelText: 'Add a new label',
border: InputBorder.none,
),
);
},
suggestionsCallback: (pattern) =>
_searchLabel(pattern),
itemBuilder: (context, suggestion) {
return new ListTile(
title: Text(suggestion.toString()));
},
transitionBuilder:
(context, suggestionsBox, controller) {
return suggestionsBox;
},
onSuggestionSelected: (suggestion) {
//transitionBuilder:
// (context, suggestionsBox, controller) {
// return suggestionsBox;
//},
onSelected: (suggestion) {
_addLabel(suggestion.toString());
},
),
Expand Down
35 changes: 24 additions & 11 deletions lib/pages/user/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _LoginPageState extends State<LoginPage> {
final _usernameController = TextEditingController();
final _passwordController = TextEditingController();

final _serverSuggestionController = SuggestionsBoxController();
final _serverSuggestionController = SuggestionsController();


@override
Expand Down Expand Up @@ -89,25 +89,38 @@ class _LoginPageState extends State<LoginPage> {
padding: vStandardVerticalPadding,
child: Row(children: [
Expanded(
child: TypeAheadFormField(
suggestionsBoxController: _serverSuggestionController,
getImmediateSuggestions: true,
enabled: !_loading,
validator: (address) {
return (isUrl(address) ||
child: TypeAheadField(
//suggestionsBoxController: _serverSuggestionController,
//getImmediateSuggestions: true,
//enabled: !_loading,
controller: _serverController,
builder: (context, controller, focusnode) {
return TextFormField(
controller: controller,
focusNode: focusnode,
enabled: !_loading,
validator: (address) {
return (isUrl(address) ||
address != null ||
address!.isEmpty)
? null
: 'Invalid URL';
: 'Invalid URL';
},
decoration: new InputDecoration(
border: OutlineInputBorder(),
labelText: 'Server Address'),
);
},
/*
textFieldConfiguration: TextFieldConfiguration(
controller: _serverController,
decoration: new InputDecoration(
border: OutlineInputBorder(),
labelText: 'Server Address'),
),
onSuggestionSelected: (suggestion) {
),*/
onSelected: (suggestion) {
_serverController.text = suggestion;
setState(() => _serverController.text = suggestion);
},
itemBuilder: (BuildContext context, Object? itemData) {
return Card(
Expand All @@ -121,7 +134,7 @@ class _LoginPageState extends State<LoginPage> {
IconButton(onPressed: () {
setState(() {
pastServers.remove(itemData.toString());
_serverSuggestionController.suggestionsBox?.close();
//_serverSuggestionController.suggestionsBox?.close();
VikunjaGlobal.of(context).settingsManager.setPastServers(pastServers);

});
Expand Down
Loading

0 comments on commit 8b7e6a2

Please sign in to comment.