feat(customization): font switcher with Unbounded, styled via m3e

This commit is contained in:
klockky
2026-05-16 10:58:14 +03:00
parent cf1e8244d5
commit 8848ad1769
6 changed files with 397 additions and 11 deletions
+37
View File
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class AppFont {
final String id;
final String label;
final String googleFamily;
const AppFont({
required this.id,
required this.label,
required this.googleFamily,
});
}
class AppFonts {
static const String prefKey = 'app_font';
static const List<AppFont> all = [
AppFont(id: 'inter', label: 'Inter', googleFamily: 'Inter'),
AppFont(id: 'unbounded', label: 'Unbounded', googleFamily: 'Unbounded'),
];
static AppFont get fallback => all.first;
static AppFont byId(String? id) {
return all.firstWhere((f) => f.id == id, orElse: () => fallback);
}
static TextTheme textTheme(String id, TextTheme base) {
return GoogleFonts.getTextTheme(byId(id).googleFamily, base);
}
static TextStyle sample(String id, {required double fontSize}) {
return GoogleFonts.getFont(byId(id).googleFamily, fontSize: fontSize);
}
}