Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Need help or have any questions? We're here to assist:
## Contributors

- [Jamalianpour](https://github.com/Jamalianpour)
Responsible for adding full macOS support and performing a comprehensive refactor, including code cleanup, structural improvements, and cross-platform compatibility enhancements.
Responsible for adding full macOS support and refactor.

---

Expand Down
3 changes: 2 additions & 1 deletion lib/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:netshift/controller/blocked_apps_controller.dart';
import 'package:netshift/controller/check_for_update_controller.dart';
import 'package:netshift/controller/foreground_controller.dart';
import 'package:netshift/controller/glow_controller.dart';
import 'package:netshift/controller/main_wrapper_controller.dart';
import 'package:netshift/controller/netshift_engine_controller.dart';
import 'package:netshift/controller/splash_controller.dart';
import 'package:netshift/controller/stop_watch_controller.dart';
Expand All @@ -17,6 +18,6 @@ class InitialBindings extends Bindings {
Get.lazyPut(() => StopWatchController(), fenix: true);
Get.lazyPut(() => GlowController(), fenix: true);
Get.lazyPut(() => BlockedAppsController(), fenix: true);
Get.lazyPut(() => MainWrapperController(), fenix: true);
}
}

6 changes: 3 additions & 3 deletions lib/controller/blocked_apps_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:installed_apps/app_info.dart';
import 'package:installed_apps/installed_apps.dart';

