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 = '🇮🇳'; emoji = '🇮🇳';
break; break;
case 'syd':
emoji = '🇦🇺';
break;
case 'nyc': case 'nyc':
case 'sfo': case 'sfo':
emoji = '🇺🇸'; emoji = '🇺🇸';
break; break;
} }
return emoji; 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() @JsonSerializable()

View File

@ -155,6 +155,24 @@ class HetznerLocation {
} }
return emoji; 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. /// A Volume is a highly-available, scalable, and SSD-based block storage for Servers.

View File

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

View File

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

View File

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

View File

@ -120,6 +120,14 @@ class SelectLocationPage extends StatelessWidget {
.titleMedium, .titleMedium,
), ),
const SizedBox(height: 8), 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) if (location.description != null)
Text( Text(
location.description!, location.description!,