CTK 1.2.0
This commit is contained in:
@@ -12,8 +12,7 @@ class Clinic {
|
||||
required this.lat,
|
||||
required this.lon,
|
||||
required this.address,
|
||||
required this.phone,
|
||||
required this.hasPhone,
|
||||
required this.phoneNumbers,
|
||||
required this.openingHours,
|
||||
required this.hasOpeningHours,
|
||||
this.distanceKm,
|
||||
@@ -24,11 +23,17 @@ class Clinic {
|
||||
final double lat;
|
||||
final double lon;
|
||||
final String address;
|
||||
final String phone;
|
||||
final bool hasPhone;
|
||||
|
||||
/// Um consultório na OSM pode ter mais do que um contacto na mesma tag
|
||||
/// `phone` (separados por `;`/`,`) — já vêm separados aqui, para quem usa
|
||||
/// isto poder oferecer escolha em vez de tentar ligar para o texto todo
|
||||
/// de uma vez. Lista vazia quando não há telefone.
|
||||
final List<String> phoneNumbers;
|
||||
final String openingHours;
|
||||
final bool hasOpeningHours;
|
||||
|
||||
bool get hasPhone => phoneNumbers.isNotEmpty;
|
||||
|
||||
/// Distância (km) até à morada guardada — só preenchida depois de
|
||||
/// [OverpassService.fetchNearbyClinics] a calcular; `null` até lá.
|
||||
final double? distanceKm;
|
||||
@@ -40,8 +45,7 @@ class Clinic {
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
address: address,
|
||||
phone: phone,
|
||||
hasPhone: hasPhone,
|
||||
phoneNumbers: phoneNumbers,
|
||||
openingHours: openingHours,
|
||||
hasOpeningHours: hasOpeningHours,
|
||||
distanceKm: distanceKm,
|
||||
@@ -76,10 +80,16 @@ class Clinic {
|
||||
(tags['addr:city'] ?? tags['addr:suburb']),
|
||||
].whereType<String>().where((s) => s.trim().isNotEmpty).toList();
|
||||
|
||||
final phone = (tags['phone'] as String?)?.trim() ??
|
||||
final phoneRaw = (tags['phone'] as String?)?.trim() ??
|
||||
(tags['contact:phone'] as String?)?.trim();
|
||||
final phoneNumbers = (phoneRaw == null || phoneRaw.isEmpty)
|
||||
? const <String>[]
|
||||
: phoneRaw
|
||||
.split(RegExp(r'[;,]'))
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
final openingHours = (tags['opening_hours'] as String?)?.trim();
|
||||
final hasPhone = phone != null && phone.isNotEmpty;
|
||||
final hasOpeningHours = openingHours != null && openingHours.isNotEmpty;
|
||||
|
||||
return Clinic(
|
||||
@@ -92,8 +102,7 @@ class Clinic {
|
||||
address: addressParts.isNotEmpty
|
||||
? addressParts.join(' • ')
|
||||
: ConsultoriosStrings.noAddress,
|
||||
phone: hasPhone ? phone : ConsultoriosStrings.noPhone,
|
||||
hasPhone: hasPhone,
|
||||
phoneNumbers: phoneNumbers,
|
||||
openingHours: hasOpeningHours
|
||||
? openingHours
|
||||
: ConsultoriosStrings.noOpeningHours,
|
||||
|
||||
Reference in New Issue
Block a user