Conversation
@elioqoshi do you have any thoughts on @Feichtmeier's proposal above? |
@Feichtmeier 's addition is a good proposal! I do feel the whole page for just a dropdown feels a little empty. In my initial explorations I had a flow where one can choose the timezone via a dropdown AND the map (if you'd choose it in one, the other one would be updated accordingly). Do you think this is feasible? |
GeoService offers: - Countries and timezones - GeoIP lookup (https://geoip.ubuntu.com/lookup) - Geoname lookup (http://geoname-lookup.ubuntu.com/) - Offline lookup (cities15000.txt from geonames.org) Ref: canonical#38
The map in the original design is not accessible. Therefore, the initial version of the page comes without a map. Close: canonical#38
This should no longer be necessary since we have a Where are you? page where the timezone is set.
I have added a timezone entry and updated the screencast in the PR description. If we decide to add a map, I'd like to leave that as a separate (big) task. 😄 |
Quick smoke tests: my location is auto-detected to Madrid (Spain), which isn't very accurate, but IIRC ubiquity doesn't do a better job, so that's not a regression. The timezone (Europe/Madrid) is correct. Searching in the location text field isn't working as I'd expect: when I input "barcelon", I would expect "Barcelona (Catalonia, Spain)" to be in the list of results, but it isn't:
And a dummy question, because I haven't read the code yet: can the names of cities and timezones be localized in the selected language, or is the data only available in English? |
The result is from https://geoip.ubuntu.com/lookup. I get sometimes even slightly different results when refreshing the page.
I got also surprised that geoname-lookup.ubuntu.com doesn't do a "starts with" search. |
Non-English alternate names are included in both online and offline lookups:
|
And that's a known bug which will turn 10 years old later this year, unless we do something about it ;) |
That's a minor detail, so feel free to ignore, but I find the logging a bit misleading. When I input "barcelona", I see:
So far so good. Then I click on the first entry in the results, my location is correctly selected, but I see:
I understand why this happens, but for someone reading the logs it's a tad misleading, maybe we could avoid issuing a request when the user selects an entry in the search results? |
Yeah, the extra request is a bit annoying. The problem is that
It gets really ugly but something like this would prevent the spurious search. diff --git a/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart b/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
index c8f8e641..709df3e3 100644
--- a/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
+++ b/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
@@ -80,7 +80,14 @@ class WhereAreYouPageState extends State<WhereAreYouPage> {
);
},
displayStringForOption: formatLocation,
- optionsBuilder: (value) {
+ optionsBuilder: (value) async {
+ // wait for onSelected to get called
+ await Future.delayed(const Duration(microseconds: 1));
+ // avoid searching a selected and formatted location
+ if (value.text ==
+ formatLocation(model.selectedLocation)) {
+ return model.locations;
+ }
return model.searchLocation(value.text);
},
onSelected: model.selectLocation, |
I guess we can assume that city names don't contain parentheses, so here's another possibility: diff --git a/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart b/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
index c8f8e641..a2d64f82 100644
--- a/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
+++ b/packages/ubuntu_desktop_installer/lib/pages/where_are_you/where_are_you_page.dart
@@ -81,6 +81,10 @@ class WhereAreYouPageState extends State<WhereAreYouPage> {
},
displayStringForOption: formatLocation,
optionsBuilder: (value) {
+ if (RegExp(r'^.*\(.*\)$').hasMatch(value.text)) {
+ // avoid searching a selected and formatted location
+ return model.locations;
+ }
return model.searchLocation(value.text);
},
onSelected: model.selectLocation, |
I have to agree this is rather ugly, I'd prefer if we could devise a cleaner approach.
Unfortunately, it appears that the names of some cities listed in cities15000.txt do contain parentheses (e.g. "Newport (Kentucky)", "سقّز (٢)", "Τιμπού (θερινή) Πουνάκα (χειμερινή)", …). And given the implementation of The documentation for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just a couple of very minor comments.
Hmm, this is not true. The first thing it does is to update the text editing controller's value, and then calls onSelected. |
I'm afraid adding a listener or checking the editing controller's current value doesn't really help unless we postpone the search in one way or another. The problem is essentially the same as previously that when building options, we don't know yet if an option has been selected, which could be either by clicking an option or by submitting the field using the keyboard. |
Thanks! I've opened #652 for the extra search request. |
The map in the original design is not accessible. Therefore, the initial version of the page comes without a map.
location.mp4
Close: #38