update flutter and make connection more smooth
This commit is contained in:
@@ -22,13 +22,13 @@ enum NotificationType {
|
||||
}
|
||||
|
||||
class InAppNotificationController with AppLogger {
|
||||
void showToast(
|
||||
ToastificationItem showToast(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
NotificationType type = NotificationType.info,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
toastification.show(
|
||||
return toastification.show(
|
||||
context: context,
|
||||
title: Text(message),
|
||||
type: type._toastificationType,
|
||||
@@ -43,13 +43,13 @@ class InAppNotificationController with AppLogger {
|
||||
);
|
||||
}
|
||||
|
||||
void showErrorToast(String message) {
|
||||
ToastificationItem? showErrorToast(String message) {
|
||||
final context = RootScaffold.stateKey.currentContext;
|
||||
if (context == null) {
|
||||
loggy.warning("context is null");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
showToast(
|
||||
return showToast(
|
||||
context,
|
||||
message,
|
||||
type: NotificationType.error,
|
||||
@@ -57,26 +57,26 @@ class InAppNotificationController with AppLogger {
|
||||
);
|
||||
}
|
||||
|
||||
void showSuccessToast(String message) {
|
||||
ToastificationItem? showSuccessToast(String message) {
|
||||
final context = RootScaffold.stateKey.currentContext;
|
||||
if (context == null) {
|
||||
loggy.warning("context is null");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
showToast(
|
||||
return showToast(
|
||||
context,
|
||||
message,
|
||||
type: NotificationType.success,
|
||||
);
|
||||
}
|
||||
|
||||
void showInfoToast(String message) {
|
||||
ToastificationItem? showInfoToast(String message, {Duration duration = const Duration(seconds: 3)}) {
|
||||
final context = RootScaffold.stateKey.currentContext;
|
||||
if (context == null) {
|
||||
loggy.warning("context is null");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
showToast(context, message);
|
||||
return showToast(context, message, duration: duration);
|
||||
}
|
||||
|
||||
Future<void> showErrorDialog(PresentableError error) async {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:combine/combine.dart';
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -161,9 +162,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Future.microtask(() async {
|
||||
addProfileModal(context, ref);
|
||||
});
|
||||
await addProfileModal(context, ref);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -239,41 +238,44 @@ 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 _warp = ref.read(warpOptionNotifierProvider.notifier);
|
||||
final _profile = ref.read(addProfileProvider.notifier);
|
||||
final consent = _prefs.getBool(warpConsentGiven) ?? false;
|
||||
final consent = false && (_prefs.getBool(warpConsentGiven) ?? false);
|
||||
context.pop();
|
||||
Future.microtask(() async {
|
||||
final t = ref.read(translationsProvider);
|
||||
final notification = ref.read(inAppNotificationControllerProvider);
|
||||
|
||||
if (!consent) {
|
||||
final agreed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => const WarpLicenseAgreementModal(),
|
||||
);
|
||||
final t = ref.read(translationsProvider);
|
||||
final notification = ref.read(inAppNotificationControllerProvider);
|
||||
|
||||
if (agreed ?? false) {
|
||||
await _prefs.setBool(warpConsentGiven, true);
|
||||
notification.showInfoToast(t.profile.add.addingWarpMsg);
|
||||
await _warp.generateWarpConfig();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (!consent) {
|
||||
final agreed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => const WarpLicenseAgreementModal(),
|
||||
);
|
||||
|
||||
if (agreed ?? false) {
|
||||
await _prefs.setBool(warpConsentGiven, true);
|
||||
final toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
|
||||
toast?.pause();
|
||||
await _warp.generateWarpConfig();
|
||||
toast?.start();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final accountId = _prefs.getString("warp2-account-id");
|
||||
final accessToken = _prefs.getString("warp2-access-token");
|
||||
final hasWarp2Config = accountId != null && accessToken != null;
|
||||
final accountId = _prefs.getString("warp2-account-id");
|
||||
final accessToken = _prefs.getString("warp2-access-token");
|
||||
final hasWarp2Config = accountId != null && accessToken != null;
|
||||
|
||||
if (!hasWarp2Config) {
|
||||
notification.showInfoToast(t.profile.add.addingWarpMsg);
|
||||
await _warp.generateWarp2Config();
|
||||
}
|
||||
await _profile.add("#profile-title: Hiddify WARP\nwarp://p1@auto#National&&detour=warp://p2@auto#WoW"); //
|
||||
});
|
||||
if (!hasWarp2Config || true) {
|
||||
final toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
|
||||
toast?.pause();
|
||||
await _warp.generateWarp2Config();
|
||||
toast?.start();
|
||||
}
|
||||
await _profile.add("#profile-title: Hiddify WARP\nwarp://p1@auto#National&&detour=warp://p2@auto#WoW"); //
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:combine/combine.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/core/model/directories.dart';
|
||||
@@ -65,8 +65,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
) {
|
||||
final port = _statusReceiver.sendPort.nativePort;
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
_box.setupOnce(NativeApi.initializeApiDLData);
|
||||
final err = _box
|
||||
.setup(
|
||||
@@ -94,8 +94,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
bool debug,
|
||||
) {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box
|
||||
.parse(
|
||||
path.toNativeUtf8().cast(),
|
||||
@@ -116,8 +116,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
@override
|
||||
TaskEither<String, Unit> changeOptions(SingboxConfigOption options) {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final json = jsonEncode(options.toJson());
|
||||
final err = _box.changeConfigOptions(json.toNativeUtf8().cast()).cast<Utf8>().toDartString();
|
||||
if (err.isNotEmpty) {
|
||||
@@ -134,8 +134,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
String path,
|
||||
) {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final response = _box
|
||||
.generateConfig(
|
||||
path.toNativeUtf8().cast(),
|
||||
@@ -159,8 +159,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
) {
|
||||
loggy.debug("starting, memory limit: [${!disableMemoryLimit}]");
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box
|
||||
.start(
|
||||
configPath.toNativeUtf8().cast(),
|
||||
@@ -180,8 +180,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
@override
|
||||
TaskEither<String, Unit> stop() {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box.stop().cast<Utf8>().toDartString();
|
||||
if (err.isNotEmpty) {
|
||||
return left(err);
|
||||
@@ -200,8 +200,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
) {
|
||||
loggy.debug("restarting, memory limit: [${!disableMemoryLimit}]");
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box
|
||||
.restart(
|
||||
configPath.toNativeUtf8().cast(),
|
||||
@@ -360,8 +360,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
@override
|
||||
TaskEither<String, Unit> selectOutbound(String groupTag, String outboundTag) {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box
|
||||
.selectOutbound(
|
||||
groupTag.toNativeUtf8().cast(),
|
||||
@@ -381,8 +381,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
@override
|
||||
TaskEither<String, Unit> urlTest(String groupTag) {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final err = _box.urlTest(groupTag.toNativeUtf8().cast()).cast<Utf8>().toDartString();
|
||||
if (err.isNotEmpty) {
|
||||
return left(err);
|
||||
@@ -410,8 +410,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
@override
|
||||
TaskEither<String, Unit> clearLogs() {
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
_logBuffer.clear();
|
||||
return right(unit);
|
||||
},
|
||||
@@ -444,8 +444,8 @@ class FFISingboxService with InfraLogger implements SingboxService {
|
||||
}) {
|
||||
loggy.debug("generating warp config");
|
||||
return TaskEither(
|
||||
() => Future.microtask(
|
||||
() async {
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final response = _box
|
||||
.generateWarpConfig(
|
||||
licenseKey.toNativeUtf8().cast(),
|
||||
|
||||
Reference in New Issue
Block a user