mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-01-17 07:39:32 +00:00
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
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:
parent
a520136e01
commit
e23c0b6c5f
84 changed files with 1565 additions and 1945 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue