polish: strip verbose comments, simplify codebase
This commit is contained in:
1 parent
a32252c56d
commit
35bfeb61c4
16 files changed
+26
-147
No files matched your search
@@ -3,13 +3,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:revoltvpn/logic/app_colors.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
|
||||
/// ClockDisplay renders inside the ConnectButton circle when the VPN is active.
|
||||
///
|
||||
/// Shows a circular quota-progress arc, a glowing countdown timer, and the
|
||||
/// current transfer speed — all sized to fit within the 260px button.
|
||||
///
|
||||
/// Before the first server sync arrives, a subtle "Syncing…" placeholder
|
||||
/// is shown instead of a misleading 00:00:00.
|
||||
class ClockDisplay extends StatelessWidget {
|
||||
const ClockDisplay({super.key});
|
||||
|
||||
|
||||
@@ -6,14 +6,6 @@ import 'package:revoltvpn/logic/vpn_connection.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
import 'package:revoltvpn/logic/ad_manager.dart';
|
||||
|
||||
/// ConnectButton — circle with brand.png + pulsing glow when connected.
|
||||
///
|
||||
/// Rules:
|
||||
/// disconnected → connect (ad → config → tunnel)
|
||||
/// connecting → disconnect (cancel)
|
||||
/// connected → disconnect
|
||||
/// error → connect (retry)
|
||||
/// disconnecting → ignore
|
||||
class ConnectButton extends StatefulWidget {
|
||||
const ConnectButton({super.key});
|
||||
|
||||
@@ -59,7 +51,7 @@ class _ConnectButtonState extends State<ConnectButton>
|
||||
}
|
||||
|
||||
Future<void> _handleTap() async {
|
||||
// 1-second cooldown to prevent spam
|
||||
|
||||
final now = DateTime.now();
|
||||
if (now.difference(_lastTap).inMilliseconds < 1000) return;
|
||||
_lastTap = now;
|
||||
@@ -70,7 +62,7 @@ class _ConnectButtonState extends State<ConnectButton>
|
||||
final timer = context.read<SessionTimer>();
|
||||
final ad = context.read<AdManager>();
|
||||
|
||||
// ── Disconnect if connected or connecting ───────────────────────────
|
||||
|
||||
if (vpn.status == VpnStatus.connected || vpn.status == VpnStatus.connecting) {
|
||||
_busy = false;
|
||||
timer.stop(); // MUST stop timer BEFORE disconnect — prevents auto-reconnect
|
||||
@@ -78,10 +70,10 @@ class _ConnectButtonState extends State<ConnectButton>
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Ignore if disconnecting ─────────────────────────────────────────
|
||||
|
||||
if (vpn.status == VpnStatus.disconnecting) return;
|
||||
|
||||
// ── Connect (or retry) ─────────────────────────────────────────────
|
||||
|
||||
if (_busy) return;
|
||||
|
||||
setState(() => _busy = true);
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:revoltvpn/logic/app_colors.dart';
|
||||
|
||||
/// OnlineDot displays a glowing green dot when the server is healthy,
|
||||
/// and a muted gray dot when disconnected or still syncing.
|
||||
class OnlineDot extends StatelessWidget {
|
||||
/// Whether the server has been confirmed reachable.
|
||||
final bool isOnline;
|
||||
|
||||
/// Optional custom label. Falls back to "Server Online" / "Disconnected".
|
||||
final String? label;
|
||||
|
||||
const OnlineDot({
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:revoltvpn/logic/app_colors.dart';
|
||||
class DiscordLinkButton extends StatelessWidget {
|
||||
const DiscordLinkButton({super.key});
|
||||
|
||||
/// Public entry point for the sidebar or any other widget.
|
||||
static Future<void> launchDiscord() async {
|
||||
final Uri url = Uri.parse('https://discord.gg/revoltvpn');
|
||||
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
||||
|
||||
@@ -4,17 +4,9 @@ import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
import 'package:revoltvpn/logic/app_colors.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
/// GdprButton lets the user review or change their ad consent choices.
|
||||
///
|
||||
/// When tapped, it tries to show Google's UMP consent form so the user
|
||||
/// can adjust their preferences (personalized vs non-personalized ads).
|
||||
/// If the form isn't available (e.g. user is outside the EEA), it falls
|
||||
/// back to opening the privacy policy instead.
|
||||
class GdprButton extends StatelessWidget {
|
||||
const GdprButton({super.key});
|
||||
|
||||
/// Public entry point so the sidebar (or any other widget) can trigger
|
||||
/// the consent flow without embedding an IconButton.
|
||||
static Future<void> showConsentForm() async {
|
||||
try {
|
||||
// If the form is already available, show it directly — no need to
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:revoltvpn/logic/app_colors.dart';
|
||||
class InfoButton extends StatelessWidget {
|
||||
const InfoButton({super.key});
|
||||
|
||||
/// Public entry point for the sidebar or any other widget.
|
||||
static Future<void> launchGitHub() async {
|
||||
final Uri url = Uri.parse('https://github.com/esefxdz/ReVoltVPN');
|
||||
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:revoltvpn/logic/app_colors.dart';
|
||||
class PrivacyPolicyButton extends StatelessWidget {
|
||||
const PrivacyPolicyButton({super.key});
|
||||
|
||||
/// Public entry point for the sidebar or any other widget.
|
||||
static Future<void> launchPrivacyPolicy() async {
|
||||
final Uri url = Uri.parse('https://github.com/esefxdz/ReVoltVPN/blob/main/PRIVACY_POLICY.md');
|
||||
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
||||
|
||||
@@ -5,8 +5,6 @@ import 'package:revoltvpn/components/sidebar_contents/privacy_policy_button.dart
|
||||
import 'package:revoltvpn/components/sidebar_contents/info_button.dart';
|
||||
import 'package:revoltvpn/components/sidebar_contents/discord_link_button.dart';
|
||||
|
||||
/// Right-edge drawer. Four fully-tappable rows — tap anywhere on a row
|
||||
/// to trigger its action and close the drawer.
|
||||
class SidebarDrawer extends StatelessWidget {
|
||||
const SidebarDrawer({super.key});
|
||||
|
||||
@@ -19,7 +17,6 @@ class SidebarDrawer extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// ── Header ──────────────────────────────────────────────────
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 24, 20, 20),
|
||||
decoration: const BoxDecoration(
|
||||
@@ -51,7 +48,6 @@ class SidebarDrawer extends StatelessWidget {
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// ── Ad Consent (fully tappable) ─────────────────────────────
|
||||
_Row(
|
||||
icon: Icons.admin_panel_settings_outlined,
|
||||
label: 'Ad Consent',
|
||||
@@ -61,7 +57,6 @@ class SidebarDrawer extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
|
||||
// ── Privacy Policy (fully tappable) ─────────────────────────
|
||||
_Row(
|
||||
icon: Icons.privacy_tip_outlined,
|
||||
label: 'Privacy Policy',
|
||||
@@ -71,7 +66,6 @@ class SidebarDrawer extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
|
||||
// ── About (fully tappable) ──────────────────────────────────
|
||||
_Row(
|
||||
icon: Icons.help_outline,
|
||||
label: 'About',
|
||||
@@ -81,7 +75,6 @@ class SidebarDrawer extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
|
||||
// ── Discord (fully tappable) ────────────────────────────────
|
||||
_Row(
|
||||
icon: Icons.discord,
|
||||
label: 'Discord',
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:revoltvpn/logic/app_colors.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
|
||||
/// SpeedBox — a small card showing current network speed or "Idle".
|
||||
class SpeedBox extends StatelessWidget {
|
||||
const SpeedBox({super.key});
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import 'package:revoltvpn/logic/vpn_connection.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
import 'package:revoltvpn/components/online_dot.dart';
|
||||
|
||||
/// StatusBar — unified bottom card combining the Finland connection badge
|
||||
/// and the server health indicator in one box.
|
||||
class StatusBar extends StatelessWidget {
|
||||
const StatusBar({super.key});
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:revoltvpn/logic/app_colors.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
|
||||
/// TimerBox — a rectangular card showing the session countdown.
|
||||
class TimerBox extends StatelessWidget {
|
||||
const TimerBox({super.key});
|
||||
|
||||
|
||||
Reference in new issue
Block a user