Skip to content
Merged
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
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
flutter_v2ray: 21ee520e013877941e2e67b3b48aed9c6870e8dc
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
flutter_v2ray: 1190bb389b67a1dc9f28ece1d4b308101e38395e
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7

PODFILE CHECKSUM: f8e15f817b1bf5846cb6aad560a31cf33c165196

Expand Down
72 changes: 66 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';

import 'package:vpn_client/pages/apps/apps_page.dart';
import 'package:vpn_client/pages/main/main_page.dart';
import 'package:vpn_client/pages/servers/servers_page.dart';
import 'package:vpn_client/pages/settings/settings_page.dart';
import 'package:vpn_client/pages/speed/speed_page.dart';
import 'package:vpn_client/providers/vpn_provider.dart';
import 'package:vpn_client/pages/servers/servers_page.dart';
import 'package:vpn_client/theme_provider.dart';
import 'package:vpn_client/vpn_state.dart';

import 'design/colors.dart';
import 'nav_bar.dart';

void main() {
runApp(MultiProvider(providers: [ChangeNotifierProvider(create: (_) => ThemeProvider()), ChangeNotifierProvider(create: (_) => VPNProvider())], child: const App()));
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => ThemeProvider()),
ChangeNotifierProvider(create: (_) => VpnState()),
],
child: const App(),
),
);
}

class App extends StatelessWidget {
Expand All @@ -22,13 +32,54 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);

// If you want to override it manually, do it here (or leave as null to use system):
// final Locale? manualLocale = const Locale('ru'); // ← override example
final Locale? manualLocale = null; // ← use system by default

return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'VPN Client',
theme: lightTheme,
darkTheme: darkTheme,
locale: manualLocale,
localeResolutionCallback: (locale, supportedLocales) {
if (locale == null) return const Locale('en');

// Check for exact match
for (var supportedLocale in supportedLocales) {
if (supportedLocale.languageCode == locale.languageCode &&
(supportedLocale.countryCode == null ||
supportedLocale.countryCode == locale.countryCode)) {
return supportedLocale;
}
}

// If Chinese variants are not supported, fallback to zh
if (locale.languageCode == 'zh') {
return supportedLocales.contains(const Locale('zh'))
? const Locale('zh')
: const Locale('en');
}

// Fallback to 'en' if not found
return const Locale('en');
},

themeMode: themeProvider.themeMode,
home: const MainScreen(),

localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en'),
Locale('ru'),
Locale('th'),
Locale('zh'),
],
);
}
}
Expand All @@ -51,7 +102,7 @@ class _MainScreenState extends State<MainScreen> {
const AppsPage(),
ServersPage(onNavBarTap: _handleNavBarTap),
const MainPage(),
const SpeedPage(),
const PlaceholderPage(text: 'Speed Page'),
const SettingsPage(),
];
}
Expand All @@ -69,8 +120,17 @@ class _MainScreenState extends State<MainScreen> {
bottomNavigationBar: NavBar(
initialIndex: _currentIndex,
onItemTapped: _handleNavBarTap,
selectedColor: Theme.of(context).colorScheme.primary,
),
);
}
}

class PlaceholderPage extends StatelessWidget {
final String text;
const PlaceholderPage({super.key, required this.text});

@override
Widget build(BuildContext context) {
return Center(child: Text(text));
}
}
26 changes: 22 additions & 4 deletions lib/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class SettingsPage extends StatelessWidget {
const SettingsPage({Key? key}) : super(key: key);
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});

@override
_SettingsPageState createState() => _SettingsPageState();
}

class _SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
return const Center(child: Text('Settings Page'));
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.app_name),
),
body: Center(
child: ElevatedButton(
child: const Text("Help! Coding flutter requires a lot of work!"),
onPressed: () {
Navigator.pop(context);
},
),
),
);
}
}
}
8 changes: 1 addition & 7 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- vpnclient_engine_flutter (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
- vpnclient_engine_flutter (from `Flutter/ephemeral/.symlinks/plugins/vpnclient_engine_flutter/macos`)

EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
shared_preferences_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
vpnclient_engine_flutter:
:path: Flutter/ephemeral/.symlinks/plugins/vpnclient_engine_flutter/macos

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
vpnclient_engine_flutter: d018814c86b1c8e99306e2bb838df8dea9fb0971
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7

PODFILE CHECKSUM: 7eb978b976557c8c1cd717d8185ec483fd090a82

Expand Down
4 changes: 0 additions & 4 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
Expand Down
Loading