halkyon_app: data locations as precise as a country or a state

An operator's DATA_LOCATION and BACKUP_LOCATION may name a subdivision
(ISO 3166-2, US-CA, DE-BY) besides the EU or a country. The app adds
"(EU)" to a member country and the country to a subdivision ("Germany
(EU)", "California, United States", "Bavaria, Germany (EU)"), in
English and German, and shows the most specific flag there is: a
subdivision's own where the flag package has one, else its country's.
Subdivision names come from Unicode CLDR 48.2 (tool/subdivision_names.py),
bundled with their licence, which the app registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-19 18:47:25 +02:00
commit 96f2d14618
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -51,6 +51,7 @@ void main() {
bool signedOut = false,
Set<Instance> answering = const {},
Map<Instance, InstanceLocations> locations = const {},
SubdivisionNames subdivisionNames = const MemorySubdivisionNames({}),
}) async {
tester.view.physicalSize = const Size(412, 900);
tester.view.devicePixelRatio = 1;
@ -68,7 +69,10 @@ void main() {
checker: FakeInstanceChecker(answering, locations),
countryNames: MemoryCountryNames(const {
'CH': {'en': 'Switzerland'},
'DE': {'en': 'Germany'},
'US': {'en': 'United States'},
}),
subdivisionNames: subdivisionNames,
readLook: () async => (themeMode: ThemeMode.light, locale: null),
open: (instance) async {
opened.add(instance);
@ -127,6 +131,30 @@ void main() {
expect(find.byType(Flag), findsOne);
});
testWidgets('an instance may say where more precisely: a state, a region', (
tester,
) async {
await start(
tester,
answering: {builtIn},
locations: {
builtIn: const InstanceLocations(data: 'US-CA', backups: 'DE-BY'),
},
subdivisionNames: const MemorySubdivisionNames({
'DE-BY': {'en': 'Bavaria'},
'US-CA': {'en': 'California'},
}),
);
expect(
find.text(
'Data: California, United States\nBackups: Bavaria, Germany (EU)',
),
findsOne,
);
expect(find.byType(Flag), findsOne);
});
testWidgets('an instance saying nothing, or not answering, comes with the '
'app, without a flag', (tester) async {
await start(tester);