import 'package:hl_lieferservice/feature/settings/model/settings.dart';
import 'package:shared_preferences/shared_preferences.dart';

class SettingsRepository {
  Future<Settings> getSettings() async {
    final prefs = await SharedPreferences.getInstance();

    bool? useHardwareScanner = prefs.getBool("useHardwareScanner");

    if (useHardwareScanner == null) {
      await prefs.setBool("useHardwareScanner", false);
      useHardwareScanner = false;
    }

    return Settings(useHardwareScanner: useHardwareScanner);
  }

  Future<void> saveSettings(Settings settings) async {
    final prefs = await SharedPreferences.getInstance();
    await prefs.setBool("useHardwareScanner", settings.useHardwareScanner);
  }
}