feat: mobile-like window size and always-visible stats
- Changed window size to mobile phone format (400x800) - Removed width condition for ActiveProxyFooter - now always visible - Added run-umbrix.sh launch script with icon copying - Stats cards now display on all screen sizes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'package:hiddify/features/per_app_proxy/data/per_app_proxy_repository.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/data/per_app_proxy_repository.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'per_app_proxy_data_providers.g.dart';
|
||||
|
||||
@@ -2,26 +2,23 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:umbrix/utils/utils.dart';
|
||||
|
||||
abstract interface class PerAppProxyRepository {
|
||||
TaskEither<String, List<InstalledPackageInfo>> getInstalledPackages();
|
||||
TaskEither<String, Uint8List> getPackageIcon(String packageName);
|
||||
}
|
||||
|
||||
class PerAppProxyRepositoryImpl
|
||||
with InfraLogger
|
||||
implements PerAppProxyRepository {
|
||||
final _methodChannel = const MethodChannel("com.hiddify.app/platform");
|
||||
class PerAppProxyRepositoryImpl with InfraLogger implements PerAppProxyRepository {
|
||||
final _methodChannel = const MethodChannel("com.umbrix.app/platform");
|
||||
|
||||
@override
|
||||
TaskEither<String, List<InstalledPackageInfo>> getInstalledPackages() {
|
||||
return TaskEither(
|
||||
() async {
|
||||
loggy.debug("getting installed packages info");
|
||||
final result =
|
||||
await _methodChannel.invokeMethod<String>("get_installed_packages");
|
||||
final result = await _methodChannel.invokeMethod<String>("get_installed_packages");
|
||||
if (result == null) return left("null response");
|
||||
return right(
|
||||
(jsonDecode(result) as List).map((e) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:umbrix/core/localization/translations.dart';
|
||||
|
||||
enum PerAppProxyMode {
|
||||
off,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/data/per_app_proxy_data_providers.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:hiddify/utils/riverpod_utils.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/data/per_app_proxy_data_providers.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:umbrix/utils/riverpod_utils.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'per_app_proxy_notifier.g.dart';
|
||||
@@ -10,11 +10,7 @@ part 'per_app_proxy_notifier.g.dart';
|
||||
Future<List<InstalledPackageInfo>> installedPackagesInfo(
|
||||
InstalledPackagesInfoRef ref,
|
||||
) async {
|
||||
return ref
|
||||
.watch(perAppProxyRepositoryProvider)
|
||||
.getInstalledPackages()
|
||||
.getOrElse((err) {
|
||||
// _logger.error("error getting installed packages", err);
|
||||
return ref.watch(perAppProxyRepositoryProvider).getInstalledPackages().getOrElse((err) {
|
||||
throw err;
|
||||
}).run();
|
||||
}
|
||||
@@ -24,12 +20,8 @@ Future<ImageProvider> packageIcon(
|
||||
PackageIconRef ref,
|
||||
String packageName,
|
||||
) async {
|
||||
ref.disposeDelay(const Duration(seconds: 10));
|
||||
final bytes = await ref
|
||||
.watch(perAppProxyRepositoryProvider)
|
||||
.getPackageIcon(packageName)
|
||||
.getOrElse((err) {
|
||||
// _logger.warning("error getting package icon", err);
|
||||
ref.disposeDelay(const Duration(seconds: 60));
|
||||
final bytes = await ref.watch(perAppProxyRepositoryProvider).getPackageIcon(packageName).getOrElse((err) {
|
||||
throw err;
|
||||
}).run();
|
||||
return MemoryImage(bytes);
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/model/region.dart';
|
||||
import 'package:hiddify/core/preferences/general_preferences.dart';
|
||||
import 'package:hiddify/core/router/routes.dart';
|
||||
import 'package:hiddify/features/common/nested_app_bar.dart';
|
||||
import 'package:hiddify/features/config_option/data/config_option_repository.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/model/per_app_proxy_mode.dart';
|
||||
import 'package:hiddify/features/per_app_proxy/overview/per_app_proxy_notifier.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:umbrix/core/localization/translations.dart';
|
||||
import 'package:umbrix/core/model/region.dart';
|
||||
import 'package:umbrix/core/preferences/general_preferences.dart';
|
||||
import 'package:umbrix/core/router/routes.dart';
|
||||
import 'package:umbrix/features/common/nested_app_bar.dart';
|
||||
import 'package:umbrix/features/config_option/data/config_option_repository.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/model/installed_package_info.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/model/per_app_proxy_mode.dart';
|
||||
import 'package:umbrix/features/per_app_proxy/overview/per_app_proxy_notifier.dart';
|
||||
import 'package:umbrix/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
class PerAppProxyPage extends HookConsumerWidget with PresLogger {
|
||||
@@ -31,7 +32,7 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
|
||||
final searchQuery = useState("");
|
||||
final currentTab = useState(0);
|
||||
final domainInputController = useTextEditingController();
|
||||
final tabController = useTabController(initialLength: 2);
|
||||
final tabController = useTabController(initialLength: PlatformUtils.isDesktop ? 1 : 2);
|
||||
|
||||
final filteredPackages = useMemoized(
|
||||
() {
|
||||
@@ -59,21 +60,23 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
|
||||
final appBar = NestedAppBar(
|
||||
title: Text(t.settings.network.excludedDomains.pageTitle),
|
||||
actions: [
|
||||
if (currentTab.value == 1 && !isSearching.value)
|
||||
if (currentTab.value == 1 && !isSearching.value && !PlatformUtils.isDesktop)
|
||||
IconButton(
|
||||
icon: const Icon(FluentIcons.search_24_regular),
|
||||
onPressed: () => isSearching.value = true,
|
||||
tooltip: localizations.searchFieldLabel,
|
||||
),
|
||||
],
|
||||
bottom: TabBar(
|
||||
controller: tabController,
|
||||
onTap: (index) => currentTab.value = index,
|
||||
tabs: [
|
||||
Tab(text: t.settings.network.excludedDomains.domainsTab),
|
||||
Tab(text: t.settings.network.excludedDomains.appsTab),
|
||||
],
|
||||
),
|
||||
bottom: PlatformUtils.isDesktop
|
||||
? null // На Desktop только вкладка "Домены"
|
||||
: TabBar(
|
||||
controller: tabController,
|
||||
onTap: (index) => currentTab.value = index,
|
||||
tabs: [
|
||||
Tab(text: t.settings.network.excludedDomains.domainsTab),
|
||||
Tab(text: t.settings.network.excludedDomains.appsTab),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
final searchAppBar = SliverAppBar(
|
||||
@@ -110,173 +113,156 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
if (isSearching.value) searchAppBar else appBar,
|
||||
SliverFillRemaining(
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
_buildDomainsTab(context, t, ref, domainInputController),
|
||||
_buildAppsTab(
|
||||
context,
|
||||
ref,
|
||||
t,
|
||||
perAppProxyMode,
|
||||
filteredPackages,
|
||||
perAppProxyList,
|
||||
showSystemApps,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: currentTab.value == 0
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => _showAddDomainModal(context, ref, domainInputController),
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(t.settings.network.excludedDomains.fabButton),
|
||||
)
|
||||
: null,
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (currentTab.value == 1)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
final interceptBackToHome = !PlatformUtils.isDesktop;
|
||||
|
||||
return PopScope<void>(
|
||||
canPop: !interceptBackToHome,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (!didPop && interceptBackToHome) {
|
||||
const HomeRoute().go(context);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
if (isSearching.value) searchAppBar else appBar,
|
||||
SliverFillRemaining(
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
// Подсказка над кнопками
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0, bottom: 8.0),
|
||||
child: Text(
|
||||
perAppProxyMode == PerAppProxyMode.include ? t.settings.network.perAppProxyModes.includeMsg : t.settings.network.perAppProxyModes.excludeMsg,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: perAppProxyMode == PerAppProxyMode.include
|
||||
? ElevatedButton(
|
||||
onPressed: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
disabledBackgroundColor: Theme.of(context).colorScheme.primary,
|
||||
disabledForegroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.include),
|
||||
)
|
||||
: OutlinedButton(
|
||||
onPressed: () async {
|
||||
await ref.read(Preferences.perAppProxyMode.notifier).update(PerAppProxyMode.include);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.include),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: perAppProxyMode == PerAppProxyMode.exclude
|
||||
? ElevatedButton(
|
||||
onPressed: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
disabledBackgroundColor: Theme.of(context).colorScheme.primary,
|
||||
disabledForegroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.exclude),
|
||||
)
|
||||
: OutlinedButton(
|
||||
onPressed: () async {
|
||||
await ref.read(Preferences.perAppProxyMode.notifier).update(PerAppProxyMode.exclude);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.exclude),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.help_outline),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(t.settings.network.perAppProxyPageTitle),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${t.settings.network.perAppProxyModes.include}:",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(t.settings.network.perAppProxyModes.includeMsg),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
"${t.settings.network.perAppProxyModes.exclude}:",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(t.settings.network.perAppProxyModes.excludeMsg),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(MaterialLocalizations.of(context).okButtonLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
tooltip: t.settings.network.perAppProxyPageTitle,
|
||||
),
|
||||
],
|
||||
_buildDomainsTab(context, t, ref, domainInputController),
|
||||
_buildAppsTab(
|
||||
context,
|
||||
ref,
|
||||
t,
|
||||
perAppProxyMode,
|
||||
filteredPackages,
|
||||
perAppProxyList,
|
||||
showSystemApps,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
NavigationBar(
|
||||
selectedIndex: 2,
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.home_20_regular),
|
||||
selectedIcon: const Icon(FluentIcons.home_20_filled),
|
||||
label: t.home.pageTitle,
|
||||
],
|
||||
),
|
||||
floatingActionButton: currentTab.value == 0
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => _showAddDomainModal(context, ref, domainInputController),
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(t.settings.network.excludedDomains.fabButton),
|
||||
)
|
||||
: null,
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (currentTab.value == 1)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Подсказка над кнопками
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0, bottom: 8.0),
|
||||
child: Text(
|
||||
perAppProxyMode == PerAppProxyMode.include ? t.settings.network.perAppProxyModes.includeMsg : t.settings.network.perAppProxyModes.excludeMsg,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: perAppProxyMode == PerAppProxyMode.include
|
||||
? ElevatedButton(
|
||||
onPressed: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
disabledBackgroundColor: Theme.of(context).colorScheme.primary,
|
||||
disabledForegroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.include),
|
||||
)
|
||||
: OutlinedButton(
|
||||
onPressed: () async {
|
||||
await ref.read(Preferences.perAppProxyMode.notifier).update(PerAppProxyMode.include);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.include),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: perAppProxyMode == PerAppProxyMode.exclude
|
||||
? ElevatedButton(
|
||||
onPressed: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
disabledBackgroundColor: Theme.of(context).colorScheme.primary,
|
||||
disabledForegroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.exclude),
|
||||
)
|
||||
: OutlinedButton(
|
||||
onPressed: () async {
|
||||
await ref.read(Preferences.perAppProxyMode.notifier).update(PerAppProxyMode.exclude);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(fontSize: 13),
|
||||
),
|
||||
child: Text(t.settings.network.perAppProxyModes.exclude),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.help_outline),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(t.settings.network.perAppProxyPageTitle),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${t.settings.network.perAppProxyModes.include}:",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(t.settings.network.perAppProxyModes.includeMsg),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
"${t.settings.network.perAppProxyModes.exclude}:",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(t.settings.network.perAppProxyModes.excludeMsg),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(MaterialLocalizations.of(context).okButtonLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
tooltip: t.settings.network.perAppProxyPageTitle,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.list_20_regular),
|
||||
selectedIcon: const Icon(FluentIcons.list_20_filled),
|
||||
label: t.proxies.pageTitle,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.more_vertical_20_regular),
|
||||
selectedIcon: const Icon(FluentIcons.more_vertical_20_filled),
|
||||
label: t.settings.network.excludedDomains.pageTitle,
|
||||
),
|
||||
],
|
||||
onDestinationSelected: (index) {
|
||||
if (index == 0) {
|
||||
const HomeRoute().go(context);
|
||||
} else if (index == 1) {
|
||||
const ProxiesRoute().go(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user