changed everything from filcnaplo to refilc finally

This commit is contained in:
Kima
2024-02-24 20:12:25 +01:00
parent 0d1c7b7143
commit 1171e3aaaf
655 changed files with 38728 additions and 44967 deletions

View File

@@ -0,0 +1,398 @@
// ignore_for_file: use_build_context_synchronously
import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/utils/format.dart';
import 'package:refilc_kreta_api/models/subject.dart';
import 'package:refilc_kreta_api/models/teacher.dart';
import 'package:refilc_kreta_api/providers/absence_provider.dart';
import 'package:refilc_kreta_api/providers/grade_provider.dart';
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
// import 'package:refilc_mobile_ui/screens/settings/settings_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'edit_subject.i18n.dart';
class EditSubjectScreen extends StatefulWidget {
const EditSubjectScreen({
super.key,
required this.subject,
required this.teacher,
});
final GradeSubject subject;
final Teacher teacher;
@override
EditSubjectScreenState createState() => EditSubjectScreenState();
}
class EditSubjectScreenState extends State<EditSubjectScreen> {
late SettingsProvider settingsProvider;
late DatabaseProvider databaseProvider;
late UserProvider user;
final _subjectName = TextEditingController();
final _teacherName = TextEditingController();
@override
Widget build(BuildContext context) {
settingsProvider = Provider.of<SettingsProvider>(context);
databaseProvider = Provider.of<DatabaseProvider>(context);
user = Provider.of<UserProvider>(context);
return Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
(widget.subject.isRenamed && settingsProvider.renamedSubjectsEnabled
? widget.subject.renamedTo
: widget.subject.name.capital()) ??
'',
style: TextStyle(
color: AppColors.of(context).text,
fontStyle: settingsProvider.renamedSubjectsItalics
? FontStyle.italic
: FontStyle.normal,
),
),
actions: [
IconButton(
onPressed: () async {
Map<String, String> subs = await databaseProvider.userQuery
.renamedSubjects(userId: user.id!);
subs.remove(widget.subject.id);
await databaseProvider.userStore
.storeRenamedSubjects(subs, userId: user.id!);
Map<String, String> teach = await databaseProvider.userQuery
.renamedTeachers(userId: user.id!);
teach.remove(widget.teacher.id);
await databaseProvider.userStore
.storeRenamedTeachers(teach, userId: user.id!);
updateProviders();
// im crying rn
Navigator.of(context).pop();
Navigator.of(context).pop();
setState(() {});
},
icon: const Icon(FeatherIcons.trash2),
),
const SizedBox(
width: 8.0,
),
],
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
// rename subject
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
showSubjectRenameDialog();
},
title: Text("rename_it".i18n),
leading: Icon(
FeatherIcons.penTool,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// rename teacher
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
showTeacherRenameDialog();
},
title: Text("rename_te".i18n),
leading: Icon(
FeatherIcons.user,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// edit rounding
// SplittedPanel(
// padding: const EdgeInsets.only(top: 9.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [
// PanelButton(
// onPressed: () {
// SettingsHelper.newRoundings(context, widget.subject);
// setState(() {});
// },
// title: Text(
// "rounding".i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(.95),
// ),
// ),
// leading: Icon(
// FeatherIcons.gitCommit,
// size: 22.0,
// color: AppColors.of(context).text.withOpacity(.95),
// ),
// trailing: Text(
// ((widget.subject.customRounding ??
// settingsProvider.rounding) /
// 10)
// .toStringAsFixed(1),
// style: const TextStyle(fontSize: 14.0),
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12.0),
// bottom: Radius.circular(12.0),
// ),
// ),
// ],
// ),
],
),
),
),
);
}
// rename dialogs
void showSubjectRenameDialog() {
_subjectName.text = widget.subject.renamedTo ?? '';
showDialog(
context: context,
builder: (context) => StatefulBuilder(builder: (context, setS) {
return AlertDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(14.0))),
title: Text("rename_it".i18n),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius:
const BorderRadius.all(Radius.circular(12.0))),
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Center(
child: Text(
widget.subject.name,
style: const TextStyle(
fontWeight: FontWeight.w500, fontSize: 16.0),
),
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Icon(FeatherIcons.arrowDown, size: 32),
),
TextField(
controller: _subjectName,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
focusedBorder: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
hintText: "modified_name".i18n,
suffixIcon: IconButton(
icon: const Icon(
FeatherIcons.x,
color: Colors.grey,
),
onPressed: () {
setState(() {
_subjectName.text = "";
});
},
),
),
),
],
),
actions: [
TextButton(
child: Text(
"cancel".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () {
Navigator.of(context).maybePop();
},
),
TextButton(
child: Text(
"done".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () async {
Map<String, String> renamedSubjs = await databaseProvider
.userQuery
.renamedSubjects(userId: user.id!);
renamedSubjs[widget.subject.id] = _subjectName.text;
await databaseProvider.userStore
.storeRenamedSubjects(renamedSubjs, userId: user.id!);
updateProviders();
Navigator.of(context).pop();
setState(() {});
},
),
],
);
}),
).then((val) {
_subjectName.text = "";
});
}
void showTeacherRenameDialog() {
_teacherName.text = widget.teacher.renamedTo ?? '';
showDialog(
context: context,
builder: (context) => StatefulBuilder(builder: (context, setS) {
return AlertDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(14.0))),
title: Text("rename_te".i18n),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius:
const BorderRadius.all(Radius.circular(12.0))),
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Center(
child: Text(
widget.teacher.name,
style: const TextStyle(
fontWeight: FontWeight.w500, fontSize: 16.0),
),
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Icon(FeatherIcons.arrowDown, size: 32),
),
TextField(
controller: _teacherName,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
focusedBorder: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
hintText: "modified_name".i18n,
suffixIcon: IconButton(
icon: const Icon(
FeatherIcons.x,
color: Colors.grey,
),
onPressed: () {
setState(() {
_teacherName.text = "";
});
},
),
),
),
],
),
actions: [
TextButton(
child: Text(
"cancel".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () {
Navigator.of(context).maybePop();
},
),
TextButton(
child: Text(
"done".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () async {
Map<String, String> renamedTeach = await databaseProvider
.userQuery
.renamedTeachers(userId: user.id!);
renamedTeach[widget.teacher.id] = _teacherName.text;
await databaseProvider.userStore
.storeRenamedTeachers(renamedTeach, userId: user.id!);
updateProviders();
Navigator.of(context).pop();
setState(() {});
},
),
],
);
}),
).then((val) {
_teacherName.text = "";
});
}
void updateProviders() async {
await Provider.of<GradeProvider>(context, listen: false)
.convertBySettings();
await Provider.of<TimetableProvider>(context, listen: false)
.convertBySettings();
await Provider.of<AbsenceProvider>(context, listen: false)
.convertBySettings();
}
}

