Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions assets/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ msgstr "Automatically chooses fastest location"
msgid "pro_locations"
msgstr "Pro locations:"

msgid "currently_unavailable"
msgstr "Currently Unavailable:"

msgid "choose_your_location_with_lantern_pro"
msgstr "Choose your location with Lantern Pro:"

Expand Down Expand Up @@ -937,21 +934,6 @@ msgstr "Private Servers"
msgid "fastest_server"
msgstr "Fastest Server"

msgid "server_may_be_unreachable"
msgstr "May be unreachable"

msgid "server_may_be_unreachable_title"
msgstr "This Server may be unreachable"

msgid "server_may_be_unreachable_message"
msgstr "This Server may not work from your current network. Use Smart Location to pick a working server automatically."

msgid "use_smart_location"
msgstr "Use Smart Location"

msgid "try_anyway"
msgstr "Try Anyway"

msgid "join_my_private_server"
msgstr "Join My Lantern Private Server"

Expand Down Expand Up @@ -1672,4 +1654,3 @@ msgid "configuration_message"
msgstr "Your old configuration has been cleared. Turn the VPN on to automatically download the latest."



1 change: 0 additions & 1 deletion lib/core/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export 'package:lantern/core/widgets/lantern_logo.dart';
export 'package:lantern/core/widgets/platform_card.dart';
export 'package:lantern/core/widgets/pro_banner.dart';
export 'package:lantern/core/widgets/pro_button.dart';
export 'package:lantern/core/widgets/server_reachability_warning_icon.dart';
export 'package:lantern/features/home/data_usage.dart';

export '../../core/widgets/divider_space.dart';
Expand Down
29 changes: 0 additions & 29 deletions lib/core/widgets/server_reachability_warning_icon.dart

This file was deleted.

20 changes: 1 addition & 19 deletions lib/features/vpn/location_setting.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:lantern/core/widgets/setting_tile.dart';
import 'package:lantern/features/vpn/provider/available_servers_notifier.dart';
import 'package:lantern/features/vpn/provider/server_location_notifier.dart';

import '../../core/common/common.dart';
Expand All @@ -13,17 +12,6 @@ class LocationSetting extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final serverLocation = ref.watch(serverLocationProvider);
final serverType = serverLocation.serverType.toServerLocationType;
final selectedServer = ref
.watch(availableServersProvider)
.maybeWhen(
data: (servers) => servers.serverByTag(serverLocation.serverName),
orElse: () => null,
);
final isManualLanternLocation =
serverType == ServerLocationType.lanternLocation;
final shouldWarnBeforeManualSelection =
isManualLanternLocation &&
selectedServer?.shouldWarnBeforeManualSelection == true;

String title = '';
String value = '';
Expand Down Expand Up @@ -62,17 +50,11 @@ class LocationSetting extends HookConsumerWidget {
tileKey: const Key('home.location_setting'),
label: title,
value: value.i18n,
subtitle: shouldWarnBeforeManualSelection
? 'server_may_be_unreachable'.i18n
: protocol,
subtitle: protocol,
icon: flag.isEmpty ? AppImagePaths.location : Flag(countryCode: flag),
actions: [
if (serverType == ServerLocationType.auto)
AppImage(path: AppImagePaths.blot, useThemeColor: false),
if (shouldWarnBeforeManualSelection) ...[
const ServerReachabilityWarningIcon(),
const SizedBox(width: 8),
],
const SizedBox(width: 8),
IconButton(
onPressed: () => appRouter.push(const ServerSelection()),
Expand Down
163 changes: 5 additions & 158 deletions lib/features/vpn/server_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,49 +346,10 @@ class _ServerLocationListViewState
return const Center(child: Text("No locations available"));
}

final List<Widget> sections;
if (widget.userPro) {
// Pro users get the reachable / currently-unavailable split.
final reachableLocations = allLocations
.where((s) => !s.shouldWarnBeforeManualSelection)
.toList();
final unavailableLocations =
allLocations
.where((s) => s.shouldWarnBeforeManualSelection)
.toList()
..sort(_compareServersByLocation);

sections = [
if (reachableLocations.isNotEmpty) ...[
_sectionHeader('pro_locations'.i18n),
_sectionCard(
_reachableLocationTiles(
reachableLocations,
selectedTag,
),
),
],
if (unavailableLocations.isNotEmpty) ...[
SizedBox(height: reachableLocations.isEmpty ? 4 : size24),
_sectionHeader('currently_unavailable'.i18n),
_sectionCard(
_unavailableLocationTiles(
unavailableLocations,
selectedTag,
),
),
],
];
} else {
// Free users see every location in a single list, without the
// reachable / unavailable distinction.
sections = [
_sectionHeader('pro_locations'.i18n),
_sectionCard(
_reachableLocationTiles(allLocations, selectedTag),
),
];
}
final sections = [
_sectionHeader('pro_locations'.i18n),
_sectionCard(_locationTiles(allLocations, selectedTag)),
];

return Stack(
children: [
Expand Down Expand Up @@ -445,10 +406,7 @@ class _ServerLocationListViewState
);
}

List<Widget> _reachableLocationTiles(
List<Server> locations,
String selectedTag,
) {
List<Widget> _locationTiles(List<Server> locations, String selectedTag) {
final grouped = _groupLocationsByCountry(locations);
final countryEntries = grouped.entries.toList()
..sort((a, b) => a.key.compareTo(b.key));
Expand All @@ -464,7 +422,6 @@ class _ServerLocationListViewState
onServerSelected: onServerSelected,
server: serverData,
isSelected: selectedTag == serverData.tag,
showReachabilityWarning: widget.userPro,
);
}

Expand All @@ -473,22 +430,6 @@ class _ServerLocationListViewState
locations: countryLocations,
selectedServerTag: selectedTag,
onServerSelected: onServerSelected,
showReachabilityWarning: widget.userPro,
);
}).toList();
}

