Skip to content

Commit 3ca7a54

Browse files
committed
add base
1 parent 15045e7 commit 3ca7a54

File tree

15 files changed

+783
-116
lines changed

15 files changed

+783
-116
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ OmidVPN is a simple, lightweight, and secure OpenVPN client for Android that all
2929
- 🔒 **Secure Connection**: Connect to VPN servers with strong encryption
3030
- 🌍 **Global Servers**: Access servers from various countries around the world
3131
-**Fast & Lightweight**: Minimal resource usage for optimal performance
32-
- 💰 **Completely Free**: No ads, no subscriptions, no hidden fees
32+
- 💰 **Free with Premium Options**: Free to use with optional premium license for additional servers
3333
- 🚫 **No Tracking**: Respects your privacy with zero data collection
3434
- 📱 **Modern UI**: Clean and intuitive user interface built with Flutter
3535
- 🎯 **Easy to Use**: Simple one-tap connection to VPN servers
@@ -86,6 +86,7 @@ OmidVPN respects your privacy. We do not:
8686
- Telegram: [@h3dev](https://t.me/h3dev)
8787
8888
- Instagram: [@h3dev.pira](https://instagram.com/h3dev.pira)
89+
- X (Twitter): [@albert_com32388](https://x.com/albert_com32388)
8990

9091
## 🤝 Contributing
9192

lib/api/api/api.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,7 @@ final vpngateRepositoryProvider = FutureProvider((Ref ref) async {
7676
baseURL:
7777
'https://raw.githubusercontent.com/fdciabdul/Vpngate-Scraper-API/refs/heads/main/json/data.json',
7878
),
79-
additionalSources: [
80-
JsonServerRemoteSource(
81-
dio: dio,
82-
baseURL:
83-
'https://raw.githubusercontent.com/code3-dev/omidvpn-api/refs/heads/master/api/index.json',
84-
),
85-
],
79+
additionalSources: [], // We'll add premium sources dynamically when fetching
8680
localSource: cacheManager,
8781
cacheKey: 'json_servers.json',
8882
);

lib/api/domain/entity/server_info.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ServerInfo {
1414
final String operator;
1515
final String message;
1616
final String vpnConfig;
17+
final bool isPremium; // Add this field to track premium servers
1718

1819
ServerInfo({
1920
required this.hostName,
@@ -31,6 +32,7 @@ class ServerInfo {
3132
required this.operator,
3233
required this.message,
3334
required this.vpnConfig,
35+
this.isPremium = false, // Default to false
3436
});
3537

3638
ServerInfo.empty()
@@ -48,7 +50,8 @@ class ServerInfo {
4850
logType = '',
4951
operator = '',
5052
message = '',
51-
vpnConfig = '';
53+
vpnConfig = '',
54+
isPremium = false;
5255

5356
copyWith({
5457
String? hostName,
@@ -66,6 +69,7 @@ class ServerInfo {
6669
String? operator,
6770
String? message,
6871
String? vpnConfig,
72+
bool? isPremium,
6973
}) {
7074
return ServerInfo(
7175
hostName: hostName ?? this.hostName,
@@ -83,6 +87,7 @@ class ServerInfo {
8387
operator: operator ?? this.operator,
8488
message: message ?? this.message,
8589
vpnConfig: vpnConfig ?? this.vpnConfig,
90+
isPremium: isPremium ?? this.isPremium,
8691
);
8792
}
88-
}
93+
}

lib/main.dart

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,107 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_riverpod/flutter_riverpod.dart';
33
import 'package:omidvpn/api/api/api.dart';
44
import 'package:omidvpn/ui/home/home_screen.dart';
5+
import 'package:omidvpn/ui/license/license_screen.dart';
6+
import 'package:shared_preferences/shared_preferences.dart';
57

68
void main() {
7-
runApp(const ProviderScope(child: Omid()));
9+
runApp(
10+
ProviderScope(
11+
child: MyApp(),
12+
),
13+
);
814
}
915

10-
class Omid extends ConsumerWidget {
11-
const Omid({super.key});
16+
class MyApp extends ConsumerWidget {
17+
const MyApp({super.key});
1218

1319
@override
1420
Widget build(BuildContext context, WidgetRef ref) {
15-
final lang = ref.watch(langProvider);
1621
final themeMode = ref.watch(themeModeProvider);
17-
22+
1823
return MaterialApp(
19-
title: lang.homeTitle,
24+
title: 'OmidVPN',
2025
theme: ThemeData(
21-
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
2226
useMaterial3: true,
27+
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
2328
),
2429
darkTheme: ThemeData(
30+
useMaterial3: true,
2531
colorScheme: ColorScheme.fromSeed(
2632
seedColor: Colors.blue,
2733
brightness: Brightness.dark,
2834
),
29-
useMaterial3: true,
3035
),
3136
themeMode: themeMode,
32-
home: const HomePage(),
37+
home: const LicenseWrapper(),
38+
debugShowCheckedModeBanner: false,
3339
);
3440
}
41+
}
42+
43+
class LicenseWrapper extends ConsumerStatefulWidget {
44+
const LicenseWrapper({super.key});
45+
46+
@override
47+
ConsumerState<LicenseWrapper> createState() => _LicenseWrapperState();
48+
}
49+
50+
class _LicenseWrapperState extends ConsumerState<LicenseWrapper> {
51+
bool _licenseValidated = false;
52+
bool _checkingLicense = true;
53+
54+
@override
55+
void initState() {
56+
super.initState();
57+
_checkLicense();
58+
}
59+
60+
Future<void> _checkLicense() async {
61+
final prefs = await SharedPreferences.getInstance();
62+
final storedLicense = prefs.getString('premium_license_key');
63+
final continueWithoutLicense = prefs.getBool('continue_without_license') ?? false;
64+
65+
if (storedLicense != null && storedLicense.isNotEmpty) {
66+
// For now, we'll assume the stored license is valid
67+
// In a real app, you might want to validate it against your server
68+
setState(() {
69+
_licenseValidated = true;
70+
_checkingLicense = false;
71+
});
72+
} else if (continueWithoutLicense) {
73+
// User has chosen to continue without license
74+
setState(() {
75+
_licenseValidated = true;
76+
_checkingLicense = false;
77+
});
78+
} else {
79+
setState(() {
80+
_licenseValidated = false;
81+
_checkingLicense = false;
82+
});
83+
}
84+
}
85+
86+
void _onLicenseValidated() {
87+
setState(() {
88+
_licenseValidated = true;
89+
});
90+
}
91+
92+
@override
93+
Widget build(BuildContext context) {
94+
if (_checkingLicense) {
95+
return Scaffold(
96+
body: Center(
97+
child: CircularProgressIndicator(),
98+
),
99+
);
100+
}
101+
102+
if (_licenseValidated) {
103+
return const HomePage();
104+
}
105+
106+
return LicenseScreen(onLicenseValidated: _onLicenseValidated);
107+
}
35108
}

lib/ui/about/about_screen.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ class AboutScreen extends ConsumerWidget {
100100
_launchUrl('https://instagram.com/h3dev.pira');
101101
},
102102
),
103+
ListTile(
104+
leading: Icon(Icons.rocket),
105+
title: Text('X (Twitter)'),
106+
subtitle: Text('albert_com32388'),
107+
onTap: () {
108+
// Open Twitter profile
109+
_launchUrl('https://x.com/albert_com32388');
110+
},
111+
),
103112
],
104113
),
105114
),
@@ -126,4 +135,4 @@ class AboutScreen extends ConsumerWidget {
126135
),
127136
);
128137
}
129-
}
138+
}

0 commit comments

Comments
 (0)