View File

@@ -0,0 +1,42 @@
import 'package:i18n_extension/i18n_extension.dart';
extension SettingsLocalization on String {
static final _t = Translations.byLocale("hu_hu") +
{
"en_en": {
"rename_it": "Rename Subject",
"rename_te": "Rename Teacher",
"rounding": "Rounding",
"gs_mode": "Good Student Mode",
"rename_subject": "Rename Subject",
"modified_name": "Modified Name",
"cancel": "Cancel",
"done": "Done",
},
"hu_hu": {
"rename_it": "Tantárgy átnevezése",
"rename_te": "Tanár átnevezése",
"rounding": "Kerekítés",
"gs_mode": "Jó tanuló mód",
"rename_subject": "Tantárgy átnevezése",
"modified_name": "Módosított név",
"cancel": "Mégse",
"done": "Kész",
},
"de_de": {
"rename_it": "Betreff umbenennen",
"rename_te": "Lehrer umbenennen",
"rounding": "Rundung",
"gs_mode": "Guter Student Modus",
"rename_subject": "Fach umbenennen",
"modified_name": "Geänderter Name",
"cancel": "Abbrechen",
"done": "Erledigt",
},
};
String get i18n => localize(this, _t);
String fill(List<Object> params) => localizeFill(this, params);
String plural(int value) => localizePlural(value, this, _t);
String version(Object modifier) => localizeVersion(modifier, this, _t);
}

View File

