Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
83274be574 |
|||
|
6b218b03ee |
|||
|
88cdcf9863 |
|||
|
e2f25749e0 |
3 changed files with 91 additions and 57 deletions
|
|
@ -10,6 +10,7 @@ import "package:nexus/controllers/client.dart";
|
||||||
import "package:nexus/controllers/client_state.dart";
|
import "package:nexus/controllers/client_state.dart";
|
||||||
import "package:nexus/controllers/settings.dart";
|
import "package:nexus/controllers/settings.dart";
|
||||||
import "package:nexus/controllers/unified_push.dart";
|
import "package:nexus/controllers/unified_push.dart";
|
||||||
|
import "package:nexus/controllers/spec_versions.dart";
|
||||||
import "package:nexus/models/account_data.dart";
|
import "package:nexus/models/account_data.dart";
|
||||||
import "package:nexus/models/settings_category.dart";
|
import "package:nexus/models/settings_category.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
|
|
@ -20,9 +21,6 @@ class SettingsSectionsController
|
||||||
@override
|
@override
|
||||||
Future<IMap<String, IList<SettingsCategory>>> build() async {
|
Future<IMap<String, IList<SettingsCategory>>> build() async {
|
||||||
final settings = await ref.watch(SettingsController.provider.future);
|
final settings = await ref.watch(SettingsController.provider.future);
|
||||||
final specVersionsResponse = await ref
|
|
||||||
.watch(ClientController.provider.notifier)
|
|
||||||
.getSpecVersions();
|
|
||||||
|
|
||||||
return .new({
|
return .new({
|
||||||
"General": .new([
|
"General": .new([
|
||||||
|
|
@ -52,6 +50,7 @@ class SettingsSectionsController
|
||||||
title: "Use Dynamic Theme",
|
title: "Use Dynamic Theme",
|
||||||
icon: Icons.palette,
|
icon: Icons.palette,
|
||||||
description: "Toggle on or off Dynamic Theme. Only available on Android, Linux, Windows, or MacOS.",
|
description: "Toggle on or off Dynamic Theme. Only available on Android, Linux, Windows, or MacOS.",
|
||||||
|
description: "Toggle on or off Dynamic Theme. Only available on Android, Linux, Windows, or MacOS.",
|
||||||
builder: (title, description, icon) => SwitchListTile(
|
builder: (title, description, icon) => SwitchListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
subtitle: Text(description),
|
subtitle: Text(description),
|
||||||
|
|
@ -78,6 +77,7 @@ class SettingsSectionsController
|
||||||
.new(
|
.new(
|
||||||
title: "Linux Mobile Mode",
|
title: "Linux Mobile Mode",
|
||||||
description: "Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window.",
|
description: "Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window.",
|
||||||
|
description: "Enables some fixes for Linux mobile, e.g. disabling dragging appbar for moving window.",
|
||||||
icon: Icons.construction,
|
icon: Icons.construction,
|
||||||
builder: (title, description, icon) => SwitchListTile(
|
builder: (title, description, icon) => SwitchListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
|
|
@ -145,9 +145,13 @@ class SettingsSectionsController
|
||||||
.new(
|
.new(
|
||||||
title: "Invite Blocking",
|
title: "Invite Blocking",
|
||||||
description: "Block invites, either completely, or block only invites from users without shared private rooms (depends on server support).",
|
description: "Block invites, either completely, or block only invites from users without shared private rooms (depends on server support).",
|
||||||
|
description: "Block invites, either completely, or block only invites from users without shared private rooms (depends on server support).",
|
||||||
builder: (title, description, icon) => Consumer(
|
builder: (title, description, icon) => Consumer(
|
||||||
builder: (context, ref, _) =>
|
builder: (context, ref, _) {
|
||||||
DialogListTile<DefaultInviteAction>(
|
final specVersionsResponse = ref.watch(
|
||||||
|
SpecVersionsController.provider,
|
||||||
|
);
|
||||||
|
return DialogListTile<DefaultInviteAction>(
|
||||||
icon: Icon(icon),
|
icon: Icon(icon),
|
||||||
title: title,
|
title: title,
|
||||||
subtitle: Text(description),
|
subtitle: Text(description),
|
||||||
|
|
@ -155,7 +159,11 @@ class SettingsSectionsController
|
||||||
.watch(AccountDataController.provider)
|
.watch(AccountDataController.provider)
|
||||||
.invitePermissionConfig
|
.invitePermissionConfig
|
||||||
.defaultAction,
|
.defaultAction,
|
||||||
options: specVersionsResponse.unstableFeatures.msc4494
|
options:
|
||||||
|
specVersionsResponse.maybeWhen(
|
||||||
|
data: (data) => data.unstableFeatures.msc4494,
|
||||||
|
orElse: () => true,
|
||||||
|
)
|
||||||
? DefaultInviteAction.values
|
? DefaultInviteAction.values
|
||||||
: IList(DefaultInviteAction.values)
|
: IList(DefaultInviteAction.values)
|
||||||
.remove(.denyPublic)
|
.remove(.denyPublic)
|
||||||
|
|
@ -165,7 +173,9 @@ class SettingsSectionsController
|
||||||
.deny => "Deny",
|
.deny => "Deny",
|
||||||
.denyPublic => "Deny public",
|
.denyPublic => "Deny public",
|
||||||
},
|
},
|
||||||
onChanged: (value) => ref
|
onChanged: specVersionsResponse.maybeWhen(
|
||||||
|
data: (_) =>
|
||||||
|
(value) => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.watch(ClientController.provider.notifier)
|
||||||
.setAccountData(
|
.setAccountData(
|
||||||
.new(
|
.new(
|
||||||
|
|
@ -176,7 +186,10 @@ class SettingsSectionsController
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
|
orElse: () => null,
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
icon: Icons.person_off,
|
icon: Icons.person_off,
|
||||||
),
|
),
|
||||||
|
|
@ -197,6 +210,8 @@ class SettingsSectionsController
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.popUntil((route) => route.isFirst);
|
.popUntil((route) => route.isFirst);
|
||||||
|
Navigator.of(context)
|
||||||
|
.popUntil((route) => route.isFirst);
|
||||||
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
await WidgetsBinding.instance.endOfFrame;
|
||||||
|
|
||||||
|
|
|
||||||
15
lib/controllers/spec_versions.dart
Normal file
15
lib/controllers/spec_versions.dart
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
|
import "package:nexus/controllers/client.dart";
|
||||||
|
import "package:nexus/models/spec_versions_response.dart";
|
||||||
|
|
||||||
|
class SpecVersionsController extends AsyncNotifier<SpecVersionsResponse> {
|
||||||
|
@override
|
||||||
|
Future<SpecVersionsResponse> build() =>
|
||||||
|
ref.watch(ClientController.provider.notifier).getSpecVersions();
|
||||||
|
|
||||||
|
static final provider =
|
||||||
|
AsyncNotifierProvider.autoDispose<
|
||||||
|
SpecVersionsController,
|
||||||
|
SpecVersionsResponse
|
||||||
|
>(SpecVersionsController.new);
|
||||||
|
}
|
||||||
|
|
@ -170,14 +170,17 @@ class const SettingsPage({super.key}) extends ConsumerWidget {
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
children: [
|
children: [
|
||||||
NavigationRailM3E(
|
MaterialUiCompatibilityBridge(
|
||||||
|
child: NavigationRailM3E(
|
||||||
type: .alwaysExpand,
|
type: .alwaysExpand,
|
||||||
trailing: searchBar,
|
trailing: searchBar,
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
sections: sections
|
sections: sections
|
||||||
.mapTo(
|
.mapTo(
|
||||||
(categoryGroup, categories) =>
|
(
|
||||||
NavigationRailM3ESection(
|
categoryGroup,
|
||||||
|
categories,
|
||||||
|
) => NavigationRailM3ESection(
|
||||||
header: DividerText(categoryGroup),
|
header: DividerText(categoryGroup),
|
||||||
destinations: categories
|
destinations: categories
|
||||||
.map(
|
.map(
|
||||||
|
|
@ -195,6 +198,7 @@ class const SettingsPage({super.key}) extends ConsumerWidget {
|
||||||
onDestinationSelected: (value) =>
|
onDestinationSelected: (value) =>
|
||||||
selected.value = value,
|
selected.value = value,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
VerticalDivider(),
|
VerticalDivider(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SuperListView(
|
child: SuperListView(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue