feat: Add country names to installation process

- Resolve: #494
pull/501/head
NaiJi ✨ 2024-04-17 00:00:20 +04:00
parent c179a109fd
commit 6dc4109e0d
6 changed files with 74 additions and 1 deletions

View File

@ -65,14 +65,56 @@ class DigitalOceanLocation {
emoji = '🇮🇳';
break;
case 'syd':
emoji = '🇦🇺';
break;
case 'nyc':
case 'sfo':
emoji = '🇺🇸';
break;
}
return emoji;
}
String get countryDisplayName {
String displayName = slug;
switch (slug.substring(0, 3)) {
case 'fra':
displayName = 'Germany';
break;
case 'ams':
displayName = 'Netherlands';
break;
case 'sgp':
displayName = 'Singapore';
break;
case 'lon':
displayName = 'United Kingdom';
break;
case 'tor':
displayName = 'Canada';
break;
case 'blr':
displayName = 'India';
break;
case 'syd':
displayName = 'Australia';
break;
case 'nyc':
case 'sfo':
displayName = 'United States';
break;
}
return displayName;
}
}
@JsonSerializable()

View File

@ -155,6 +155,24 @@ class HetznerLocation {
}
return emoji;
}
String get countryDisplayName {
String displayName = country;
switch (country.substring(0, 2)) {
case 'DE':
displayName = 'Germany';
break;
case 'FI':
displayName = 'Finland';
break;
case 'US':
displayName = 'United States';
break;
}
return displayName;
}
}
/// A Volume is a highly-available, scalable, and SSD-based block storage for Servers.

View File

@ -2,12 +2,14 @@ class ServerProviderLocation {
ServerProviderLocation({
required this.title,
required this.identifier,
required this.country,
this.description,
this.flag = '',
});
final String title;
final String identifier;
final String country;
final String? description;
final String flag;
}

View File

@ -438,6 +438,7 @@ class DigitalOceanServerProvider extends ServerProvider {
description: rawLocation.name,
flag: rawLocation.flag,
identifier: rawLocation.slug,
country: rawLocation.countryDisplayName,
);
} catch (e) {
continue;

View File

@ -156,6 +156,7 @@ class HetznerServerProvider extends ServerProvider {
description: server.location.description,
flag: server.location.flag,
identifier: server.location.name,
country: server.location.countryDisplayName,
),
),
);
@ -456,6 +457,7 @@ class HetznerServerProvider extends ServerProvider {
description: rawLocation.description,
flag: rawLocation.flag,
identifier: rawLocation.name,
country: rawLocation.countryDisplayName,
);
} catch (e) {
continue;

View File

@ -120,6 +120,14 @@ class SelectLocationPage extends StatelessWidget {
.titleMedium,
),
const SizedBox(height: 8),
Text(
location.country,
style: Theme.of(context)
.textTheme
.bodyMedium,
),
if (location.description != null)
const SizedBox(height: 4),
if (location.description != null)
Text(
location.description!,