@@ -0,0 +1,156 @@
// import 'package:refilc/models/settings.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.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:refilc_plus/ui/mobile/settings/welcome_message.dart';
// import 'package:provider/provider.dart';
import 'submenu_screen.i18n.dart';
class MenuExtrasSettings extends StatelessWidget {
const MenuExtrasSettings({
super.key,
this.borderRadius = const BorderRadius.vertical(
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
});
final BorderRadius borderRadius;
@override
Widget build(BuildContext context) {
return PanelButton(
onPressed: () => Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(builder: (context) => const ExtrasSettingsScreen()),
),
title: Text("extras".i18n),
leading: Icon(
FeatherIcons.edit,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: borderRadius,
);
}
}
class ExtrasSettingsScreen extends StatefulWidget {
const ExtrasSettingsScreen({super.key});
@override
ExtrasSettingsScreenState createState() => ExtrasSettingsScreenState();
}
class ExtrasSettingsScreenState extends State<ExtrasSettingsScreen> {
late SettingsProvider settingsProvider;
late UserProvider user;
@override
Widget build(BuildContext context) {
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
UserProvider user = Provider.of<UserProvider>(context);
return Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
"extras".i18n,
style: TextStyle(color: AppColors.of(context).text),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () async {
if (!Provider.of<PremiumProvider>(context, listen: false)
.hasScope(PremiumScopes.customGradeRarities)) {
return PremiumLockedFeatureUpsell.show(
context: context,
feature: PremiumFeature.gradeRarities);
}
// settingsProvider.update(
// gradeOpeningFun: !settingsProvider.gradeOpeningFun);
SettingsHelper.surpriseGradeRarityText(
context,
title: 'rarity_title'.i18n,
cancel: 'cancel'.i18n,
done: 'done'.i18n,
rarities: [
"common".i18n,
"uncommon".i18n,
"rare".i18n,
"epic".i18n,
"legendary".i18n,
],
);
setState(() {});
},
trailingDivider: true,
title: Text(
"surprise_grades".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.gradeOpeningFun ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.gift,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.gradeOpeningFun ? .95 : .25),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(gradeOpeningFun: v);
setState(() {});
},
value: settingsProvider.gradeOpeningFun,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
WelcomeMessagePanelButton(settingsProvider, user),
],
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,371 @@
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/utils/format.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_screen.i18n.dart';
class MenuGeneralSettings extends StatelessWidget {
const MenuGeneralSettings({
super.key,
this.borderRadius = const BorderRadius.vertical(
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
});
final BorderRadius borderRadius;
@override
Widget build(BuildContext context) {
return PanelButton(
onPressed: () => Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(builder: (context) => const GeneralSettingsScreen()),
),
title: Text("general".i18n),
leading: Icon(
FeatherIcons.settings,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: borderRadius,
);
}
}
class GeneralSettingsScreen extends StatefulWidget {
const GeneralSettingsScreen({super.key});
@override
GeneralSettingsScreenState createState() => GeneralSettingsScreenState();
}
class GeneralSettingsScreenState extends State<GeneralSettingsScreen> {
@override
Widget build(BuildContext context) {
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
String startPageTitle =
SettingsHelper.localizedPageTitles()[settingsProvider.startPage] ?? "?";
String languageText =
SettingsHelper.langMap[settingsProvider.language] ?? "?";
String vibrateTitle = {
VibrationStrength.off: "voff".i18n,
VibrationStrength.light: "vlight".i18n,
VibrationStrength.medium: "vmedium".i18n,
VibrationStrength.strong: "vstrong".i18n,
}[settingsProvider.vibrate] ??
"?";
return Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
"general".i18n,
style: TextStyle(color: AppColors.of(context).text),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
SettingsHelper.bellDelay(context);
setState(() {});
},
title: Text(
"bell_delay".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.bellDelayEnabled ? .95 : .25),
),
),
leading: Icon(
settingsProvider.bellDelayEnabled
? FeatherIcons.bell
: FeatherIcons.bellOff,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.bellDelayEnabled ? .95 : .25),
),
trailingDivider: true,
trailing: Switch(
onChanged: (v) =>
settingsProvider.update(bellDelayEnabled: v),
value: settingsProvider.bellDelayEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.rounding(context);
setState(() {});
},
title: Text(
"rounding".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.gitCommit,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Text(
(settingsProvider.rounding / 10).toStringAsFixed(1),
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settingsProvider.update(
graphClassAvg: !settingsProvider.graphClassAvg);
setState(() {});
},
title: Text(
"graph_class_avg".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.graphClassAvg ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.barChart,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.graphClassAvg ? .95 : .25),
),
trailing: Switch(
onChanged: (v) =>
settingsProvider.update(graphClassAvg: v),
value: settingsProvider.graphClassAvg,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.startPage(context);
setState(() {});
},
title: Text(
"startpage".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.play,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Text(
startPageTitle.capital(),
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.language(context);
setState(() {});
},
title: Text(
"language".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(
languageText,
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.vibrate(context);
setState(() {});
},
title: Text(
"vibrate".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.radio,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Text(
vibrateTitle,
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settingsProvider.update(
showBreaks: !settingsProvider.showBreaks);
setState(() {});
},
title: Text(
"show_breaks".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.showBreaks ? .95 : .25),
),
),
leading: Icon(
settingsProvider.showBreaks
? FeatherIcons.eye
: FeatherIcons.eyeOff,
size: 22.0,
color: AppColors.of(context)
.text
.withOpacity(settingsProvider.showBreaks ? .95 : .25),
),
trailing: Switch(
onChanged: (v) => settingsProvider.update(showBreaks: v),
value: settingsProvider.showBreaks,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () {
settingsProvider.update(
newsEnabled: !settingsProvider.newsEnabled);
setState(() {});
},
title: Text(
"news".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.newsEnabled ? .95 : .25),
),
),
leading: Icon(
Icons.newspaper_outlined,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.newsEnabled ? .95 : .25),
),
trailing: Switch(
onChanged: (v) => settingsProvider.update(newsEnabled: v),
value: settingsProvider.newsEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,572 @@
// ignore_for_file: use_build_context_synchronously
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/models/shared_theme.dart';
import 'package:refilc/theme/colors/accent.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/theme/observer.dart';
import 'package:refilc_kreta_api/providers/share_provider.dart';
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
import 'package:refilc_mobile_ui/common/empty.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_screen.i18n.dart';
import 'package:share_plus/share_plus.dart';
class MenuPaintList extends StatelessWidget {
const MenuPaintList({
super.key,
this.borderRadius = const BorderRadius.vertical(
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
});
final BorderRadius borderRadius;
@override
Widget build(BuildContext context) {
return PanelButton(
onPressed: () async {
List<SharedTheme> publicThemes =
await Provider.of<ShareProvider>(context, listen: false)
.getAllPublicThemes(context);
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(
builder: (context) => PaintListScreen(publicThemes: publicThemes)));
},
title: Text(
"own_paints".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.list,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: borderRadius,
);
}
}
class PaintListScreen extends StatefulWidget {
const PaintListScreen({super.key, required this.publicThemes});
final List<SharedTheme> publicThemes;
@override
PaintListScreenState createState() => PaintListScreenState();
}
class PaintListScreenState extends State<PaintListScreen>
with SingleTickerProviderStateMixin {
late SettingsProvider settingsProvider;
late UserProvider user;
late ShareProvider shareProvider;
late AnimationController _hideContainersController;
late List<Widget> tiles;
final _paintId = TextEditingController();
SharedTheme? newThemeByID;
@override
void initState() {
super.initState();
shareProvider = Provider.of<ShareProvider>(context, listen: false);
_hideContainersController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 200));
}
void buildPublicPaintTiles() async {
List<Widget> subjectTiles = [];
var added = [];
var i = 0;
for (var t in widget.publicThemes) {
if (added.contains(t.id)) continue;
Widget w = PanelButton(
onPressed: () => {
// TODO: set theme
},
title: Column(
children: [
Text(
t.displayName,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
Text(
t.nickname,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.75),
),
),
],
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
margin: const EdgeInsets.only(left: 2.0),
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: t.backgroundColor,
),
),
Container(
margin: const EdgeInsets.only(left: 2.0),
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: t.panelsColor,
),
),
Container(
margin: const EdgeInsets.only(left: 2.0),
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: t.accentColor,
),
),
],
),
borderRadius: BorderRadius.vertical(
top: Radius.circular(i == 0 ? 12.0 : 4.0),
bottom:
Radius.circular(i + 1 == widget.publicThemes.length ? 12.0 : 4.0),
),
);
i += 1;
subjectTiles.add(w);
added.add(t.id);
}
if (widget.publicThemes.isEmpty) {
subjectTiles.add(Empty(
subtitle: 'no_pub_paint'.i18n,
));
}
tiles = subjectTiles;
}
@override
Widget build(BuildContext context) {
settingsProvider = Provider.of<SettingsProvider>(context);
user = Provider.of<UserProvider>(context);
buildPublicPaintTiles();
return AnimatedBuilder(
animation: _hideContainersController,
builder: (context, child) => Opacity(
opacity: 1 - _hideContainersController.value,
child: Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
"own_paints".i18n,
style: TextStyle(color: AppColors.of(context).text),
),
),
body: SingleChildScrollView(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
// enter id
SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(3.0),
hasBorder: true,
isTransparent: true,
children: [
PanelButton(
onPressed: () => showEnterIDDialog(),
title: Text(
"enter_id".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.plus,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
const SizedBox(
height: 18.0,
),
// current paint
SplittedPanel(
title: Text('current_paint'.i18n),
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: [
PanelButton(
onPressed: () async {
if (settingsProvider.currentThemeId != '') {
Share.share(
settingsProvider.currentThemeId,
subject: 'share_subj_theme'.i18n,
);
} else {
SharedGradeColors gradeColors = await shareProvider
.shareCurrentGradeColors(context);
SharedTheme theme =
await shareProvider.shareCurrentTheme(
context,
gradeColors: gradeColors,
);
Share.share(
theme.id,
subject: 'share_subj_theme'.i18n,
);
}
},
longPressInstead: true,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
settingsProvider.currentThemeDisplayName != ''
? settingsProvider.currentThemeDisplayName
: 'no_name'.i18n,
style: TextStyle(
color:
AppColors.of(context).text.withOpacity(.95),
),
),
Text(
settingsProvider.currentThemeCreator != ''
? settingsProvider.currentThemeCreator
: 'Anonymous',
style: TextStyle(
color:
AppColors.of(context).text.withOpacity(.65),
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
),
],
),
trailing: Transform.translate(
offset: const Offset(8.0, 0.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
margin: const EdgeInsets.only(left: 2.0),
width: 14.0,
height: 14.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
(settingsProvider.customBackgroundColor ??
SettingsProvider.defaultSettings()
.customBackgroundColor),
boxShadow: [
BoxShadow(
color: AppColors.of(context)
.text
.withOpacity(0.15),
offset: const Offset(1, 2),
blurRadius: 3,
),
],
),
),
Transform.translate(
offset: const Offset(-4.0, 0.0),
child: Container(
margin: const EdgeInsets.only(left: 2.0),
width: 14.0,
height: 14.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: (settingsProvider
.customHighlightColor ??
SettingsProvider.defaultSettings()
.customHighlightColor),
boxShadow: [
BoxShadow(
color: AppColors.of(context)
.text
.withOpacity(0.15),
offset: const Offset(1, 2),
blurRadius: 3,
),
],
),
),
),
Transform.translate(
offset: const Offset(-8.0, 0.0),
child: Container(
margin: const EdgeInsets.only(left: 2.0),
width: 14.0,
height: 14.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: settingsProvider.customAccentColor ??
accentColorMap[
settingsProvider.accentColor],
boxShadow: [
BoxShadow(
color: AppColors.of(context)
.text
.withOpacity(0.15),
offset: const Offset(1, 2),
blurRadius: 3,
),
],
),
),
),
],
),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
bottom: Radius.circular(12),
),
),
],
),
const SizedBox(
height: 18.0,
),
// own paints
SplittedPanel(
title: Text('public_paint'.i18n),
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: tiles,
),
],
),
),
),
),
),
);
}
// enter id dialog
void showEnterIDDialog() {
_paintId.text = '';
showDialog(
context: context,
builder: (context) => StatefulBuilder(builder: (context, setS) {
return AlertDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(14.0))),
title: Text("enter_id".i18n),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: _paintId,
onEditingComplete: () async {
// SharedTheme? theme = await shareProvider.getThemeById(
// context,
// id: _paintId.text.replaceAll(' ', ''),
// );
// if (theme != null) {
// // set theme variable
// newThemeByID = theme;
// _paintId.clear();
// } else {
// ScaffoldMessenger.of(context).showSnackBar(
// CustomSnackBar(
// content: Text("theme_not_found".i18n,
// style: const TextStyle(color: Colors.white)),
// backgroundColor: AppColors.of(context).red,
// context: context,
// ),
// );
// }
},
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
focusedBorder: OutlineInputBorder(
borderSide:
const BorderSide(color: Colors.grey, width: 1.5),
borderRadius: BorderRadius.circular(12.0),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
hintText: 'paint_id'.i18n,
suffixIcon: IconButton(
icon: const Icon(
FeatherIcons.x,
color: Colors.grey,
),
onPressed: () {
setState(() {
_paintId.text = '';
});
},
),
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Icon(FeatherIcons.arrowDown, size: 32),
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius:
const BorderRadius.all(Radius.circular(12.0))),
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Center(
child: Text(
'set_as_current'.i18n,
style: const TextStyle(
fontWeight: FontWeight.w500, fontSize: 16.0),
),
),
),
],
),
actions: [
TextButton(
child: Text(
"cancel".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () {
Navigator.of(context).maybePop();
},
),
TextButton(
child: Text(
"done".i18n,
style: const TextStyle(fontWeight: FontWeight.w500),
),
onPressed: () async {
// get sex
SharedTheme? theme = await shareProvider.getThemeById(
context,
id: _paintId.text.replaceAll(' ', ''),
);
if (theme != null) {
// set theme variable
newThemeByID = theme;
_paintId.clear();
} else {
ScaffoldMessenger.of(context).showSnackBar(
CustomSnackBar(
content: Text("theme_not_found".i18n,
style: const TextStyle(color: Colors.white)),
backgroundColor: AppColors.of(context).red,
context: context,
),
);
}
// slay
setPaint();
setState(() {});
Navigator.of(context).pop();
},
),
],
);
}),
).then((val) {
_paintId.clear();
});
}
void setPaint() async {
if (newThemeByID == null) return;
// changing grade colors
List<Color> colors = [
newThemeByID!.gradeColors.oneColor,
newThemeByID!.gradeColors.twoColor,
newThemeByID!.gradeColors.threeColor,
newThemeByID!.gradeColors.fourColor,
newThemeByID!.gradeColors.fiveColor,
];
settingsProvider.update(gradeColors: colors, store: true);
// changing shadow effect
settingsProvider.update(
shadowEffect: newThemeByID!.shadowEffect, store: true);
// changing theme mode
settingsProvider.update(theme: newThemeByID!.themeMode, store: true);
// changing theme
settingsProvider.update(
customBackgroundColor: newThemeByID!.backgroundColor,
customHighlightColor: newThemeByID!.panelsColor,
customAccentColor: newThemeByID!.accentColor,
customIconColor: newThemeByID!.iconColor,
// new things
currentThemeId: newThemeByID!.id,
currentThemeDisplayName: newThemeByID!.displayName,
currentThemeCreator: newThemeByID!.nickname,
// we should store it
store: true,
);
// changing font family
settingsProvider.update(fontFamily: newThemeByID!.fontFamily, store: true);
// seems weird but it works, trust me (idk why)
// await settingsProvider.update(theme: settingsProvider.theme, store: true);
Provider.of<ThemeModeObserver>(context, listen: false)
.changeTheme(settingsProvider.theme, updateNavbarColor: true);
}
}

