Notification is added

This commit is contained in:
esefxdz committed 2026-05-31 12:48:37 +03:00
1 parent afe7fb578a
commit a80a23e008
7 files changed
+153 -2

No files matched your search

+17
View File
@@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
import 'package:paladinvpn/logic/app_config.dart';
import 'package:paladinvpn/logic/vpn_connection.dart';
import 'package:paladinvpn/logic/crypto_service.dart';
import 'package:paladinvpn/components/notification.dart';
/// SessionTimer acts as the client-side session authority for the VPN tunnel.
///
@@ -51,6 +52,16 @@ class SessionTimer extends ChangeNotifier {
return '${gb.toStringAsFixed(2)} GB';
}
String get formattedDataUsed {
if (_usedBytes == 0) return '0.00 MB';
if (_usedBytes > 1024 * 1024 * 1024) {
final gb = _usedBytes / (1024 * 1024 * 1024);
return '${gb.toStringAsFixed(2)} GB';
}
final mb = _usedBytes / (1024 * 1024);
return '${mb.toStringAsFixed(2)} MB';
}
double get progress {
// Max duration is generally 60 or 90 minutes. We'll base the ring purely on data usage or just standard time
// For UI simplicity, we'll return data progress:
@@ -119,6 +130,11 @@ class SessionTimer extends ChangeNotifier {
}
_lastUsedBytes = _usedBytes;
VpnNotificationManager.showOrUpdateStatus(
timeLeft: formatted,
speedKbps: '${_currentSpeedKbps.toStringAsFixed(2)} KB/s',
);
notifyListeners();
} else if (response.statusCode == 404) {
// Peer not found on server (expired/deleted natively)
@@ -159,6 +175,7 @@ class SessionTimer extends ChangeNotifier {
_timer = null;
_remainingSeconds = 0;
_currentSpeedKbps = 0.0;
VpnNotificationManager.cancel();
notifyListeners();
}