- Introduced a new Flutter project for the cxyz Android manga/comic reader, including essential files such as pubspec.yaml, AndroidManifest.xml, and Gradle configuration. - Added .gitignore files to exclude unnecessary files and directories for both the main project and Android-specific files. - Implemented initial README.md with project description, features, setup instructions, and API details for ComicLand, MangaRead, and MangaTown. - Configured analysis options and dependencies in pubspec.yaml to support Flutter development. - Established a pnpm workspace and lockfile for dependency management. - Included various Android resources such as icons, styles, and launch backgrounds for a complete application setup.
33 lines
961 B
Dart
33 lines
961 B
Dart
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<double> load() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final raw = prefs.getDouble(prefKey);
|
|
if (raw == null) return defaultScale;
|
|
return clamp(raw);
|
|
}
|
|
|
|
static Future<void> 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%';
|
|
}
|
|
}
|