View File

@@ -0,0 +1,834 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/helpers/subject.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/utils/format.dart';
import 'package:refilc_kreta_api/models/grade.dart';
import 'package:refilc_kreta_api/providers/absence_provider.dart';
import 'package:refilc_kreta_api/providers/grade_provider.dart';
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_helper.dart';
import 'package:refilc_mobile_ui/screens/settings/submenu/edit_subject.dart';
import 'package:refilc_mobile_ui/screens/settings/submenu/paint_list.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_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({
super.key,
this.borderRadius = const BorderRadius.vertical(
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
});
final BorderRadius borderRadius;
@override
Widget build(BuildContext context) {
return PanelButton(
onPressed: () => Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) => const PersonalizeSettingsScreen()),
),
title: Text("personalization".i18n),
leading: Icon(
Icons.palette_outlined,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: borderRadius,
);
}
}
class PersonalizeSettingsScreen extends StatefulWidget {
const PersonalizeSettingsScreen({super.key});
@override
PersonalizeSettingsScreenState createState() =>
PersonalizeSettingsScreenState();
}
class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
with SingleTickerProviderStateMixin {
late SettingsProvider settingsProvider;
late UserProvider user;
late AnimationController _hideContainersController;
late List<Grade> editedShit;
late List<Grade> otherShit;
late List<Widget> tiles;
// late List<Widget> fontTiles;
@override
void initState() {
super.initState();
// editedShit = Provider.of<GradeProvider>(context, listen: false)
// .grades
// .where((e) => e.teacher.isRenamed || e.subject.isRenamed)
// // .map((e) => e.subject)
// .toSet()
// .toList()
// ..sort((a, b) => a.subject.name.compareTo(b.subject.name));
List<Grade> other = Provider.of<GradeProvider>(context, listen: false)
.grades
.where((e) => !e.teacher.isRenamed && !e.subject.isRenamed)
.toSet()
.toList()
..sort((a, b) => a.subject.name.compareTo(b.subject.name));
otherShit = [];
var addedOthers = [];
for (var e in other) {
if (addedOthers.contains(e.subject.id)) continue;
addedOthers.add(e.subject.id);
otherShit.add(e);
}
otherShit = otherShit
..sort((a, b) =>
a.subject.name.compareTo(b.subject.name)); // just cuz why not
// editedTeachers = Provider.of<GradeProvider>(context, listen: false)
// .grades
// .where((e) => e.teacher.isRenamed || e.subject.isRenamed)
// .map((e) => e.teacher)
// .toSet()
// .toList();
// // ..sort((a, b) => a.name.compareTo(b.name));
// otherTeachers = Provider.of<GradeProvider>(context, listen: false)
// .grades
// .where((e) => !e.teacher.isRenamed && !e.subject.isRenamed)
// .map((e) => e.teacher)
// .toSet()
// .toList();
// ..sort((a, b) => a.name.compareTo(b.name));
_hideContainersController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 200));
}
void buildSubjectTiles() {
List<Widget> subjectTiles = [];
var added = [];
var i = 0;
List<Grade> need = [];
for (var s in editedShit) {
if (added.contains(s.subject.id)) continue;
need.add(s);
added.add(s.subject.id);
}
for (var s in need) {
Widget widget = PanelButton(
onPressed: () async {
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) => EditSubjectScreen(
subject: s.subject,
teacher: s.teacher, // not sure why, but it works tho
),
),
);
setState(() {});
},
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(s.subject.isRenamed && settingsProvider.renamedSubjectsEnabled
? s.subject.renamedTo
: s.subject.name.capital()) ??
'',
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
fontStyle: settingsProvider.renamedSubjectsItalics
? FontStyle.italic
: FontStyle.normal,
),
),
Text(
(s.teacher.isRenamed && settingsProvider.renamedTeachersEnabled
? s.teacher.renamedTo
: s.teacher.name.capital()) ??
'',
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.85),
fontWeight: FontWeight.w400,
fontSize: 15.0,
height: 1.2,
),
),
],
),
leading: Icon(
SubjectIcon.resolveVariant(context: context, subject: s.subject),
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
borderRadius: BorderRadius.vertical(
top: Radius.circular(i == 0 ? 12.0 : 4.0),
bottom: Radius.circular(i + 1 == need.length ? 12.0 : 4.0),
),
);
i += 1;
subjectTiles.add(widget);
}
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);
user = Provider.of<UserProvider>(context);
// get edited shit
editedShit = Provider.of<GradeProvider>(context, listen: false)
.grades
.where((e) => e.teacher.isRenamed || e.subject.isRenamed)
// .map((e) => e.subject)
.toSet()
.toList()
..sort((a, b) => a.subject.name.compareTo(b.subject.name));
String themeModeText = {
ThemeMode.light: "light".i18n,
ThemeMode.dark: "dark".i18n,
ThemeMode.system: "system".i18n
}[settingsProvider.theme] ??
"?";
// build da tilés
buildSubjectTiles();
// buildFontTiles();
return AnimatedBuilder(
animation: _hideContainersController,
builder: (context, child) => Opacity(
opacity: 1 - _hideContainersController.value,
child: Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
title: Text(
"personalization".i18n,
style: TextStyle(color: AppColors.of(context).text),
),
),
body: SingleChildScrollView(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
child: Column(
children: [
// app theme
SplittedPanel(
padding: const EdgeInsets.only(top: 8.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.theme(context);
setState(() {});
},
title: Text("theme".i18n),
leading: Icon(
FeatherIcons.sun,
size: 22.0,
color: AppColors.of(context).text.withOpacity(0.95),
),
trailing: Text(
themeModeText,
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// color magic shit
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: false,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 14.0),
onPressed: () async {
await _hideContainersController.forward();
SettingsHelper.accentColor(context);
setState(() {});
_hideContainersController.reset();
},
title: Text(
"color".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.droplet,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Container(
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary,
shape: BoxShape.circle,
),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(4.0),
),
),
const MenuPaintList(
borderRadius: BorderRadius.vertical(
top: Radius.circular(4.0),
bottom: Radius.circular(12.0),
),
),
],
),
// shadow toggle
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
shadowEffect: !settingsProvider.shadowEffect);
setState(() {});
},
title: Text(
"shadow_effect".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.shadowEffect ? .95 : .25),
),
),
leading: Icon(
FeatherIcons.moon,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.shadowEffect ? .95 : .25),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(shadowEffect: v);
setState(() {});
},
value: settingsProvider.shadowEffect,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// change subject icons
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.iconPack(context);
},
title: Text(
"icon_pack".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.grid,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Text(
settingsProvider.iconPack.name.capital(),
style: const TextStyle(fontSize: 14.0),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// grade colors
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
SettingsHelper.gradeColors(context);
setState(() {});
},
title: Text(
"grade_colors".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.star,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: List.generate(
5,
(i) => Container(
margin: const EdgeInsets.only(left: 2.0),
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: settingsProvider.gradeColors[i],
),
),
),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// rename things
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: false,
children: [
// rename subjects
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
renamedSubjectsEnabled:
!settingsProvider.renamedSubjectsEnabled);
await Provider.of<GradeProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<TimetableProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<AbsenceProvider>(context,
listen: false)
.convertBySettings();
setState(() {});
},
title: Text(
"rename_subjects".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.renamedSubjectsEnabled
? .95
: .25),
),
),
leading: Icon(
Icons.school_outlined,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.renamedSubjectsEnabled
? .95
: .25),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(renamedSubjectsEnabled: v);
await Provider.of<GradeProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<TimetableProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<AbsenceProvider>(context,
listen: false)
.convertBySettings();
setState(() {});
},
value: settingsProvider.renamedSubjectsEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(4.0),
),
),
// rename teachers
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
renamedTeachersEnabled:
!settingsProvider.renamedTeachersEnabled);
await Provider.of<GradeProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<TimetableProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<AbsenceProvider>(context,
listen: false)
.convertBySettings();
setState(() {});
},
title: Text(
"rename_teachers".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.renamedTeachersEnabled
? .95
: .25),
),
),
leading: Icon(
FeatherIcons.user,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.renamedTeachersEnabled
? .95
: .25),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(renamedTeachersEnabled: v);
await Provider.of<GradeProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<TimetableProvider>(context,
listen: false)
.convertBySettings();
await Provider.of<AbsenceProvider>(context,
listen: false)
.convertBySettings();
setState(() {});
},
value: settingsProvider.renamedTeachersEnabled,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(4.0),
bottom: Radius.circular(12.0),
),
),
],
),
// live activity color
if (Platform.isIOS)
SplittedPanel(
padding: const EdgeInsets.only(top: 9.0),
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
children: [
PanelButton(
onPressed: () {
if (!Provider.of<PremiumProvider>(context,
listen: false)
.hasScope(PremiumScopes.liveActivityColor)) {
PremiumLockedFeatureUpsell.show(
context: context,
feature: PremiumFeature.liveActivity,
);
return;
}
SettingsHelper.liveActivityColor(context);
setState(() {});
},
title: Text(
"live_activity_color".i18n,
style: TextStyle(
color:
AppColors.of(context).text.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.activity,
size: 22.0,
color: AppColors.of(context).text.withOpacity(.95),
),
trailing: Container(
margin: const EdgeInsets.only(left: 2.0),
width: 12.0,
height: 12.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: settingsProvider.liveActivityColor,
),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
// SplittedPanel(
// padding: const EdgeInsets.only(top: 9.0),
// cardPadding: const EdgeInsets.all(4.0),
// isSeparated: true,
// children: [],
// ),
if (settingsProvider.renamedSubjectsEnabled ||
settingsProvider.renamedTeachersEnabled)
Column(
children: [
const SizedBox(
height: 18.0,
),
SplittedPanel(
title: Text('subjects'.i18n),
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: tiles,
),
const SizedBox(
height: 9.0,
),
SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(3.0),
hasBorder: true,
isTransparent: true,
children: [
DropdownButton2(
items: otherShit
.map((item) => DropdownMenuItem<String>(
value: item.subject.id,
child: Text(
item.subject.name,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
overflow: TextOverflow.ellipsis,
),
))
.toList(),
onChanged: (String? v) async {
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) => EditSubjectScreen(
subject: otherShit
.firstWhere((e) => e.subject.id == v)
.subject,
teacher: otherShit
.firstWhere((e) => e.subject.id == v)
.teacher,
),
),
);
setState(() {});
// _subjectName.text = "";
},
iconSize: 14,
iconEnabledColor: AppColors.of(context).text,
iconDisabledColor: AppColors.of(context).text,
underline: const SizedBox(),
itemHeight: 40,
itemPadding:
const EdgeInsets.only(left: 14, right: 14),
buttonWidth: 50,
dropdownWidth: 300,
dropdownPadding: null,
buttonDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
),
dropdownElevation: 8,
scrollbarRadius: const Radius.circular(40),
scrollbarThickness: 6,
scrollbarAlwaysShow: true,
offset: const Offset(-10, -10),
buttonSplashColor: Colors.transparent,
customButton: PanelButton(
title: Text(
"select_subject".i18n,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.95),
),
),
leading: Icon(
FeatherIcons.plus,
size: 22.0,
color: AppColors.of(context)
.text
.withOpacity(.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
),
],
),
],
),
// 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.type,
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),
),
),
],
),
],
),
),
),
),
),
);
}
}

