Fix minor bugs

This commit is contained in:
problematicconsumer
2023-12-31 10:49:37 +03:30
parent d8ffeb2ef4
commit 789c559565
4 changed files with 32 additions and 60 deletions

View File

@@ -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(

View File

@@ -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<void> update(ProxiesSort value) {
state = value;

View File

@@ -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<ProxiesSort>(
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<ProxiesSort>(
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(),
],
),

View File

@@ -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": [
"@:"
]
}
}