class BlockedAppsController extends GetxController {
GetStorage box2 = GetStorage();
var blockedApps = <String>[].obs;
var apps = <AppInfo>[].obs;
final GetStorage box2 = GetStorage();
RxList<String> blockedApps = <String>[].obs;
RxList<AppInfo> apps = <AppInfo>[].obs;
RxBool isSystemApp = false.obs;
@override
void onInit() {
Expand Down
12 changes: 9 additions & 3 deletions lib/controller/check_for_update_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class CheckForUpdateController extends GetxController {
log("No update available");
updateIsAvailable.value = false;
} else {
log("Update available version: ${updateVersion.value} with status code ${response.statusCode}");
log(
"Update available version: ${updateVersion.value} with status code ${response.statusCode}",
);
updateIsAvailable.value = true;
}
} else {
Expand All @@ -55,7 +57,9 @@ class CheckForUpdateController extends GetxController {
log("No update available");
updateIsAvailable.value = false;
} else {
log("Update available version: ${updateVersion.value} with status code ${response.statusCode}");
log(
"Update available version: ${updateVersion.value} with status code ${response.statusCode}",
);
updateIsAvailable.value = true;
}
} else {
Expand All @@ -82,7 +86,9 @@ class CheckForUpdateController extends GetxController {
log("No update available");
updateIsAvailable.value = false;
} else {
log("Update available version: ${updateVersion.value} with status code ${response.statusCode}");
log(
"Update available version: ${updateVersion.value} with status code ${response.statusCode}",
);
updateIsAvailable.value = true;
}
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/controller/dio_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ void configureDio() {
log("Connect timeout: ${dio.options.connectTimeout!.inSeconds} Seconds");
log("Receive timeout: ${dio.options.receiveTimeout!.inSeconds} Seconds");
}

4 changes: 2 additions & 2 deletions lib/controller/encrypt_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// class EncryptionData {
// static final String keyString = generateRandomKey(32);
// static final encrypt.Key key = encrypt.Key.fromUtf8(keyString);
// static final encrypt.IV iv = encrypt.IV.fromLength(16);
// static final encrypt.IV iv = encrypt.IV.fromLength(16);
// static final encrypt.Encrypter encrypter = encrypt.Encrypter(encrypt.AES(key));

// static String encryptData(String plainText) {
Expand All @@ -23,4 +23,4 @@
// final List<int> values = List<int>.generate(length, (i) => random.nextInt(256));
// return base64Url.encode(values).substring(0, length);
// }
// }
// }
43 changes: 22 additions & 21 deletions lib/controller/foreground_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import 'package:netshift/controller/stop_watch_controller.dart';
class ForegroundController extends GetxController {
static const platform = MethodChannel("com.netshift.dnschanger/netdns");
RxBool isRunning = false.obs;
static const EventChannel statusChannel =
EventChannel("com.netshift.dnschanger/netdnsStatus");
static const EventChannel statusChannel = EventChannel(
"com.netshift.dnschanger/netdnsStatus",
);
String foregroundStatus = "none";
RxString download = "0.00 MB".obs;
RxString upload = "0.00 MB".obs;
RxBool serviceStatus = false.obs;
StreamSubscription? dataUsageSubscription;
final status = GetStorage();
NetshiftEngineController netshiftEngineController =
Get.put(NetshiftEngineController());
NetshiftEngineController netshiftEngineController = Get.put(
NetshiftEngineController(),
);
StopWatchController stopWatchController = Get.put(StopWatchController());
Future<void> startService(String contextText) async {
log("Foreground Service Started");
Expand All @@ -32,7 +34,6 @@ class ForegroundController extends GetxController {
}
}


Future<void> stopService() async {
isRunning.value = false;
// statusService.write('isServiceRunning', false);
Expand All @@ -47,21 +48,19 @@ class ForegroundController extends GetxController {
}

void listenToServiceStatus() {
platform.setMethodCallHandler(
(call) async {
if (call.method == "serviceStatusUpdate") {
serviceStatus.value = call.arguments as bool;
log("Service status updated: ${serviceStatus.value}");
loadServiceStatus();
} else if (call.method == 'dataUsageUpdate') {
final Map<dynamic, dynamic> data = call.arguments;
download.value =
"${(data['download'] / (1024 * 1024)).toStringAsFixed(2)} MB";
upload.value =
"${(data['upload'] / (1024 * 1024)).toStringAsFixed(2)} MB";
}
},
);
platform.setMethodCallHandler((call) async {
if (call.method == "serviceStatusUpdate") {
serviceStatus.value = call.arguments as bool;
log("Service status updated: ${serviceStatus.value}");
loadServiceStatus();
} else if (call.method == 'dataUsageUpdate') {
final Map<dynamic, dynamic> data = call.arguments;
download.value =
"${(data['download'] / (1024 * 1024)).toStringAsFixed(2)} MB";
upload.value =
"${(data['upload'] / (1024 * 1024)).toStringAsFixed(2)} MB";
}
});
}

Future<bool> serviceStatusKotlin() async {
Expand All @@ -78,7 +77,9 @@ class ForegroundController extends GetxController {
serviceStatus.value = await serviceStatusKotlin();
loadServiceStatus();
log("****Service Status ananas : ${serviceStatus.value}****");
log("****Service Status ananas1 : ${netshiftEngineController.isActive.value}****");
log(
"****Service Status ananas1 : ${netshiftEngineController.isActive.value}****",
);
}

void loadServiceStatus() {
Expand Down
2 changes: 1 addition & 1 deletion lib/controller/glow_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class GlowController extends GetxController with GetTickerProviderStateMixin {
glowController.dispose();
super.onClose();
}
}
}
5 changes: 3 additions & 2 deletions lib/controller/main_wrapper_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:netshift/screens/home_page.dart';
import 'package:netshift/screens/settings_page.dart';

class MainWrapperController extends GetxController {
final netshiftEngineController =
final NetshiftEngineController netshiftEngineController =
Get.find<NetshiftEngineController>();
final List<Widget> _pages = [
HomePage(),
Expand All @@ -20,7 +20,8 @@ class MainWrapperController extends GetxController {
super.onInit();
netshiftEngineController.getIpAddress();
}
var selectedIndex = 0.obs;

RxInt selectedIndex = 0.obs;

void onSelectPage(int index) {
selectedIndex.value = index;
Expand Down
Loading