View File

@@ -0,0 +1,57 @@
import 'package:i18n_extension/i18n_extension.dart';
extension SettingsLocalization on String {
static final _t = Translations.byLocale("hu_hu") +
{
"en_en": {
"general": "General",
"personalization": "Personalization",
"extras": "Extras",
"surprise_grades": "Surprise Grades",
"cancel": "Cancel",
"done": "Done",
"rarity_title": "Rarity Text",
// default rarities
"common": "Common",
"uncommon": "Uncommon",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
},
"hu_hu": {
"general": "Általános",
"personalization": "Személyre szabás",
"extras": "Extrák",
"surprise_grades": "Meglepetés jegyek",
"cancel": "Mégse",
"done": "Kész",
"rarity_title": "Ritkaság szövege",
// default rarities
"common": "Gyakori",
"uncommon": "Nem gyakori",
"rare": "Ritka",
"epic": "Epikus",
"legendary": "Legendás",
},
"de_de": {
"general": "Allgemeine",
"personalization": "Personalisierung",
"extras": "Extras",
"surprise_grades": "Überraschende Noten",
"cancel": "Abbrechen",
"done": "Bereit",
"rarity_title": "Text zur Seltenheit",
// default rarities
"common": "Gemeinsam",
"uncommon": "Gelegentlich",
"rare": "Selten",
"epic": "Episch",
"legendary": "Legendär",
},
};
String get i18n => localize(this, _t);
String fill(List<Object> params) => localizeFill(this, params);
String plural(int value) => localizePlural(value, this, _t);
String version(Object modifier) => localizeVersion(modifier, this, _t);
}