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,17 +1,17 @@
import 'dart:ui' show PlatformDispatcher;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart';
import 'package:hiddify/core/analytics/analytics_controller.dart';
import 'package:hiddify/core/http_client/dio_http_client.dart';
import 'package:hiddify/core/localization/locale_preferences.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/model/constants.dart';
import 'package:hiddify/core/model/region.dart';
import 'package:hiddify/gen/assets.gen.dart';
import 'package:hiddify/core/preferences/general_preferences.dart';
import 'package:hiddify/features/common/general_pref_tiles.dart';
import 'package:hiddify/features/config_option/data/config_option_repository.dart';
import 'package:hiddify/features/settings/about/terms_and_conditions_screen.dart';
import 'package:hiddify/gen/assets.gen.dart';
import 'package:hiddify/utils/utils.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
@@ -19,9 +19,7 @@ import 'package:sliver_tools/sliver_tools.dart';
import 'package:timezone_to_country/timezone_to_country.dart';
class IntroPage extends HookConsumerWidget with PresLogger {
IntroPage({super.key});
bool locationInfoLoaded = false;
const IntroPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -29,10 +27,11 @@ class IntroPage extends HookConsumerWidget with PresLogger {
final theme = Theme.of(context);
final isStarting = useState(false);
if (!locationInfoLoaded) {
// Автовыбор региона теперь через useEffect (хуки)
useEffect(() {
autoSelectRegion(ref).then((value) => loggy.debug("Auto Region selection finished!"));
locationInfoLoaded = true;
}
return null;
}, const [],);
return Scaffold(
body: Container(
@@ -82,7 +81,7 @@ class IntroPage extends HookConsumerWidget with PresLogger {
const Gap(24),
// Заголовок
Text(
'Welcome to Umbrix',
t.intro.welcomeTitle,
style: theme.textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
@@ -91,7 +90,7 @@ class IntroPage extends HookConsumerWidget with PresLogger {
),
const Gap(8),
Text(
'Fast and Secure',
t.intro.subtitle,
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
@@ -101,138 +100,150 @@ class IntroPage extends HookConsumerWidget with PresLogger {
),
),
),
// Настройки в виде карточек
SliverCrossAxisConstrained(
maxCrossAxisExtent: 400,
child: MultiSliver(
children: [
// Язык
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: const LocalePrefTile(),
const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: LocalePrefTile(),
),
),
),
// Регион
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: const RegionPrefTile(),
const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: RegionPrefTile(),
),
),
),
// Аналитика
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: const EnableAnalyticsPrefTile(),
const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 6),
child: _SettingCard(
child: EnableAnalyticsPrefTile(),
),
),
),
const SliverGap(16),
// Условия использования
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text.rich(
t.intro.termsAndPolicyCaution(
tap: (text) => TextSpan(
text: text,
style: TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.w600,
decoration: TextDecoration.underline,
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text.rich(
t.intro.termsAndPolicyCaution(
tap: (text) => TextSpan(
text: text,
style: TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.w600,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const TermsAndConditionsScreen(),
),
);
},
),
recognizer: TapGestureRecognizer()
..onTap = () async {
await UriUtils.tryLaunch(
Uri.parse(Constants.termsAndConditionsUrl),
);
},
),
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
textAlign: TextAlign.center,
),
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
textAlign: TextAlign.center,
),
),
// Кнопка начать
Padding(
padding: const EdgeInsets.fromLTRB(24, 24, 24, 32),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
theme.colorScheme.primary,
theme.colorScheme.primary.withOpacity(0.8),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 24, 24, 32),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
theme.colorScheme.primary,
theme.colorScheme.primary.withOpacity(0.8),
],
),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: theme.colorScheme.primary.withOpacity(0.4),
blurRadius: 12,
offset: const Offset(0, 6),
),
],
),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: theme.colorScheme.primary.withOpacity(0.4),
blurRadius: 12,
offset: const Offset(0, 6),
),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: isStarting.value
? null
: () async {
isStarting.value = true;
if (!ref.read(analyticsControllerProvider).requireValue) {
loggy.info("disabling analytics per user request");
try {
await ref.read(analyticsControllerProvider.notifier).disableAnalytics();
} catch (error, stackTrace) {
loggy.error(
"could not disable analytics",
error,
stackTrace,
);
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: isStarting.value
? null
: () async {
isStarting.value = true;
if (!ref.read(analyticsControllerProvider).requireValue) {
loggy.info("disabling analytics per user request");
try {
await ref.read(analyticsControllerProvider.notifier).disableAnalytics();
} catch (error, stackTrace) {
loggy.error(
"could not disable analytics",
error,
stackTrace,
);
}
}
}
await ref.read(Preferences.introCompleted.notifier).update(true);
},
borderRadius: BorderRadius.circular(16),
child: Container(
height: 56,
alignment: Alignment.center,
child: isStarting.value
? SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
strokeWidth: 3,
valueColor: AlwaysStoppedAnimation<Color>(
theme.colorScheme.onPrimary,
),
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
t.intro.start,
style: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.bold,
await ref.read(Preferences.introCompleted.notifier).update(true);
},
borderRadius: BorderRadius.circular(16),
child: Container(
height: 56,
alignment: Alignment.center,
child: isStarting.value
? SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
strokeWidth: 3,
valueColor: AlwaysStoppedAnimation<Color>(
theme.colorScheme.onPrimary,
),
),
const Gap(8),
Icon(
Icons.arrow_forward_rounded,
color: theme.colorScheme.onPrimary,
),
],
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
t.intro.start,
style: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
),
const Gap(8),
Icon(
Icons.arrow_forward_rounded,
color: theme.colorScheme.onPrimary,
),
],
),
),
),
),
),
@@ -266,28 +277,25 @@ class IntroPage extends HookConsumerWidget with PresLogger {
);
}
// UMBRIX: Используем timezone вместо IP для приватности
try {
final DioHttpClient client = DioHttpClient(
timeout: const Duration(seconds: 2),
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0",
debug: true,
);
final response = await client.get<Map<String, dynamic>>('https://api.ip.sb/geoip/');
final timezone = DateTime.now().timeZoneName;
final systemLocale = PlatformDispatcher.instance.locale;
if (response.statusCode == 200) {
final jsonData = response.data!;
final regionLocale = _getRegionLocale(jsonData['country_code']?.toString() ?? "");
loggy.debug('Using timezone: $timezone, system locale: ${systemLocale.languageCode}');
loggy.debug(
'Region: ${regionLocale.region} Locale: ${regionLocale.locale}',
);
// Определяем регион по системной локали (без интернет-запросов!)
final countryCode = systemLocale.countryCode ?? '';
if (countryCode.isNotEmpty) {
final regionLocale = _getRegionLocale(countryCode);
await ref.read(ConfigOptions.region.notifier).update(regionLocale.region);
await ref.read(localePreferencesProvider.notifier).changeLocale(regionLocale.locale);
loggy.debug('Region set from system locale: ${regionLocale.region}');
} else {
loggy.warning('Request failed with status: ${response.statusCode}');
loggy.debug('Could not determine region from system locale, using default');
}
} catch (e) {
loggy.warning('Could not get the local country code from ip');
loggy.warning('Could not auto-select region: $e');
}
}
@@ -327,7 +335,7 @@ class _SettingCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest.withOpacity(0.5),