update flutter and make connection more smooth

This commit is contained in:
hiddify-com
2024-07-14 12:03:18 +02:00
parent 26b8695586
commit 0e0b8db0dc
6 changed files with 107 additions and 96 deletions

View File

@@ -58,7 +58,7 @@ prepare:
@echo make macos-prepare @echo make macos-prepare
@echo make ios-prepare @echo make ios-prepare
windows-prepare: get-geo-assets get gen translate windows-libs windows-prepare: get gen translate windows-libs
ios-prepare: get-geo-assets get gen translate ios-libs ios-prepare: get-geo-assets get gen translate ios-libs
macos-prepare: get-geo-assets get gen translate macos-libs macos-prepare: get-geo-assets get gen translate macos-libs

View File

@@ -22,13 +22,13 @@ enum NotificationType {
} }
class InAppNotificationController with AppLogger { class InAppNotificationController with AppLogger {
void showToast( ToastificationItem showToast(
BuildContext context, BuildContext context,
String message, { String message, {
NotificationType type = NotificationType.info, NotificationType type = NotificationType.info,
Duration duration = const Duration(seconds: 3), Duration duration = const Duration(seconds: 3),
}) { }) {
toastification.show( return toastification.show(
context: context, context: context,
title: Text(message), title: Text(message),
type: type._toastificationType, type: type._toastificationType,
@@ -43,13 +43,13 @@ class InAppNotificationController with AppLogger {
); );
} }
void showErrorToast(String message) { ToastificationItem? showErrorToast(String message) {
final context = RootScaffold.stateKey.currentContext; final context = RootScaffold.stateKey.currentContext;
if (context == null) { if (context == null) {
loggy.warning("context is null"); loggy.warning("context is null");
return; return null;
} }
showToast( return showToast(
context, context,
message, message,
type: NotificationType.error, type: NotificationType.error,
@@ -57,26 +57,26 @@ class InAppNotificationController with AppLogger {
); );
} }
void showSuccessToast(String message) { ToastificationItem? showSuccessToast(String message) {
final context = RootScaffold.stateKey.currentContext; final context = RootScaffold.stateKey.currentContext;
if (context == null) { if (context == null) {
loggy.warning("context is null"); loggy.warning("context is null");
return; return null;
} }
showToast( return showToast(
context, context,
message, message,
type: NotificationType.success, type: NotificationType.success,
); );
} }
void showInfoToast(String message) { ToastificationItem? showInfoToast(String message, {Duration duration = const Duration(seconds: 3)}) {
final context = RootScaffold.stateKey.currentContext; final context = RootScaffold.stateKey.currentContext;
if (context == null) { if (context == null) {
loggy.warning("context is null"); loggy.warning("context is null");
return; return null;
} }
showToast(context, message); return showToast(context, message, duration: duration);
} }
Future<void> showErrorDialog(PresentableError error) async { Future<void> showErrorDialog(PresentableError error) async {

View File

@@ -1,3 +1,4 @@
import 'package:combine/combine.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -161,9 +162,7 @@ class AddProfileModal extends HookConsumerWidget {
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
Future.microtask(() async { await addProfileModal(context, ref);
addProfileModal(context, ref);
});
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -239,13 +238,13 @@ class AddProfileModal extends HookConsumerWidget {
); );
} }
void addProfileModal(BuildContext context, WidgetRef ref) async { Future<void> addProfileModal(BuildContext context, WidgetRef ref) async {
final _prefs = ref.read(sharedPreferencesProvider).requireValue; final _prefs = ref.read(sharedPreferencesProvider).requireValue;
final _warp = ref.read(warpOptionNotifierProvider.notifier); final _warp = ref.read(warpOptionNotifierProvider.notifier);
final _profile = ref.read(addProfileProvider.notifier); final _profile = ref.read(addProfileProvider.notifier);
final consent = _prefs.getBool(warpConsentGiven) ?? false; final consent = false && (_prefs.getBool(warpConsentGiven) ?? false);
context.pop(); context.pop();
Future.microtask(() async {
final t = ref.read(translationsProvider); final t = ref.read(translationsProvider);
final notification = ref.read(inAppNotificationControllerProvider); final notification = ref.read(inAppNotificationControllerProvider);
@@ -257,10 +256,12 @@ class AddProfileModal extends HookConsumerWidget {
if (agreed ?? false) { if (agreed ?? false) {
await _prefs.setBool(warpConsentGiven, true); await _prefs.setBool(warpConsentGiven, true);
notification.showInfoToast(t.profile.add.addingWarpMsg); final toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
toast?.pause();
await _warp.generateWarpConfig(); await _warp.generateWarpConfig();
toast?.start();
} else { } else {
return null; return;
} }
} }
@@ -268,12 +269,13 @@ class AddProfileModal extends HookConsumerWidget {
final accessToken = _prefs.getString("warp2-access-token"); final accessToken = _prefs.getString("warp2-access-token");
final hasWarp2Config = accountId != null && accessToken != null; final hasWarp2Config = accountId != null && accessToken != null;
if (!hasWarp2Config) { if (!hasWarp2Config || true) {
notification.showInfoToast(t.profile.add.addingWarpMsg); final toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
toast?.pause();
await _warp.generateWarp2Config(); await _warp.generateWarp2Config();
toast?.start();
} }
await _profile.add("#profile-title: Hiddify WARP\nwarp://p1@auto#National&&detour=warp://p2@auto#WoW"); // await _profile.add("#profile-title: Hiddify WARP\nwarp://p1@auto#National&&detour=warp://p2@auto#WoW"); //
});
} }
} }

View File

@@ -3,7 +3,7 @@ import 'dart:convert';
import 'dart:ffi'; import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'dart:isolate'; import 'dart:isolate';
import 'package:combine/combine.dart';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:fpdart/fpdart.dart'; import 'package:fpdart/fpdart.dart';
import 'package:hiddify/core/model/directories.dart'; import 'package:hiddify/core/model/directories.dart';
@@ -65,8 +65,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
) { ) {
final port = _statusReceiver.sendPort.nativePort; final port = _statusReceiver.sendPort.nativePort;
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
_box.setupOnce(NativeApi.initializeApiDLData); _box.setupOnce(NativeApi.initializeApiDLData);
final err = _box final err = _box
.setup( .setup(
@@ -94,8 +94,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
bool debug, bool debug,
) { ) {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box final err = _box
.parse( .parse(
path.toNativeUtf8().cast(), path.toNativeUtf8().cast(),
@@ -116,8 +116,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
@override @override
TaskEither<String, Unit> changeOptions(SingboxConfigOption options) { TaskEither<String, Unit> changeOptions(SingboxConfigOption options) {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final json = jsonEncode(options.toJson()); final json = jsonEncode(options.toJson());
final err = _box.changeConfigOptions(json.toNativeUtf8().cast()).cast<Utf8>().toDartString(); final err = _box.changeConfigOptions(json.toNativeUtf8().cast()).cast<Utf8>().toDartString();
if (err.isNotEmpty) { if (err.isNotEmpty) {
@@ -134,8 +134,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
String path, String path,
) { ) {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final response = _box final response = _box
.generateConfig( .generateConfig(
path.toNativeUtf8().cast(), path.toNativeUtf8().cast(),
@@ -159,8 +159,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
) { ) {
loggy.debug("starting, memory limit: [${!disableMemoryLimit}]"); loggy.debug("starting, memory limit: [${!disableMemoryLimit}]");
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box final err = _box
.start( .start(
configPath.toNativeUtf8().cast(), configPath.toNativeUtf8().cast(),
@@ -180,8 +180,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
@override @override
TaskEither<String, Unit> stop() { TaskEither<String, Unit> stop() {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box.stop().cast<Utf8>().toDartString(); final err = _box.stop().cast<Utf8>().toDartString();
if (err.isNotEmpty) { if (err.isNotEmpty) {
return left(err); return left(err);
@@ -200,8 +200,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
) { ) {
loggy.debug("restarting, memory limit: [${!disableMemoryLimit}]"); loggy.debug("restarting, memory limit: [${!disableMemoryLimit}]");
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box final err = _box
.restart( .restart(
configPath.toNativeUtf8().cast(), configPath.toNativeUtf8().cast(),
@@ -360,8 +360,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
@override @override
TaskEither<String, Unit> selectOutbound(String groupTag, String outboundTag) { TaskEither<String, Unit> selectOutbound(String groupTag, String outboundTag) {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box final err = _box
.selectOutbound( .selectOutbound(
groupTag.toNativeUtf8().cast(), groupTag.toNativeUtf8().cast(),
@@ -381,8 +381,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
@override @override
TaskEither<String, Unit> urlTest(String groupTag) { TaskEither<String, Unit> urlTest(String groupTag) {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final err = _box.urlTest(groupTag.toNativeUtf8().cast()).cast<Utf8>().toDartString(); final err = _box.urlTest(groupTag.toNativeUtf8().cast()).cast<Utf8>().toDartString();
if (err.isNotEmpty) { if (err.isNotEmpty) {
return left(err); return left(err);
@@ -410,8 +410,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
@override @override
TaskEither<String, Unit> clearLogs() { TaskEither<String, Unit> clearLogs() {
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
_logBuffer.clear(); _logBuffer.clear();
return right(unit); return right(unit);
}, },
@@ -444,8 +444,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
}) { }) {
loggy.debug("generating warp config"); loggy.debug("generating warp config");
return TaskEither( return TaskEither(
() => Future.microtask( () => CombineWorker().execute(
() async { () {
final response = _box final response = _box
.generateWarpConfig( .generateWarpConfig(
licenseKey.toNativeUtf8().cast(), licenseKey.toNativeUtf8().cast(),

View File

@@ -218,6 +218,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.0" version: "3.0.0"
combine:
dependency: "direct main"
description:
name: combine
sha256: c16464b55d140871fbab5b37909e1808c2f020e46f9ba7deca59d40faabb6008
url: "https://pub.dev"
source: hosted
version: "0.5.7"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@@ -793,11 +801,12 @@ packages:
humanizer: humanizer:
dependency: "direct main" dependency: "direct main"
description: description:
name: humanizer path: "."
sha256: "08728a4b6d62accd7d09e668bd54e81e6e09a82c8cfda30553224b3eb868d4f2" ref: up-version
url: "https://pub.dev" resolved-ref: "8ae61d68357fae197be7ee71d67ccb9498b9d5c7"
source: hosted url: "https://github.com/alex-relov/humanizer"
version: "2.2.0" source: git
version: "2.3.0"
iconsax_flutter: iconsax_flutter:
dependency: transitive dependency: transitive
description: description:
@@ -842,10 +851,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.18.1" version: "0.19.0"
io: io:
dependency: transitive dependency: transitive
description: description:
@@ -914,26 +923,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.0" version: "10.0.4"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "3.0.3"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "3.0.1"
lint: lint:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -994,10 +1003,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: meta name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.0" version: "1.12.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -1695,26 +1704,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test name: test
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.24.9" version: "1.25.2"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.1" version: "0.7.0"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.9" version: "0.6.0"
time: time:
dependency: transitive dependency: transitive
description: description:
@@ -1927,10 +1936,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "13.0.0" version: "14.2.1"
watcher: watcher:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -2029,4 +2038,4 @@ packages:
version: "2.1.1" version: "2.1.1"
sdks: sdks:
dart: ">=3.3.0 <4.0.0" dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0" flutter: ">=3.22.2"

View File

@@ -5,7 +5,7 @@ version: 1.6.0+10600
environment: environment:
sdk: ">=3.3.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0 <3.22.0" flutter: ">=3.19.0 <3.22.3"
dependencies: dependencies:
flutter: flutter:
@@ -13,13 +13,13 @@ dependencies:
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.6 cupertino_icons: ^1.0.6
intl: ^0.18.1 intl: ^0.19.0
humanizer: ^2.2.0 # humanizer: ^2.2.0
# intl: ^0.19.0 # intl: ^0.19.0
# humanizer: humanizer:
# git: git:
# url: https://github.com/alex-relov/humanizer url: https://github.com/alex-relov/humanizer
# ref: up-version ref: up-version
slang: ^3.30.1 slang: ^3.30.1
slang_flutter: ^3.30.0 slang_flutter: ^3.30.0
fpdart: ^1.1.0 fpdart: ^1.1.0
@@ -47,7 +47,7 @@ dependencies:
launch_at_startup: ^0.2.2 launch_at_startup: ^0.2.2
sentry_flutter: ^7.16.1 sentry_flutter: ^7.16.1
sentry_dart_plugin: ^1.7.1 sentry_dart_plugin: ^1.7.1
combine: ^0.5.7
path: ^1.8.3 path: ^1.8.3
loggy: ^2.0.3 loggy: ^2.0.3
flutter_loggy: ^2.0.2 flutter_loggy: ^2.0.2