From 789c559565125f60ce72ce7936dd4cc953b5bf24 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Sun, 31 Dec 2023 10:49:37 +0330 Subject: [PATCH] Fix minor bugs --- .../data/connection_repository.dart | 3 - .../overview/proxies_overview_notifier.dart | 8 ++- .../proxy/overview/proxies_overview_page.dart | 57 +++++++++---------- project.inlang.json | 24 -------- 4 files changed, 32 insertions(+), 60 deletions(-) delete mode 100644 project.inlang.json diff --git a/lib/features/connection/data/connection_repository.dart b/lib/features/connection/data/connection_repository.dart index 5271b364..fe544dd2 100644 --- a/lib/features/connection/data/connection_repository.dart +++ b/lib/features/connection/data/connection_repository.dart @@ -132,7 +132,6 @@ class ConnectionRepositoryImpl false, ) .map((r) { - loggy.debug("setup complete"); _initialized = true; return r; }) @@ -169,9 +168,7 @@ class ConnectionRepositoryImpl }), ); await $(setup()); - loggy.debug("after setup"); await $(applyConfigOption(options)); - loggy.debug("after apply"); return await $( singbox .start( diff --git a/lib/features/proxy/overview/proxies_overview_notifier.dart b/lib/features/proxy/overview/proxies_overview_notifier.dart index 6c3fc4a7..ae2732be 100644 --- a/lib/features/proxy/overview/proxies_overview_notifier.dart +++ b/lib/features/proxy/overview/proxies_overview_notifier.dart @@ -29,7 +29,7 @@ enum ProxiesSort { } @Riverpod(keepAlive: true) -class ProxiesSortNotifier extends _$ProxiesSortNotifier { +class ProxiesSortNotifier extends _$ProxiesSortNotifier with AppLogger { late final _pref = Pref( ref.watch(sharedPreferencesProvider).requireValue, "proxies_sort_mode", @@ -39,7 +39,11 @@ class ProxiesSortNotifier extends _$ProxiesSortNotifier { ); @override - ProxiesSort build() => _pref.getValue(); + ProxiesSort build() { + final sortBy = _pref.getValue(); + loggy.info("sort proxies by: [${sortBy.name}]"); + return sortBy; + } Future update(ProxiesSort value) { state = value; diff --git a/lib/features/proxy/overview/proxies_overview_page.dart b/lib/features/proxy/overview/proxies_overview_page.dart index 1720473a..389946e9 100644 --- a/lib/features/proxy/overview/proxies_overview_page.dart +++ b/lib/features/proxy/overview/proxies_overview_page.dart @@ -23,15 +23,35 @@ class ProxiesOverviewPage extends HookConsumerWidget with PresLogger { CustomToast.error(t.presentShortError(error)).show(context), ); + final appBar = NestedAppBar( + title: Text(t.proxies.pageTitle), + actions: [ + PopupMenuButton( + initialValue: sortBy, + onSelected: ref.read(proxiesSortNotifierProvider.notifier).update, + icon: const Icon(Icons.sort), + tooltip: t.proxies.sortTooltip, + itemBuilder: (context) { + return [ + ...ProxiesSort.values.map( + (e) => PopupMenuItem( + value: e, + child: Text(e.present(t)), + ), + ), + ]; + }, + ), + ], + ); + switch (asyncProxies) { case AsyncData(value: final groups): if (groups.isEmpty) { return Scaffold( body: CustomScrollView( slivers: [ - NestedAppBar( - title: Text(t.proxies.pageTitle), - ), + appBar, SliverFillRemaining( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -50,28 +70,7 @@ class ProxiesOverviewPage extends HookConsumerWidget with PresLogger { return Scaffold( body: CustomScrollView( slivers: [ - NestedAppBar( - title: Text(t.proxies.pageTitle), - actions: [ - PopupMenuButton( - initialValue: sortBy, - onSelected: - ref.read(proxiesSortNotifierProvider.notifier).update, - icon: const Icon(Icons.sort), - tooltip: t.proxies.sortTooltip, - itemBuilder: (context) { - return [ - ...ProxiesSort.values.map( - (e) => PopupMenuItem( - value: e, - child: Text(e.present(t)), - ), - ), - ]; - }, - ), - ], - ), + appBar, SliverLayoutBuilder( builder: (context, constraints) { final width = constraints.crossAxisExtent; @@ -140,9 +139,7 @@ class ProxiesOverviewPage extends HookConsumerWidget with PresLogger { return Scaffold( body: CustomScrollView( slivers: [ - NestedAppBar( - title: Text(t.proxies.pageTitle), - ), + appBar, SliverErrorBodyPlaceholder( t.presentShortError(error), icon: null, @@ -155,9 +152,7 @@ class ProxiesOverviewPage extends HookConsumerWidget with PresLogger { return Scaffold( body: CustomScrollView( slivers: [ - NestedAppBar( - title: Text(t.proxies.pageTitle), - ), + appBar, const SliverLoadingBodyPlaceholder(), ], ), diff --git a/project.inlang.json b/project.inlang.json deleted file mode 100644 index 0ce0eb6d..00000000 --- a/project.inlang.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "https://inlang.com/schema/project-settings", - "sourceLanguageTag": "en", - "languageTags": [ - "en", - "fa", - "ru", - "tr", - "zh-CN" - ], - "modules": [ - "https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@4/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@1/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@1/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@1/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@1/dist/index.js" - ], - "plugin.inlang.i18next": { - "pathPattern": "./assets/translations/strings_{languageTag}.i18n.json", - "variableReferencePattern": [ - "@:" - ] - } -} \ No newline at end of file