chore: run dart format
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions

This commit is contained in:
Dr.Blank 2026-01-10 16:51:05 +05:30
parent a520136e01
commit e23c0b6c5f
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
84 changed files with 1565 additions and 1945 deletions

View file

@ -11,10 +11,7 @@ import 'package:flutter/foundation.dart';
import 'package:vaani/main.dart' show appLogger;
class LibrarySwitchChip extends HookConsumerWidget {
const LibrarySwitchChip({
super.key,
required this.libraries,
});
const LibrarySwitchChip({super.key, required this.libraries});
final List<Library> libraries;
@override
@ -26,30 +23,22 @@ class LibrarySwitchChip extends HookConsumerWidget {
AbsIcons.getIconByName(
apiSettings.activeLibraryId != null
? libraries
.firstWhere(
(lib) => lib.id == apiSettings.activeLibraryId,
)
.icon
.firstWhere((lib) => lib.id == apiSettings.activeLibraryId)
.icon
: libraries.first.icon,
),
), // Replace with your icon
label: const Text('Change Library'),
// Enable only if libraries are loaded and not empty
onPressed: libraries.isNotEmpty
? () => showLibrarySwitcher(
context,
ref,
)
? () => showLibrarySwitcher(context, ref)
: null, // Disable if no libraries
);
}
}
// --- Helper Function to Show the Switcher ---
void showLibrarySwitcher(
BuildContext context,
WidgetRef ref,
) {
void showLibrarySwitcher(BuildContext context, WidgetRef ref) {
final content = _LibrarySelectionContent();
// --- Platform-Specific UI ---
@ -209,7 +198,9 @@ class _LibrarySelectionContent extends ConsumerWidget {
// Get current settings state
final currentSettings = ref.read(apiSettingsProvider);
// Update the active library ID
ref.read(apiSettingsProvider.notifier).updateState(
ref
.read(apiSettingsProvider.notifier)
.updateState(
currentSettings.copyWith(activeLibraryId: library.id),
);
// Close the dialog/bottom sheet