Files
bookshelf/bookshelf_flutter/lib/features/settings/bloc/settings_bloc.dart
Yuriy Panov 2f97873095 Fix import paths and test issues
- Fixed test file import paths to point to correct Bloc file locations
- Fixed Bloc file import paths for models (../../../models/models.dart)
- Added explicit type annotations to resolve null safety warnings
- Fixed null safety issues in wishlist_bloc_test.dart
- All 70 tests now passing
2026-02-04 15:28:59 +06:00

39 lines
1.2 KiB
Dart

import 'package:flutter_bloc/flutter_bloc.dart';
import 'settings_event.dart';
import 'settings_state.dart';
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
SettingsBloc() : super(SettingsState.initial()) {
on<LoadSettings>(_onLoadSettings);
on<UpdateTheme>(_onUpdateTheme);
on<UpdateLanguage>(_onUpdateLanguage);
on<ToggleNotifications>(_onToggleNotifications);
on<ClearData>(_onClearData);
}
void _onLoadSettings(LoadSettings event, Emitter<SettingsState> emit) {
emit(state.copyWith(
isDarkMode: false,
language: 'English',
notificationsEnabled: true,
isLoading: false,
));
}
void _onUpdateTheme(UpdateTheme event, Emitter<SettingsState> emit) {
emit(state.copyWith(isDarkMode: event.isDarkMode));
}
void _onUpdateLanguage(UpdateLanguage event, Emitter<SettingsState> emit) {
emit(state.copyWith(language: event.language));
}
void _onToggleNotifications(
ToggleNotifications event, Emitter<SettingsState> emit) {
emit(state.copyWith(notificationsEnabled: !state.notificationsEnabled));
}
void _onClearData(ClearData event, Emitter<SettingsState> emit) {
emit(state.copyWith(dataCleared: true));
}
}