Backup before removing hiddify references

This commit is contained in:
Hiddify User
2026-01-15 12:28:40 +03:00
parent f54603d129
commit 36d9e31236
231 changed files with 6648 additions and 1832 deletions

View File

@@ -1,4 +1,3 @@
import 'package:combine/combine.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -62,10 +61,10 @@ class AddProfileModal extends HookConsumerWidget {
controller: scrollController,
child: AnimatedSize(
duration: const Duration(milliseconds: 250),
child: Builder(
builder: (context) {
// Fixed button width instead of using LayoutBuilder
final buttonWidth = (MediaQuery.of(context).size.width / 2) - (buttonsPadding + (buttonsGap / 2));
child: LayoutBuilder(
builder: (context, constraints) {
// temporary solution, aspect ratio widget relies on height and in a row there no height!
final buttonWidth = constraints.maxWidth / 2 - (buttonsPadding + (buttonsGap / 2));
return AnimatedCrossFade(
firstChild: SizedBox(
@@ -98,70 +97,42 @@ class AddProfileModal extends HookConsumerWidget {
),
secondChild: Column(
children: [
// Заголовок
Padding(
padding: const EdgeInsets.fromLTRB(24, 16, 24, 8),
child: Text(
t.profile.add.buttonText,
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
// Основные кнопки в виде больших карточек
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
padding: const EdgeInsets.symmetric(horizontal: buttonsPadding),
child: Row(
children: [
_ModernButton(
_Button(
key: const ValueKey("add_from_clipboard_button"),
label: t.profile.add.fromClipboard,
subtitle: "Paste from clipboard",
icon: FluentIcons.clipboard_paste_24_filled,
gradient: LinearGradient(
colors: [
theme.colorScheme.primaryContainer,
theme.colorScheme.secondaryContainer,
],
),
icon: FluentIcons.clipboard_paste_24_regular,
size: buttonWidth,
onTap: () async {
final captureResult = await Clipboard.getData(Clipboard.kTextPlain).then((value) => value?.text ?? '');
if (addProfileState.isLoading) return;
ref.read(addProfileProvider.notifier).add(captureResult);
},
),
const Gap(12),
const Gap(buttonsGap),
if (!PlatformUtils.isDesktop)
_ModernButton(
_Button(
key: const ValueKey("add_by_qr_code_button"),
label: t.profile.add.scanQr,
subtitle: "Camera scanner",
icon: FluentIcons.qr_code_24_filled,
gradient: LinearGradient(
colors: [
theme.colorScheme.tertiaryContainer,
theme.colorScheme.primaryContainer.withOpacity(0.7),
],
),
icon: FluentIcons.qr_code_24_regular,
size: buttonWidth,
onTap: () async {
final cr = await QRCodeScannerScreen().open(context);
final cr = await const QRCodeScannerScreen().open(context);
if (cr == null) return;
if (addProfileState.isLoading) return;
ref.read(addProfileProvider.notifier).add(cr);
},
)
else
_ModernButton(
_Button(
key: const ValueKey("add_manually_button"),
label: t.profile.add.manually,
subtitle: "Create new config",
icon: FluentIcons.edit_24_filled,
gradient: LinearGradient(
colors: [
theme.colorScheme.tertiaryContainer,
theme.colorScheme.primaryContainer.withOpacity(0.7),
],
),
icon: FluentIcons.add_24_regular,
size: buttonWidth,
onTap: () async {
context.pop();
await const NewProfileRoute().push(context);
@@ -170,32 +141,87 @@ class AddProfileModal extends HookConsumerWidget {
],
),
),
const Gap(16),
// Дополнительные опции
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(
horizontal: buttonsPadding,
vertical: 16,
),
child: Column(
children: [
_CompactButton(
key: const ValueKey("add_warp_button"),
label: t.profile.add.addWarp,
icon: FluentIcons.cloud_add_24_regular,
color: theme.colorScheme.primary,
onTap: () async {
await addProfileModal(context, ref);
},
Semantics(
button: true,
child: SizedBox(
height: 36,
child: Material(
key: const ValueKey("add_warp_button"),
elevation: 8,
color: theme.colorScheme.surface,
surfaceTintColor: theme.colorScheme.surfaceTint,
shadowColor: Colors.transparent,
borderRadius: BorderRadius.circular(8),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () async {
await addProfileModal(context, ref);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FluentIcons.add_24_regular,
color: theme.colorScheme.primary,
),
const SizedBox(width: 8),
Text(
t.profile.add.addWarp,
style: theme.textTheme.labelLarge?.copyWith(
color: theme.colorScheme.primary,
),
),
],
),
),
),
),
),
if (!PlatformUtils.isDesktop) const Gap(12),
if (!PlatformUtils.isDesktop) const SizedBox(height: 16), // Spacing between the buttons
if (!PlatformUtils.isDesktop)
_CompactButton(
key: const ValueKey("add_manually_button"),
label: t.profile.add.manually,
icon: FluentIcons.edit_24_regular,
color: theme.colorScheme.secondary,
onTap: () async {
context.pop();
await const NewProfileRoute().push(context);
},
Semantics(
button: true,
child: SizedBox(
height: 36,
child: Material(
key: const ValueKey("add_manually_button"),
elevation: 8,
color: theme.colorScheme.surface,
surfaceTintColor: theme.colorScheme.surfaceTint,
shadowColor: Colors.transparent,
borderRadius: BorderRadius.circular(8),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () async {
context.pop();
await const NewProfileRoute().push(context);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FluentIcons.add_24_regular,
color: theme.colorScheme.primary,
),
const SizedBox(width: 8),
Text(
t.profile.add.manually,
style: theme.textTheme.labelLarge?.copyWith(
color: theme.colorScheme.primary,
),
),
],
),
),
),
),
),
],
),
@@ -213,10 +239,10 @@ class AddProfileModal extends HookConsumerWidget {
}
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 prefs = ref.read(sharedPreferencesProvider).requireValue;
final warp = ref.read(warpOptionNotifierProvider.notifier);
final profile = ref.read(addProfileProvider.notifier);
final consent = prefs.getBool(warpConsentGiven) ?? false;
final region = ref.read(ConfigOptions.region.notifier).raw();
context.pop();
@@ -231,10 +257,10 @@ class AddProfileModal extends HookConsumerWidget {
if (agreed != true) return;
}
await _prefs.setBool(warpConsentGiven, true);
await prefs.setBool(warpConsentGiven, true);
var toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
toast?.pause();
await _warp.generateWarpConfig();
await warp.generateWarpConfig();
toast?.start();
// final accountId = _prefs.getString("warp2-account-id");
@@ -244,179 +270,17 @@ class AddProfileModal extends HookConsumerWidget {
// if (!hasWarp2Config || true) {
toast = notification.showInfoToast(t.profile.add.addingWarpMsg, duration: const Duration(milliseconds: 100));
toast?.pause();
await _warp.generateWarp2Config();
await warp.generateWarp2Config();
toast?.start();
// }
if (region == "cn") {
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"); //
} else {
await _profile.add("https://raw.githubusercontent.com/hiddify/hiddify-next/main/test.configs/warp"); //
await profile.add("https://raw.githubusercontent.com/hiddify/hiddify-next/main/test.configs/warp"); //
}
}
}
// Современная большая кнопка с градиентом
class _ModernButton extends StatelessWidget {
const _ModernButton({
super.key,
required this.label,
required this.subtitle,
required this.icon,
required this.gradient,
required this.onTap,
});
final String label;
final String subtitle;
final IconData icon;
final Gradient gradient;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Semantics(
button: true,
child: Material(
elevation: 4,
shadowColor: theme.colorScheme.primary.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: Container(
height: 80,
decoration: BoxDecoration(
gradient: gradient,
borderRadius: BorderRadius.circular(20),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: theme.colorScheme.surface.withOpacity(0.9),
borderRadius: BorderRadius.circular(16),
),
child: Icon(
icon,
size: 28,
color: theme.colorScheme.primary,
),
),
const Gap(16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
const Gap(2),
Text(
subtitle,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onPrimaryContainer.withOpacity(0.7),
),
),
],
),
),
Icon(
FluentIcons.chevron_right_24_regular,
color: theme.colorScheme.onPrimaryContainer.withOpacity(0.5),
),
],
),
),
),
),
),
);
}
}
// Компактная кнопка для дополнительных опций
class _CompactButton extends StatelessWidget {
const _CompactButton({
super.key,
required this.label,
required this.icon,
required this.color,
required this.onTap,
});
final String label;
final IconData icon;
final Color color;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Semantics(
button: true,
child: Material(
elevation: 2,
color: theme.colorScheme.surface,
surfaceTintColor: theme.colorScheme.surfaceTint,
shadowColor: Colors.transparent,
borderRadius: BorderRadius.circular(12),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: Container(
height: 56,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Icon(
icon,
size: 20,
color: color,
),
),
const Gap(12),
Expanded(
child: Text(
label,
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
color: color,
),
),
),
Icon(
FluentIcons.add_24_regular,
size: 20,
color: color.withOpacity(0.5),
),
],
),
),
),
),
);
}
}
class _Button extends StatelessWidget {
const _Button({
super.key,