support default file pool selection

- add defaultPoolId to AppSettings + persistence
- extend SettingsScreen with pool dropdown
- update uploadAttachment to use defaultPoolId with fallback

Signed-off-by: Texas0295 <kimura@texas0295.top>
This commit is contained in:
Texas0295
2025-09-21 15:23:08 +08:00
parent b638343f02
commit 3621ea7744
10 changed files with 116 additions and 28 deletions

View File

@@ -6,7 +6,7 @@ part of 'room.dart';
// RiverpodGenerator
// **************************************************************************
String _$messagesNotifierHash() => r'fc3b66dfb8dd3fc55d142dae5c5e7bdc67eca5d4';
String _$messagesNotifierHash() => r'82a91344328ec44dfe934c80a4a770431d864bff';
/// Copied from Dart SDK
class _SystemHash {

View File

@@ -7,7 +7,7 @@ part of 'notification.dart';
// **************************************************************************
String _$notificationUnreadCountNotifierHash() =>
r'0763b66bd64e5a9b7c317887e109ab367515dfa4';
r'08c773809958d96a7ce82acf04af1f9e0b23e119';
/// See also [NotificationUnreadCountNotifier].
@ProviderFor(NotificationUnreadCountNotifier)
@@ -28,7 +28,7 @@ final notificationUnreadCountNotifierProvider =
typedef _$NotificationUnreadCountNotifier = AutoDisposeAsyncNotifier<int>;
String _$notificationListNotifierHash() =>
r'5099466db475bbcf1ab6b514eb072f1dc4c6f930';
r'260046e11f45b0d67ab25bcbdc8604890d71ccc7';
/// See also [NotificationListNotifier].
@ProviderFor(NotificationListNotifier)

View File

@@ -20,6 +20,7 @@ import 'package:material_symbols_icons/symbols.dart';
import 'package:path_provider/path_provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/pool_provider.dart';
class SettingsScreen extends HookConsumerWidget {
const SettingsScreen({super.key});
@@ -33,7 +34,7 @@ class SettingsScreen extends HookConsumerWidget {
final isDesktop =
!kIsWeb && (Platform.isWindows || Platform.isMacOS || Platform.isLinux);
final isWide = isWideScreen(context);
final poolsAsync = ref.watch(poolsProvider);
final docBasepath = useState<String?>(null);
useEffect(() {
@@ -367,6 +368,68 @@ class SettingsScreen extends HookConsumerWidget {
),
),
),
poolsAsync.when(
data: (pools) {
return ListTile(
isThreeLine: true,
minLeadingWidth: 48,
title: Text('settingsDefaultPool').tr(),
contentPadding: const EdgeInsets.only(left: 24, right: 17),
leading: const Icon(Symbols.cloud),
subtitle: Text(
settings.defaultPoolId != null
? pools
.firstWhereOrNull(
(p) => p.id == settings.defaultPoolId,
)
?.description ??
'settingsDefaultPoolHelper'.tr()
: 'settingsDefaultPoolHelper'.tr(),
style: Theme.of(context).textTheme.bodySmall,
),
trailing: DropdownButtonHideUnderline(
child: DropdownButton2<String>(
isExpanded: true,
items:
pools.map((p) {
return DropdownMenuItem<String>(
value: p.id,
child: Text(p.name).fontSize(14),
);
}).toList(),
value:
settings.defaultPoolId ??
(pools.isNotEmpty ? pools.first.id : null),
onChanged: (value) {
ref
.read(appSettingsNotifierProvider.notifier)
.setDefaultPoolId(value);
showSnackBar('settingsApplied'.tr());
},
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 5),
height: 40,
width: 220,
),
menuItemStyleData: const MenuItemStyleData(height: 40),
),
),
);
},
loading:
() => const ListTile(
minLeadingWidth: 48,
title: Text('Loading pools...'),
leading: CircularProgressIndicator(),
),
error:
(err, st) => ListTile(
minLeadingWidth: 48,
title: Text('settingsDefaultPool').tr(),
subtitle: Text('Error: $err'),
leading: const Icon(Icons.error, color: Colors.red),
),
),
];
final behaviorSettings = [