Files
ReVoltVPN/lib/main.dart
T
esefxdzandClaude Opus 5 6fcde9dd7b refactor(app): debloat 3.3.1 and fix startup restoration
Maintainer changes on top of PR #2 (Naveax). Reduces the release to two
deliberate connection modes and resolves the issues found in review:

- Lock-screen privacy: move VISIBILITY_PRIVATE and a generic publicVersion
  into MainActivity.updateVpnNotification. The PR's fix lived in an
  unreferenced class and never reached the live notification.
- Haptics: restore the default to off, and reduce HapticSettings to a
  single success() on connect/disconnect via the native channel.
- SOCKS5: make it a real proxyOnly local-proxy mode rather than a TUN
  connection under a different label. TUN stays the default.
- Health probe: restore the idle-only guard so /health is no longer polled
  every 30s while connected.
- Recovery: add a _connectionEpoch counter so connect() aborts an
  in-flight Extreme recovery.
- Startup restoration: rebuild the recovery snapshot from the still-active
  session after an app-process restart (TUN), and surface an honest
  orphaned state with a Reconnect action in proxy mode.

Drops per-app routing entirely. It only ever functioned in TUN --
addDisallowedApplication lives inside the VPN-interface setup that
proxyOnly skips -- and its allowlist half had no Dart caller.

Also removes flutter_local_notifications, the global tap-haptic surface,
and unused runtime telemetry.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-31 23:31:51 +03:00

90 lines
2.8 KiB
Dart

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:revoltvpn/logic/ad_manager.dart';
import 'package:revoltvpn/logic/app_colors.dart';
import 'package:revoltvpn/logic/connection_settings.dart';
import 'package:revoltvpn/logic/haptic_settings.dart';
import 'package:revoltvpn/logic/server_list.dart';
import 'package:revoltvpn/logic/session_timer.dart';
import 'package:revoltvpn/logic/vpn_connection.dart';
import 'package:revoltvpn/screens/intro.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await HapticSettings.initialize();
await ConnectionSettings.initialize();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
systemNavigationBarColor: Color(0xFF0D1117),
systemNavigationBarIconBrightness: Brightness.light,
));
FlutterError.onError = (details) {
debugPrint('[FlutterError] ${details.exception}');
};
PlatformDispatcher.instance.onError = (error, stack) {
debugPrint('[PlatformError] $error\n$stack');
return true;
};
runApp(const ReVoltApp());
}
class ReVoltApp extends StatelessWidget {
const ReVoltApp({super.key});
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => VpnConnection(), lazy: false),
ChangeNotifierProxyProvider<VpnConnection, SessionTimer>(
create: (ctx) =>
SessionTimer(vpnConnection: ctx.read<VpnConnection>()),
update: (_, vpn, prev) =>
prev ?? SessionTimer(vpnConnection: vpn),
),
ChangeNotifierProvider(create: (_) => AdManager()),
ChangeNotifierProvider(
create: (_) => ServerList()..init(),
lazy: false,
),
],
child: MaterialApp(
title: 'ReVolt VPN',
debugShowCheckedModeBanner: false,
theme: _buildDarkTheme(),
home: const IntroScreen(),
),
);
}
ThemeData _buildDarkTheme() {
return ThemeData(
brightness: Brightness.dark,
scaffoldBackgroundColor: AppColors.bgDeep,
colorScheme: const ColorScheme.dark(
primary: AppColors.accent,
secondary: AppColors.accent,
surface: AppColors.bgSurface,
),
fontFamily: 'Roboto',
snackBarTheme: SnackBarThemeData(
backgroundColor: AppColors.bgCard,
contentTextStyle: const TextStyle(color: AppColors.textWhite),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
behavior: SnackBarBehavior.floating,
),
useMaterial3: true,
);
}
}