List<Widget> _unavailableLocationTiles(
List<Server> locations,
String selectedTag,
) {
return locations.map((server) {
return SingleCityServerView(
key: ValueKey(server.tag),
onServerSelected: onServerSelected,
server: server,
isSelected: selectedTag == server.tag,
showReachabilityWarning: widget.userPro,
);
}).toList();
}
Expand All @@ -504,14 +445,6 @@ class _ServerLocationListViewState
return children;
}

int _compareServersByLocation(Server a, Server b) {
final country = a.location.country.compareTo(b.location.country);
if (country != 0) return country;
final city = a.location.city.compareTo(b.location.city);
if (city != 0) return city;
return a.tag.compareTo(b.tag);
}

Future<void> onServerSelected(Server selectedServer) async {
if (PlatformUtils.isMacOS) {
/// Check for if extension permission is granted before connecting to server, if not show the permission dialog first
Expand All @@ -522,87 +455,9 @@ class _ServerLocationListViewState
}
}

// The unreachable-server warning is part of the Pro reachability
// experience; free users select any location without it.
if (widget.userPro && selectedServer.shouldWarnBeforeManualSelection) {
_showManualServerWarning(selectedServer);
return;
}

await _connectToServer(selectedServer);
}

void _showManualServerWarning(Server selectedServer) {
AppDialog.customDialog(
context: context,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 24),
const Center(child: ServerReachabilityWarningIcon(size: 48)),
const SizedBox(height: 16),
Center(
child: Text(
'server_may_be_unreachable_title'.i18n,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineMedium,
),
),
const SizedBox(height: 16),
Text(
'server_may_be_unreachable_message'.i18n,
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
action: [
AppTextButton(
label: 'try_anyway'.i18n,
textColor: context.textTertiary,
onPressed: () async {
appRouter.maybePop();
await _connectToServer(selectedServer);
},
),
AppTextButton(
label: 'use_smart_location'.i18n,
onPressed: () async {
appRouter.maybePop();
await _switchToSmartLocation();
},
),
],
);
}

Future<void> _switchToSmartLocation({bool skipConflictCheck = false}) async {
final result = await ref
.read(vpnProvider.notifier)
.startVPN(force: true, skipConflictCheck: skipConflictCheck);
if (!mounted) return;

result.fold(
(failure) {
if (failure is VpnConflictFailure) {
AppDialog.vpnConflictDialog(
context: context,
onConnectAnyway: () async {
appRouter.maybePop();
await _switchToSmartLocation(skipConflictCheck: true);
},
);
} else {
context.showSnackBar(failure.localizedErrorMessage);
}
},
(_) async {
await ref.read(serverLocationProvider.notifier).switchToAuto();
appRouter.popUntilRoot();
},
);
}

Future<void> _connectToServer(Server selectedServer) async {
final result = await ref
.read(vpnProvider.notifier)
Expand Down Expand Up @@ -679,14 +534,12 @@ class _CountryCityListView extends StatefulWidget {
final List<Server> locations;
final String selectedServerTag;
final OnServerSelected onServerSelected;
final bool showReachabilityWarning;

const _CountryCityListView({
required this.country,
required this.locations,
required this.selectedServerTag,
required this.onServerSelected,
this.showReachabilityWarning = true,
});

@override
Expand Down Expand Up @@ -739,11 +592,6 @@ class _CountryCityListViewState extends State<_CountryCityListView> {
color: context.textSecondary,
),
),
trailing: !widget.showReachabilityWarning
? null
: server.isProbedUnreachable
? const ServerReachabilityWarningIcon()
: null,
tileTextStyle: Theme.of(
context,
).textTheme.bodyMedium!.copyWith(color: context.textPrimary),
Expand Down Expand Up @@ -789,7 +637,6 @@ class _CountryCityListViewState extends State<_CountryCityListView> {

return SingleCityServerView(
nested: true,
showReachabilityWarning: widget.showReachabilityWarning,
onServerSelected: (selected) {
Navigator.of(bottomSheetContext).pop();
widget.onServerSelected(selected);
Expand Down
13 changes: 1 addition & 12 deletions lib/features/vpn/single_city_server_view.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import 'package:flutter/material.dart';
import 'package:lantern/core/models/available_servers.dart';
import 'package:lantern/features/vpn/server_selection.dart';

import '../../core/common/common.dart';

// single_city_server_view.dart

class SingleCityServerView extends StatefulWidget {
final Server server;
final OnServerSelected onServerSelected;
final ValueChanged<Server> onServerSelected;
final bool isSelected;
final bool nested;

/// Whether to surface the "may be unreachable" warning icon. Disabled for
/// free users, who see every location without the reachability distinction.
final bool showReachabilityWarning;

const SingleCityServerView({
Comment on lines 11 to 14
super.key,
required this.onServerSelected,
required this.server,
this.isSelected = false,
this.nested = false,
this.showReachabilityWarning = true,
});

@override
Expand All @@ -48,11 +42,6 @@ class _SingleCityServerViewState extends State<SingleCityServerView> {
color: context.textTertiary,
),
),
trailing: !widget.showReachabilityWarning
? null
: widget.server.isProbedUnreachable
? const ServerReachabilityWarningIcon()
: null,
icon: Flag(countryCode: widget.server.location.countryCode),
onPressed: () {
widget.onServerSelected(widget.server);
Expand Down
Loading