import 'package:shared_preferences/shared_preferences.dart'; /// Layout zoom for the in-app reader (`pageWidth = screenWidth * scale`). class ReaderZoom { static const prefKey = 'reader_zoom_scale'; static const double min = 0.4; static const double max = 1.5; static const double step = 0.1; static const double defaultScale = 1.0; static double clamp(double value) { final stepped = (value / step).round() * step; return stepped.clamp(min, max); } static Future load() async { final prefs = await SharedPreferences.getInstance(); final raw = prefs.getDouble(prefKey); if (raw == null) return defaultScale; return clamp(raw); } static Future save(double scale) async { final prefs = await SharedPreferences.getInstance(); await prefs.setDouble(prefKey, clamp(scale)); } static String percentLabel(double scale) { final pct = (clamp(scale) * 100).round(); return '$pct%'; } }