forked from firka/student-legacy
finished custom fonts menu
This commit is contained in:
parent
50bb647d8f
commit
4a1aa75cb2
@ -27,6 +27,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/screens.i18n.dart';
|
||||
@ -46,6 +47,15 @@ class SettingsHelper {
|
||||
"de": "🇩🇪 Deutsch"
|
||||
};
|
||||
|
||||
static const List<String> fontList = [
|
||||
"Montserrat",
|
||||
"Merienda",
|
||||
"M PLUS Code Latin",
|
||||
"Figtree",
|
||||
"Fira Code",
|
||||
"Vollkorn",
|
||||
];
|
||||
|
||||
static const Map<Pages, String> pageTitle = {
|
||||
Pages.home: "home",
|
||||
Pages.grades: "grades",
|
||||
@ -111,6 +121,42 @@ class SettingsHelper {
|
||||
// }
|
||||
// }
|
||||
|
||||
static void fontFamily(BuildContext context) {
|
||||
SettingsProvider settings =
|
||||
Provider.of<SettingsProvider>(context, listen: false);
|
||||
|
||||
showBottomSheetMenu(
|
||||
context,
|
||||
items: List.generate(fontList.length, (index) {
|
||||
String font = fontList[index];
|
||||
return BottomSheetMenuItem(
|
||||
onPressed: () {
|
||||
settings.update(fontFamily: font == 'Montserrat' ? '' : font);
|
||||
Provider.of<ThemeModeObserver>(context, listen: false)
|
||||
.changeTheme(settings.theme, updateNavbarColor: false);
|
||||
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
font,
|
||||
style: GoogleFonts.getFont(font),
|
||||
),
|
||||
if (font == settings.fontFamily ||
|
||||
font.replaceAll('Montserrat', '') == settings.fontFamily)
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
static void iconPack(BuildContext context) {
|
||||
final settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
showBottomSheetMenu(
|
||||
|
@ -97,6 +97,7 @@ extension SettingsLocalization on String {
|
||||
"rename_subjects": "Rename Subjects",
|
||||
"rename_teachers": "Rename Teachers",
|
||||
"show_breaks": "Show Breaks",
|
||||
"fonts": "Fonts",
|
||||
},
|
||||
"hu_hu": {
|
||||
"personal_details": "Személyes információk",
|
||||
@ -192,6 +193,7 @@ extension SettingsLocalization on String {
|
||||
"rename_subjects": "Tantárgyak átnevezése",
|
||||
"rename_teachers": "Tanárok átnevezése",
|
||||
"show_breaks": "Szünetek megjelenítése",
|
||||
"fonts": "Betűk",
|
||||
},
|
||||
"de_de": {
|
||||
"personal_details": "Persönliche Angaben",
|
||||
@ -287,6 +289,7 @@ extension SettingsLocalization on String {
|
||||
"rename_subjects": "Fächer umbenennen",
|
||||
"rename_teachers": "Lehrer umbenennen",
|
||||
"show_breaks": "Pausen anzeigen",
|
||||
"fonts": "Schriftarten",
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,7 @@ import 'package:filcnaplo_mobile_ui/screens/settings/settings_screen.i18n.dart';
|
||||
import 'package:refilc_plus/models/premium_scopes.dart';
|
||||
import 'package:refilc_plus/providers/premium_provider.dart';
|
||||
import 'package:refilc_plus/ui/mobile/premium/upsell.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class MenuPersonalizeSettings extends StatelessWidget {
|
||||
const MenuPersonalizeSettings({
|
||||
@ -77,6 +78,7 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
||||
late List<Grade> otherShit;
|
||||
|
||||
late List<Widget> tiles;
|
||||
// late List<Widget> fontTiles;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -209,6 +211,53 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
||||
tiles = subjectTiles;
|
||||
}
|
||||
|
||||
// void buildFontTiles() {
|
||||
// List<String> fonts = [
|
||||
// "Merienda",
|
||||
// "M PLUS Code Latin",
|
||||
// "Figtree",
|
||||
// "Fira Code",
|
||||
// "Vollkorn",
|
||||
// ];
|
||||
|
||||
// List<Widget> fTiles = [];
|
||||
// var added = [];
|
||||
|
||||
// for (var f in fonts) {
|
||||
// if (added.contains(f)) continue;
|
||||
|
||||
// Widget widget = PanelButton(
|
||||
// onPressed: () async {
|
||||
// settingsProvider.update(fontFamily: f);
|
||||
// setState(() {});
|
||||
// },
|
||||
// title: Text(
|
||||
// f,
|
||||
// style: GoogleFonts.getFont(
|
||||
// f,
|
||||
// color: AppColors.of(context).text.withOpacity(.95),
|
||||
// fontStyle: settingsProvider.renamedSubjectsItalics
|
||||
// ? FontStyle.italic
|
||||
// : FontStyle.normal,
|
||||
// ),
|
||||
// ),
|
||||
// trailing: settingsProvider.fontFamily == f
|
||||
// ? Icon(
|
||||
// FeatherIcons.chevronRight,
|
||||
// size: 22.0,
|
||||
// color: AppColors.of(context).text.withOpacity(0.95),
|
||||
// )
|
||||
// : null,
|
||||
// borderRadius: BorderRadius.circular(12.0),
|
||||
// );
|
||||
|
||||
// fTiles.add(widget);
|
||||
// added.add(f);
|
||||
// }
|
||||
|
||||
// fontTiles = fTiles;
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
@ -232,6 +281,7 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
||||
|
||||
// build da tilés
|
||||
buildSubjectTiles();
|
||||
// buildFontTiles();
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: _hideContainersController,
|
||||
@ -730,6 +780,49 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
// custom fonts
|
||||
const SizedBox(
|
||||
height: 18.0,
|
||||
),
|
||||
SplittedPanel(
|
||||
title: Text('fonts'.i18n),
|
||||
padding: EdgeInsets.zero,
|
||||
cardPadding: const EdgeInsets.all(4.0),
|
||||
isSeparated: true,
|
||||
children: [
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.fontFamily(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text(
|
||||
"font_family".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text.withOpacity(.95),
|
||||
),
|
||||
),
|
||||
leading: Icon(
|
||||
FeatherIcons.globe,
|
||||
size: 22.0,
|
||||
color: AppColors.of(context).text.withOpacity(.95),
|
||||
),
|
||||
trailing: Text(
|
||||
settingsProvider.fontFamily != ''
|
||||
? settingsProvider.fontFamily
|
||||
: 'Montserrat',
|
||||
style: GoogleFonts.getFont(
|
||||
settingsProvider.fontFamily != ''
|
||||
? settingsProvider.fontFamily
|
||||
: 'Montserrat',
|
||||
fontSize: 14.0),
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12.0),
|
||||
bottom: Radius.circular(12.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -63,6 +63,7 @@ dependencies:
|
||||
url: https://github.com/kimaah/image_crop.git
|
||||
uuid: ^4.2.2
|
||||
maps_launcher: ^2.2.0
|
||||
google_fonts: ^4.0.4
|
||||
|
||||
dev_dependencies:
|
||||
flutter_lints: ^3.0.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user