Repository navigation
Commit 01553db
committed
wip RawAutocomplete: Let caller control options directly
This isn't nearly ready for merge; it's just to demonstrate a
direction that might be helpful for zulip/zulip-flutte#226, and
perhaps also for:
flutter#123377 (comment)
The idea (for zulip/zulip-flutte#226) is to move to a new class
RawAutocompleteController the state value for the current list of
autocomplete options. Then, to let RawAutocomplete's caller pass an
instance of that class, giving the caller control over when that
state gets updated. For us, that's better than accepting
RawAutocomplete's old behavior, where a change in the
TextEditingController was the only trigger for an update. (We want
to trigger updates when our MentionAutocompleteView changes.)
Ideally, we could add this capability to RawAutocomplete without
removing any of its current API: maybe we could make the
`controller` param optional, and I guess add asserts to try to
prevent buggy mixtures of the old and this new opt-in behavior.
Anyway, that that was way too tricky for this demo, so here I've
just ripped out all the parts where RawAutocomplete did anything
with the TextEditingController.
I think our zulip/zulip-flutter#226 doesn't create a need to control
the "selection" state, but that state is also moved to the
RawAutocompleteController class anyway. Why?
- Well, with RawAutocomplete being unaware of the text-input value,
as mentioned in the previous paragraph, it can't listen for
changes in that value, which it was doing before, to null out the
selection state when the text changed. So, now we do that.
- Also, I think there's a proposal for class like this
RawAutocompleteController to contain the selection state:
flutter#123377 (comment)
That comment would also have it include the highlighted state, I
think (which the auther calls the "hovered" state). Since those
are closely related to the options-list state, might as well
put them there along with it.
For this demo, I hacked down the Material `Autocomplete` widget so
that zulip-flutter would build, and I haven't touched any of the
Flutter framework tests.1 parent 4be6bf4 commit 01553db
2 files changed
Lines changed: 34 additions & 317 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | | - | |
10 | 7 | | |
11 | | - | |
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
| |||
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
63 | | - | |
64 | | - | |
| 59 | + | |
65 | 60 | | |
66 | | - | |
67 | 61 | | |
68 | | - | |
| 62 | + | |
69 | 63 | | |
70 | 64 | | |
71 | 65 | | |
72 | 66 | | |
73 | | - | |
74 | | - | |
| 67 | + | |
| 68 | + | |
75 | 69 | | |
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
79 | 73 | | |
80 | 74 | | |
81 | 75 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | 76 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 77 | + | |
93 | 78 | | |
94 | 79 | | |
95 | 80 | | |
| |||
105 | 90 | | |
106 | 91 | | |
107 | 92 | | |
108 | | - | |
| 93 | + | |
109 | 94 | | |
110 | 95 | | |
111 | | - | |
112 | | - | |
113 | 96 | | |
114 | 97 | | |
115 | 98 | | |
116 | 99 | | |
117 | 100 | | |
118 | 101 | | |
119 | | - | |
| 102 | + | |
120 | 103 | | |
121 | | - | |
122 | | - | |
123 | 104 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 105 | + | |
133 | 106 | | |
134 | 107 | | |
135 | 108 | | |
| |||
138 | 111 | | |
139 | 112 | | |
140 | 113 | | |
141 | | - | |
142 | | - | |
143 | 114 | | |
144 | 115 | | |
145 | 116 | | |
146 | 117 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | 118 | | |
152 | 119 | | |
153 | 120 | | |
154 | | - | |
155 | 121 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | 122 | | |
219 | 123 | | |
220 | 124 | | |
0 commit comments