changed everything from filcnaplo to refilc finally
This commit is contained in:
17
refilc_desktop_ui/lib/screens/login/login_route.dart
Normal file
17
refilc_desktop_ui/lib/screens/login/login_route.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Route loginRoute(Widget widget) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => widget,
|
||||
transitionDuration: const Duration(milliseconds: 650),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Colors.transparent,
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
358
refilc_desktop_ui/lib/screens/login/login_screen.dart
Normal file
358
refilc_desktop_ui/lib/screens/login/login_screen.dart
Normal file
@@ -0,0 +1,358 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:elegant_notification/elegant_notification.dart';
|
||||
import 'package:elegant_notification/resources/arrays.dart';
|
||||
import 'package:refilc/api/client.dart';
|
||||
import 'package:refilc/api/login.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/login_button.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
|
||||
import 'package:refilc_desktop_ui/screens/login/school_input/school_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||
import 'login_screen.i18n.dart';
|
||||
|
||||
const LinearGradient _backgroundGradient = LinearGradient(
|
||||
colors: [
|
||||
Color.fromARGB(255, 61, 122, 244),
|
||||
Color.fromARGB(255, 23, 77, 185),
|
||||
Color.fromARGB(255, 7, 42, 112),
|
||||
],
|
||||
begin: Alignment(-0.8, -2.0),
|
||||
end: Alignment(0.8, 1.0),
|
||||
stops: [-1.0, 0.0, 1.0],
|
||||
);
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key, this.back = false}) : super(key: key);
|
||||
|
||||
final bool back;
|
||||
|
||||
@override
|
||||
_LoginScreenState createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final usernameController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
final schoolController = SchoolInputController();
|
||||
final _scrollController = ScrollController();
|
||||
|
||||
LoginState _loginState = LoginState.normal;
|
||||
bool showBack = false;
|
||||
double topInset = 12.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
showBack = widget.back;
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarColor: Colors.white,
|
||||
systemNavigationBarIconBrightness: Brightness.dark,
|
||||
));
|
||||
|
||||
FilcAPI.getSchools().then((schools) {
|
||||
if (schools != null) {
|
||||
schoolController.update(() {
|
||||
schoolController.schools = schools;
|
||||
});
|
||||
} else {
|
||||
ElegantNotification.error(
|
||||
background: Colors.white,
|
||||
description: Text(
|
||||
"schools_error".i18n,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
onActionPressed: () {},
|
||||
onCloseButtonPressed: () {},
|
||||
onDismiss: () {},
|
||||
onProgressFinished: () {},
|
||||
displayCloseButton: false,
|
||||
showProgressIndicator: false,
|
||||
autoDismiss: true,
|
||||
animation: AnimationType.fromTop,
|
||||
).show(context);
|
||||
}
|
||||
});
|
||||
|
||||
if (Platform.isMacOS) {
|
||||
Window.getTitlebarHeight()
|
||||
.then((value) => setState(() => topInset = value));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: _backgroundGradient,
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// App logo
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: ClipRect(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12.0, right: 12.0, bottom: 32.0),
|
||||
child: SizedBox(
|
||||
width: 100.0,
|
||||
height: 100.0,
|
||||
// Png shadow *hack*
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Opacity(
|
||||
child: Image.asset(
|
||||
"assets/icons/ic_splash.png",
|
||||
color: Colors.black),
|
||||
opacity: 0.3),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(
|
||||
sigmaX: 6.0, sigmaY: 6.0),
|
||||
child: Image.asset(
|
||||
"assets/icons/ic_splash.png"),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Inputs
|
||||
SizedBox(
|
||||
width: 400.0,
|
||||
child: AutofillGroup(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Username
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"username".i18n,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"usernameHint".i18n,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: LoginInput(
|
||||
style: LoginInputStyle.username,
|
||||
controller: usernameController,
|
||||
),
|
||||
),
|
||||
|
||||
// Password
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"password".i18n,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"passwordHint".i18n,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: LoginInput(
|
||||
style: LoginInputStyle.password,
|
||||
controller: passwordController,
|
||||
),
|
||||
),
|
||||
|
||||
// School
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Text(
|
||||
"school".i18n,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
SchoolInput(
|
||||
scroll: _scrollController,
|
||||
controller: schoolController,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Log in button
|
||||
SizedBox(
|
||||
width: 400.0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 42.0),
|
||||
child: Visibility(
|
||||
child: LoginButton(
|
||||
child: Text("login".i18n,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15.0,
|
||||
)),
|
||||
onPressed: () => _loginAPI(context: context),
|
||||
),
|
||||
visible: _loginState != LoginState.inProgress,
|
||||
replacement: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_loginState == LoginState.missingFields ||
|
||||
_loginState == LoginState.invalidGrant ||
|
||||
_loginState == LoginState.failed)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
[
|
||||
"missing_fields",
|
||||
"invalid_grant",
|
||||
"error"
|
||||
][_loginState.index]
|
||||
.i18n,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showBack)
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
padding: EdgeInsets.only(left: 16.0, top: topInset),
|
||||
child: const ClipOval(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: BackButton(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _loginAPI({required BuildContext context}) {
|
||||
String username = usernameController.text;
|
||||
String password = passwordController.text;
|
||||
|
||||
if (username == "" ||
|
||||
password == "" ||
|
||||
schoolController.selectedSchool == null) {
|
||||
return setState(() => _loginState = LoginState.missingFields);
|
||||
}
|
||||
|
||||
setState(() => _loginState = LoginState.inProgress);
|
||||
|
||||
loginAPI(
|
||||
username: username,
|
||||
password: password,
|
||||
instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||
context: context,
|
||||
onLogin: (user) {
|
||||
ElegantNotification.success(
|
||||
background: Colors.white,
|
||||
description: Text(
|
||||
"welcome".i18n.fill([user.name]),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
onActionPressed: () {},
|
||||
onCloseButtonPressed: () {},
|
||||
onDismiss: () {},
|
||||
onProgressFinished: () {},
|
||||
displayCloseButton: false,
|
||||
showProgressIndicator: false,
|
||||
autoDismiss: true,
|
||||
animation: AnimationType.fromTop,
|
||||
).show(context);
|
||||
},
|
||||
onSuccess: () {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil("login_to_navigation", (_) => false);
|
||||
}).then((res) => setState(() => _loginState = res));
|
||||
}
|
||||
}
|
||||
51
refilc_desktop_ui/lib/screens/login/login_screen.i18n.dart
Normal file
51
refilc_desktop_ui/lib/screens/login/login_screen.i18n.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"username": "Username",
|
||||
"usernameHint": "Student ID number",
|
||||
"password": "Password",
|
||||
"passwordHint": "Date of birth",
|
||||
"school": "School",
|
||||
"login": "Log in",
|
||||
"welcome": "Welcome, %s!",
|
||||
"missing_fields": "Missing Fields!",
|
||||
"invalid_grant": "Invalid Username/Password!",
|
||||
"error": "Failed to log in.",
|
||||
"schools_error": "Failed to get schools."
|
||||
},
|
||||
"hu_hu": {
|
||||
"username": "Felhasználónév",
|
||||
"usernameHint": "Oktatási azonosító",
|
||||
"password": "Jelszó",
|
||||
"passwordHint": "Születési dátum",
|
||||
"school": "Iskola",
|
||||
"login": "Belépés",
|
||||
"welcome": "Üdv, %s!",
|
||||
"missing_fields": "Hiányzó adatok!",
|
||||
"invalid_grant": "Helytelen Felhasználónév/Jelszó!",
|
||||
"error": "Sikertelen bejelentkezés.",
|
||||
"schools_error": "Nem sikerült lekérni az iskolákat."
|
||||
},
|
||||
"de_de": {
|
||||
"username": "Benutzername",
|
||||
"usernameHint": "Ausbildung ID",
|
||||
"password": "Passwort",
|
||||
"passwordHint": "Geburtsdatum",
|
||||
"school": "Schule",
|
||||
"login": "Einloggen",
|
||||
"welcome": "Wilkommen, %s!",
|
||||
"missing_fields": "Fehlende Felder!",
|
||||
"invalid_grant": "Ungültiger Benutzername/Passwort!",
|
||||
"error": "Anmeldung fehlgeschlagen.",
|
||||
"schools_error": "Keine Schulen gefunden."
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/school_input/school_input_overlay.dart';
|
||||
import 'package:refilc_desktop_ui/screens/login/school_input/school_input_tile.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/school_input/school_search.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc_kreta_api/models/school.dart';
|
||||
|
||||
class SchoolInput extends StatefulWidget {
|
||||
const SchoolInput({Key? key, required this.controller, required this.scroll})
|
||||
: super(key: key);
|
||||
|
||||
final SchoolInputController controller;
|
||||
final ScrollController scroll;
|
||||
|
||||
@override
|
||||
_SchoolInputState createState() => _SchoolInputState();
|
||||
}
|
||||
|
||||
class _SchoolInputState extends State<SchoolInput> {
|
||||
final _focusNode = FocusNode();
|
||||
final _layerLink = LayerLink();
|
||||
late SchoolInputOverlay overlay;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
widget.controller.update = (fn) {
|
||||
if (mounted) setState(fn);
|
||||
};
|
||||
|
||||
overlay = SchoolInputOverlay(layerLink: _layerLink);
|
||||
|
||||
// Show school list when focused
|
||||
_focusNode.addListener(() {
|
||||
if (_focusNode.hasFocus) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => overlay.createOverlayEntry(context));
|
||||
Future.delayed(const Duration(milliseconds: 100)).then((value) {
|
||||
if (mounted && widget.scroll.hasClients) {
|
||||
widget.scroll.animateTo(widget.scroll.offset + 500,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.ease);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
overlay.entry?.remove();
|
||||
}
|
||||
});
|
||||
|
||||
// LoginInput TextField listener
|
||||
widget.controller.textController.addListener(() {
|
||||
String text = widget.controller.textController.text;
|
||||
if (text.isEmpty) {
|
||||
overlay.children = null;
|
||||
return;
|
||||
}
|
||||
|
||||
List<School> results =
|
||||
searchSchools(widget.controller.schools ?? [], text);
|
||||
setState(() {
|
||||
overlay.children = results
|
||||
.map((School e) => SchoolInputTile(
|
||||
school: e,
|
||||
onTap: () => _selectSchool(e),
|
||||
))
|
||||
.toList();
|
||||
});
|
||||
Overlay.of(context).setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _selectSchool(School school) {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
|
||||
setState(() {
|
||||
widget.controller.selectedSchool = school;
|
||||
widget.controller.textController.text = school.name;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CompositedTransformTarget(
|
||||
link: _layerLink,
|
||||
child: widget.controller.schools == null
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
child: const Center(
|
||||
child: SizedBox(
|
||||
height: 28.0,
|
||||
width: 28.0,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: LoginInput(
|
||||
style: LoginInputStyle.school,
|
||||
focusNode: _focusNode,
|
||||
onClear: () {
|
||||
widget.controller.selectedSchool = null;
|
||||
FocusScope.of(context).requestFocus(_focusNode);
|
||||
},
|
||||
controller: widget.controller.textController,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SchoolInputController {
|
||||
final textController = TextEditingController();
|
||||
School? selectedSchool;
|
||||
List<School>? schools;
|
||||
late void Function(void Function()) update;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:refilc_kreta_api/models/school.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SchoolInputTile extends StatelessWidget {
|
||||
const SchoolInputTile({Key? key, required this.school, this.onTap})
|
||||
: super(key: key);
|
||||
|
||||
final School school;
|
||||
final Function()? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: GestureDetector(
|
||||
onPanDown: (e) {
|
||||
onTap!();
|
||||
},
|
||||
child: InkWell(
|
||||
onTapDown: (e) {},
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// School name
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
school.name,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// School id
|
||||
Expanded(
|
||||
child: Text(
|
||||
school.instituteCode,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// School city
|
||||
Expanded(
|
||||
child: Text(
|
||||
school.city,
|
||||
textAlign: TextAlign.right,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
class NavigationRoute {
|
||||
late String _name;
|
||||
late int _index;
|
||||
|
||||
final List<String> _internalPageMap = [
|
||||
"home",
|
||||
"grades",
|
||||
"timetable",
|
||||
"messages",
|
||||
"absences",
|
||||
];
|
||||
|
||||
String get name => _name;
|
||||
int get index => _index;
|
||||
|
||||
set name(String n) {
|
||||
_name = n;
|
||||
_index = _internalPageMap.indexOf(n);
|
||||
}
|
||||
|
||||
set index(int i) {
|
||||
_index = i;
|
||||
_name = _internalPageMap.elementAt(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc_desktop_ui/pages/absences/absences_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grades_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/home/home_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/messages/messages_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/timetable/timetable_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Route navigationRouteHandler(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case "grades":
|
||||
return navigationPageRoute((context) => const GradesPage());
|
||||
case "timetable":
|
||||
return navigationPageRoute((context) => const TimetablePage());
|
||||
case "messages":
|
||||
return navigationPageRoute((context) => const MessagesPage());
|
||||
case "absences":
|
||||
return navigationPageRoute((context) => const AbsencesPage());
|
||||
case "home":
|
||||
default:
|
||||
return navigationPageRoute((context) => const HomePage());
|
||||
}
|
||||
}
|
||||
|
||||
Route navigationPageRoute(Widget Function(BuildContext) builder) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, _, __) => builder(context),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
167
refilc_desktop_ui/lib/screens/navigation/navigation_screen.dart
Normal file
167
refilc_desktop_ui/lib/screens/navigation/navigation_screen.dart
Normal file
@@ -0,0 +1,167 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:refilc/api/providers/news_provider.dart';
|
||||
import 'package:refilc/api/providers/sync.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc/theme/observer.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/navigation_route.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/navigation_route_handler.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/sidebar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc_kreta_api/client/client.dart';
|
||||
import 'package:refilc_plus/providers/goal_provider.dart';
|
||||
|
||||
class NavigationScreen extends StatefulWidget {
|
||||
const NavigationScreen({Key? key}) : super(key: key);
|
||||
|
||||
static NavigationScreenState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<NavigationScreenState>();
|
||||
|
||||
@override
|
||||
State<NavigationScreen> createState() => NavigationScreenState();
|
||||
}
|
||||
|
||||
class NavigationScreenState extends State<NavigationScreen>
|
||||
with WidgetsBindingObserver {
|
||||
final _navigatorState = GlobalKey<NavigatorState>();
|
||||
late NavigationRoute selected;
|
||||
late SettingsProvider settings;
|
||||
late NewsProvider newsProvider;
|
||||
late GoalProvider goalProvider;
|
||||
double topInset = 0.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
selected = NavigationRoute();
|
||||
selected.index = 0;
|
||||
|
||||
// add brightness observer
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
// set client User-Agent
|
||||
Provider.of<KretaClient>(context, listen: false).userAgent =
|
||||
settings.config.userAgent;
|
||||
|
||||
// get news
|
||||
newsProvider = Provider.of<NewsProvider>(context, listen: false);
|
||||
newsProvider.restore().then((value) => newsProvider.fetch());
|
||||
|
||||
// get goals
|
||||
// goalProvider = Provider.of<GoalProvider>(context, listen: false);
|
||||
// goalProvider.fetchDone();
|
||||
|
||||
// Initial sync
|
||||
syncAll(context);
|
||||
|
||||
() async {
|
||||
try {
|
||||
await Window.initialize();
|
||||
} catch (_) {}
|
||||
// Transparent sidebar
|
||||
if (Platform.isLinux) return;
|
||||
|
||||
await Window.setEffect(
|
||||
effect: Platform.isLinux
|
||||
? WindowEffect.transparent
|
||||
: WindowEffect.acrylic,
|
||||
color: Platform.isMacOS
|
||||
? Colors.transparent
|
||||
: const Color.fromARGB(27, 27, 27, 27));
|
||||
|
||||
// todo: do for windows
|
||||
if (Platform.isMacOS) {
|
||||
topInset = await Window.getTitlebarHeight();
|
||||
await Window.enableFullSizeContentView();
|
||||
await Window.hideTitle();
|
||||
await Window.makeTitlebarTransparent();
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePlatformBrightness() {
|
||||
if (settings.theme == ThemeMode.system) {
|
||||
// ignore: deprecated_member_use
|
||||
Brightness? brightness =
|
||||
// ignore: deprecated_member_use
|
||||
WidgetsBinding.instance.window.platformBrightness;
|
||||
Provider.of<ThemeModeObserver>(context, listen: false).changeTheme(
|
||||
brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark);
|
||||
}
|
||||
super.didChangePlatformBrightness();
|
||||
}
|
||||
|
||||
void setPage(String page) => setState(() => selected.name = page);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
newsProvider = Provider.of<NewsProvider>(context);
|
||||
goalProvider = Provider.of<GoalProvider>(context);
|
||||
|
||||
// show news / complete goals
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (newsProvider.show) {
|
||||
newsProvider.lock();
|
||||
// NewsView.show(newsProvider.news[newsProvider.state], context: context).then((value) => newsProvider.release());
|
||||
}
|
||||
if (goalProvider.hasDoneGoals) {
|
||||
// to-do
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: Row(
|
||||
children: [
|
||||
if (_navigatorState.currentState != null)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(context).scaffoldBackgroundColor.withOpacity(.5),
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: AppColors.of(context).shadow.withOpacity(.7),
|
||||
width: 1.0)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: topInset),
|
||||
child: Sidebar(
|
||||
navigator: _navigatorState.currentState!,
|
||||
selected: selected.name,
|
||||
onRouteChange: (name) => setPage(name),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
padding: EdgeInsets.only(top: topInset),
|
||||
),
|
||||
child: Navigator(
|
||||
key: _navigatorState,
|
||||
initialRoute: selected.name,
|
||||
onGenerateRoute: (settings) =>
|
||||
navigationRouteHandler(settings),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
353
refilc_desktop_ui/lib/screens/navigation/sidebar.dart
Normal file
353
refilc_desktop_ui/lib/screens/navigation/sidebar.dart
Normal file
@@ -0,0 +1,353 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc/api/providers/database_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/icons/filc_icons.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/utils/color.dart';
|
||||
import 'package:refilc_desktop_ui/common/panel_button.dart';
|
||||
import 'package:refilc_desktop_ui/common/profile_image.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/sidebar.i18n.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/sidebar_action.dart';
|
||||
import 'package:refilc_desktop_ui/screens/settings/settings_screen.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/accounts/account_tile.dart';
|
||||
import 'package:refilc_kreta_api/client/client.dart';
|
||||
import 'package:refilc_kreta_api/providers/absence_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/event_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/exam_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/message_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/note_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/timetable_provider.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/theme/colors/colors.dart';
|
||||
|
||||
class Sidebar extends StatefulWidget {
|
||||
const Sidebar(
|
||||
{Key? key,
|
||||
required this.navigator,
|
||||
required this.onRouteChange,
|
||||
this.selected = "home"})
|
||||
: super(key: key);
|
||||
|
||||
final NavigatorState navigator;
|
||||
final String selected;
|
||||
final Function(String) onRouteChange;
|
||||
|
||||
@override
|
||||
State<Sidebar> createState() => _SidebarState();
|
||||
}
|
||||
|
||||
class _SidebarState extends State<Sidebar> {
|
||||
late UserProvider user;
|
||||
late SettingsProvider settings;
|
||||
late String firstName;
|
||||
|
||||
String topNav = "";
|
||||
bool expandAccount = false;
|
||||
List<Widget> accountTiles = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
user = Provider.of<UserProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
Future<void> restore() => Future.wait([
|
||||
Provider.of<GradeProvider>(context, listen: false).restore(),
|
||||
Provider.of<TimetableProvider>(context, listen: false).restoreUser(),
|
||||
Provider.of<ExamProvider>(context, listen: false).restore(),
|
||||
Provider.of<HomeworkProvider>(context, listen: false).restore(),
|
||||
Provider.of<MessageProvider>(context, listen: false).restore(),
|
||||
Provider.of<MessageProvider>(context, listen: false)
|
||||
.restoreRecipients(),
|
||||
Provider.of<NoteProvider>(context, listen: false).restore(),
|
||||
Provider.of<EventProvider>(context, listen: false).restore(),
|
||||
Provider.of<AbsenceProvider>(context, listen: false).restore(),
|
||||
Provider.of<KretaClient>(context, listen: false).refreshLogin(),
|
||||
]);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
|
||||
List<String> nameParts = user.name?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
} else {
|
||||
firstName = "János";
|
||||
}
|
||||
|
||||
List<Widget> pageWidgets = [
|
||||
SidebarAction(
|
||||
title: Text("Home".i18n),
|
||||
icon: const Icon(FilcIcons.home),
|
||||
selected: widget.selected == "home",
|
||||
onTap: () {
|
||||
if (widget.selected != "home") {
|
||||
widget.navigator.pushReplacementNamed("home");
|
||||
widget.onRouteChange("home");
|
||||
}
|
||||
},
|
||||
),
|
||||
SidebarAction(
|
||||
title: Text("Grades".i18n),
|
||||
icon: const Icon(FeatherIcons.bookmark),
|
||||
selected: widget.selected == "grades",
|
||||
onTap: () {
|
||||
if (widget.selected != "grades") {
|
||||
widget.navigator.pushReplacementNamed("grades");
|
||||
widget.onRouteChange("grades");
|
||||
}
|
||||
},
|
||||
),
|
||||
SidebarAction(
|
||||
title: Text("Timetable".i18n),
|
||||
icon: const Icon(FeatherIcons.calendar),
|
||||
selected: widget.selected == "timetable",
|
||||
onTap: () {
|
||||
if (widget.selected != "timetable") {
|
||||
widget.navigator.pushReplacementNamed("timetable");
|
||||
widget.onRouteChange("timetable");
|
||||
}
|
||||
},
|
||||
),
|
||||
SidebarAction(
|
||||
title: Text("Messages".i18n),
|
||||
icon: const Icon(FeatherIcons.messageSquare),
|
||||
selected: widget.selected == "messages",
|
||||
onTap: () {
|
||||
if (widget.selected != "messages") {
|
||||
widget.navigator.pushReplacementNamed("messages");
|
||||
widget.onRouteChange("messages");
|
||||
}
|
||||
},
|
||||
),
|
||||
SidebarAction(
|
||||
title: Text("Absences".i18n),
|
||||
icon: const Icon(FeatherIcons.clock),
|
||||
selected: widget.selected == "absences",
|
||||
onTap: () {
|
||||
if (widget.selected != "absences") {
|
||||
widget.navigator.pushReplacementNamed("absences");
|
||||
widget.onRouteChange("absences");
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
List<Widget> bottomActions = [
|
||||
SidebarAction(
|
||||
title: Text("Settings".i18n),
|
||||
selected: true,
|
||||
icon: const Icon(FeatherIcons.settings),
|
||||
onTap: () {
|
||||
if (topNav != "settings") {
|
||||
widget.navigator
|
||||
.push(CupertinoPageRoute(
|
||||
builder: (context) => const SettingsScreen()))
|
||||
.then((value) => topNav = "");
|
||||
topNav = "settings";
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
buildAccountTiles();
|
||||
|
||||
List<Widget> accountWidgets = [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Column(children: accountTiles),
|
||||
),
|
||||
|
||||
// Account settings
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("login_back");
|
||||
},
|
||||
title: Text("adduser".i18n),
|
||||
leading: const Icon(FeatherIcons.userPlus),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () async {
|
||||
String? userId = user.id;
|
||||
if (userId == null) return;
|
||||
|
||||
// revoke refresh token
|
||||
await Provider.of<KretaClient>(context, listen: false).logout();
|
||||
|
||||
// delete user from app
|
||||
user.removeUser(userId);
|
||||
await Provider.of<DatabaseProvider>(context, listen: false)
|
||||
.store
|
||||
.removeUser(userId);
|
||||
|
||||
// if no other users left, go back to login screen
|
||||
if (user.getUsers().isNotEmpty) {
|
||||
user.setUser(user.getUsers().first.id);
|
||||
restore().then((_) => user.setUser(user.getUsers().first.id));
|
||||
} else {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil("login", (_) => false);
|
||||
}
|
||||
},
|
||||
title: Text("logout".i18n),
|
||||
leading: Icon(FeatherIcons.logOut, color: AppColors.of(context).red),
|
||||
),
|
||||
];
|
||||
|
||||
return SizedBox(
|
||||
height: double.infinity,
|
||||
width: 250.0,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12.0,
|
||||
top: 18.0,
|
||||
bottom: 24.0,
|
||||
right: 12.0,
|
||||
),
|
||||
child: InkWell(
|
||||
customBorder: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
expandAccount = !expandAccount;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 12.0,
|
||||
left: 5.0,
|
||||
top: 5.0,
|
||||
bottom: 5.0,
|
||||
),
|
||||
child: ProfileImage(
|
||||
name: firstName,
|
||||
radius: 18.0,
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary, //!settings.presentationMode
|
||||
// ? ColorUtils.stringToColor(user.name ?? "?")
|
||||
// : Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
firstName,
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
PageTransitionSwitcher(
|
||||
transitionBuilder:
|
||||
(child, primaryAnimation, secondaryAnimation) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Colors.transparent,
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: IconButton(
|
||||
key: Key(expandAccount ? "accounts" : "pages"),
|
||||
icon: Icon(expandAccount
|
||||
? FeatherIcons.chevronDown
|
||||
: FeatherIcons.chevronRight),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
expandAccount = !expandAccount;
|
||||
});
|
||||
},
|
||||
splashColor: const Color(0x00000000),
|
||||
focusColor: const Color(0x00000000),
|
||||
hoverColor: const Color(0x00000000),
|
||||
highlightColor: const Color(0x00000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Pages
|
||||
Expanded(
|
||||
child: PageTransitionSwitcher(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
transitionBuilder: (child, primaryAnimation, secondaryAnimation) {
|
||||
return SharedAxisTransition(
|
||||
fillColor: Colors.transparent,
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
transitionType: SharedAxisTransitionType.scaled,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: !expandAccount
|
||||
? Column(
|
||||
key: const Key("pages"),
|
||||
children: pageWidgets,
|
||||
)
|
||||
: Column(
|
||||
key: const Key("accounts"),
|
||||
children: accountWidgets,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Settings
|
||||
...bottomActions,
|
||||
|
||||
// Bottom padding
|
||||
const SizedBox(height: 12.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void buildAccountTiles() {
|
||||
accountTiles = [];
|
||||
user.getUsers().forEach((account) {
|
||||
if (account.id == user.id) return;
|
||||
|
||||
String _firstName;
|
||||
|
||||
List<String> _nameParts = user.name?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
_firstName = _nameParts.length > 1 ? _nameParts[1] : _nameParts[0];
|
||||
} else {
|
||||
_firstName = "János";
|
||||
}
|
||||
|
||||
accountTiles.add(AccountTile(
|
||||
name: Text(!settings.presentationMode ? account.name : "János",
|
||||
style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
username:
|
||||
Text(!settings.presentationMode ? account.username : "72469696969"),
|
||||
profileImage: ProfileImage(
|
||||
name: _firstName,
|
||||
backgroundColor: !settings.presentationMode
|
||||
? ColorUtils.stringToColor(account.name)
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
role: account.role,
|
||||
),
|
||||
onTap: () {
|
||||
user.setUser(account.id);
|
||||
restore().then((_) => user.setUser(account.id));
|
||||
},
|
||||
// onTapMenu: () => _showBottomSheet(account),
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
42
refilc_desktop_ui/lib/screens/navigation/sidebar.i18n.dart
Normal file
42
refilc_desktop_ui/lib/screens/navigation/sidebar.i18n.dart
Normal 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": {
|
||||
"Home": "Home",
|
||||
"Grades": "Grades",
|
||||
"Timetable": "Timetable",
|
||||
"Messages": "Messages",
|
||||
"Absences": "Absences",
|
||||
"Settings": "Settings",
|
||||
"adduser": "Add User",
|
||||
"logout": "Log Out",
|
||||
},
|
||||
"hu_hu": {
|
||||
"Home": "Kezdőlap",
|
||||
"Grades": "Jegyek",
|
||||
"Timetable": "Órarend",
|
||||
"Messages": "Üzenetek",
|
||||
"Absences": "Hiányzások",
|
||||
"Settings": "Beállítások",
|
||||
"adduser": "Fiók hozzáadása",
|
||||
"logout": "Kilépés",
|
||||
},
|
||||
"de_de": {
|
||||
"Home": "Zuhause",
|
||||
"Grades": "Noten",
|
||||
"Timetable": "Zeitplan",
|
||||
"Messages": "Mitteilungen",
|
||||
"Absences": "Fehlen",
|
||||
"Settings": "Einstellungen",
|
||||
"adduser": "Benutzer hinzufügen",
|
||||
"logout": "Abmelden",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
55
refilc_desktop_ui/lib/screens/navigation/sidebar_action.dart
Normal file
55
refilc_desktop_ui/lib/screens/navigation/sidebar_action.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
|
||||
class SidebarAction extends StatelessWidget {
|
||||
const SidebarAction(
|
||||
{Key? key, this.title, this.icon, this.onTap, this.selected = false})
|
||||
: super(key: key);
|
||||
|
||||
final bool selected;
|
||||
final Widget? icon;
|
||||
final Widget? title;
|
||||
final Function()? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 12.0),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
if (icon != null)
|
||||
IconTheme(
|
||||
data: IconThemeData(
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(selected ? 1.0 : .3),
|
||||
),
|
||||
child: icon!,
|
||||
),
|
||||
if (title != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 24.0),
|
||||
child: AnimatedDefaultTextStyle(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(selected ? 1.0 : .8),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: "Montserrat",
|
||||
),
|
||||
child: title!,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
10
refilc_desktop_ui/lib/screens/news/news_view.dart
Normal file
10
refilc_desktop_ui/lib/screens/news/news_view.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NewsView extends StatelessWidget {
|
||||
const NewsView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
957
refilc_desktop_ui/lib/screens/settings/settings_screen.dart
Normal file
957
refilc_desktop_ui/lib/screens/settings/settings_screen.dart
Normal file
@@ -0,0 +1,957 @@
|
||||
import 'package:refilc/api/providers/update_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/absence_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/event_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/exam_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/message_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/note_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/utils/format.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/models/user.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_kreta_api/client/client.dart';
|
||||
import 'package:refilc_mobile_ui/common/action_button.dart';
|
||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/bottom_sheet_menu.dart';
|
||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/bottom_sheet_menu_item.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
|
||||
import 'package:refilc_mobile_ui/common/profile_image/profile_image.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/update/updates_view.dart';
|
||||
import 'package:refilc_mobile_ui/premium/premium_button.dart';
|
||||
import 'package:refilc_mobile_ui/screens/news/news_screen.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/accounts/account_tile.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/accounts/account_view.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/debug/subject_icon_gallery.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/settings_helper.dart';
|
||||
import 'package:refilc_plus/providers/premium_provider.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart' as tabs;
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'settings_screen.i18n.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/user/nickname.dart';
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SettingsScreenState createState() => _SettingsScreenState();
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
int devmodeCountdown = 3;
|
||||
final bool __ss = false; // secret settings
|
||||
|
||||
late UserProvider user;
|
||||
late UpdateProvider updateProvider;
|
||||
late SettingsProvider settings;
|
||||
late KretaClient kretaClient;
|
||||
late String firstName;
|
||||
List<Widget> accountTiles = [];
|
||||
|
||||
late AnimationController _hideContainersController;
|
||||
|
||||
Future<void> restore() => Future.wait([
|
||||
Provider.of<GradeProvider>(context, listen: false).restore(),
|
||||
Provider.of<TimetableProvider>(context, listen: false).restoreUser(),
|
||||
Provider.of<ExamProvider>(context, listen: false).restore(),
|
||||
Provider.of<HomeworkProvider>(context, listen: false).restore(),
|
||||
Provider.of<MessageProvider>(context, listen: false).restore(),
|
||||
Provider.of<MessageProvider>(context, listen: false)
|
||||
.restoreRecipients(),
|
||||
Provider.of<NoteProvider>(context, listen: false).restore(),
|
||||
Provider.of<EventProvider>(context, listen: false).restore(),
|
||||
Provider.of<AbsenceProvider>(context, listen: false).restore(),
|
||||
Provider.of<KretaClient>(context, listen: false).refreshLogin(),
|
||||
]);
|
||||
|
||||
void buildAccountTiles() {
|
||||
accountTiles = [];
|
||||
user.getUsers().forEach((account) {
|
||||
if (account.id == user.id) return;
|
||||
|
||||
String _firstName;
|
||||
|
||||
List<String> _nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
_firstName = _nameParts.length > 1 ? _nameParts[1] : _nameParts[0];
|
||||
} else {
|
||||
_firstName = "János";
|
||||
}
|
||||
|
||||
accountTiles.add(AccountTile(
|
||||
name: Text(!settings.presentationMode ? account.name : "János",
|
||||
style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
username:
|
||||
Text(!settings.presentationMode ? account.username : "72469696969"),
|
||||
profileImage: ProfileImage(
|
||||
name: _firstName,
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary, //!settings.presentationMode
|
||||
//? ColorUtils.stringToColor(account.name)
|
||||
//: Theme.of(context).colorScheme.secondary,
|
||||
role: account.role,
|
||||
),
|
||||
onTap: () {
|
||||
user.setUser(account.id);
|
||||
restore().then((_) => user.setUser(account.id));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onTapMenu: () => _showBottomSheet(account),
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
void _showBottomSheet(User u) {
|
||||
showBottomSheetMenu(context, items: [
|
||||
BottomSheetMenuItem(
|
||||
onPressed: () => AccountView.show(u, context: context),
|
||||
icon: const Icon(FeatherIcons.user),
|
||||
title: Text("personal_details".i18n),
|
||||
),
|
||||
BottomSheetMenuItem(
|
||||
onPressed: () => _openDKT(u),
|
||||
icon: Icon(FeatherIcons.grid, color: AppColors.of(context).teal),
|
||||
title: Text("open_dkt".i18n),
|
||||
),
|
||||
UserMenuNickname(u),
|
||||
// BottomSheetMenuItem(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(FeatherIcons.camera),
|
||||
// title: Text("edit_profile_picture".i18n),
|
||||
// ),
|
||||
// BottomSheetMenuItem(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(FeatherIcons.trash2, color: AppColors.of(context).red),
|
||||
// title: Text("remove_profile_picture".i18n),
|
||||
// ),
|
||||
]);
|
||||
}
|
||||
|
||||
void _openDKT(User u) => tabs.launch(
|
||||
"https://dkttanulo.e-kreta.hu/sso?id_token=${kretaClient.idToken}",
|
||||
customTabsOption: tabs.CustomTabsOption(
|
||||
toolbarColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
showPageTitle: true,
|
||||
));
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_hideContainersController = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 200));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
updateProvider = Provider.of<UpdateProvider>(context);
|
||||
kretaClient = Provider.of<KretaClient>(context);
|
||||
|
||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
} else {
|
||||
firstName = "János";
|
||||
}
|
||||
|
||||
String startPageTitle =
|
||||
SettingsHelper.localizedPageTitles()[settings.startPage] ?? "?";
|
||||
String themeModeText = {
|
||||
ThemeMode.light: "light".i18n,
|
||||
ThemeMode.dark: "dark".i18n,
|
||||
ThemeMode.system: "system".i18n
|
||||
}[settings.theme] ??
|
||||
"?";
|
||||
String languageText = SettingsHelper.langMap[settings.language] ?? "?";
|
||||
String vibrateTitle = {
|
||||
VibrationStrength.off: "voff".i18n,
|
||||
VibrationStrength.light: "vlight".i18n,
|
||||
VibrationStrength.medium: "vmedium".i18n,
|
||||
VibrationStrength.strong: "vstrong".i18n,
|
||||
}[settings.vibrate] ??
|
||||
"?";
|
||||
|
||||
buildAccountTiles();
|
||||
|
||||
if (settings.developerMode) devmodeCountdown = -1;
|
||||
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 11.5),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
floating: true,
|
||||
snap: false,
|
||||
centerTitle: false,
|
||||
title: const Text("Settings"),
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: AnimatedBuilder(
|
||||
animation: _hideContainersController,
|
||||
builder: (context, child) => Opacity(
|
||||
opacity: 1 - _hideContainersController.value,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
StaggeredGrid.extent(
|
||||
// direction: Axis.horizontal,
|
||||
// crossAxisCount: 3,
|
||||
maxCrossAxisExtent: 600,
|
||||
children: [
|
||||
const SizedBox(height: 32.0),
|
||||
|
||||
// Updates
|
||||
if (updateProvider.available)
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
child: PanelButton(
|
||||
onPressed: () => _openUpdates(context),
|
||||
title: Text("update_available".i18n),
|
||||
leading: const Icon(FeatherIcons.download),
|
||||
trailing: Text(
|
||||
updateProvider.releases.first.tag,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
|
||||
// child: PremiumBannerButton(),
|
||||
// ),
|
||||
if (!Provider.of<PremiumProvider>(context).hasPremium)
|
||||
const ClipRect(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: PremiumButton(),
|
||||
),
|
||||
),
|
||||
|
||||
// General Settings
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("general".i18n),
|
||||
child: Column(
|
||||
children: [
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.language(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("language".i18n),
|
||||
leading: const Icon(FeatherIcons.globe),
|
||||
trailing: Text(languageText),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.startPage(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("startpage".i18n),
|
||||
leading: const Icon(FeatherIcons.play),
|
||||
trailing: Text(startPageTitle.capital()),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.rounding(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("rounding".i18n),
|
||||
leading:
|
||||
const Icon(FeatherIcons.gitCommit),
|
||||
trailing: Text((settings.rounding / 10)
|
||||
.toStringAsFixed(1)),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.vibrate(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("vibrate".i18n),
|
||||
leading: const Icon(FeatherIcons.radio),
|
||||
trailing: Text(vibrateTitle),
|
||||
),
|
||||
PanelButton(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 14.0),
|
||||
onPressed: () {
|
||||
SettingsHelper.bellDelay(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text(
|
||||
"bell_delay".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.bellDelayEnabled
|
||||
? 1.0
|
||||
: .5)),
|
||||
),
|
||||
leading: settings.bellDelayEnabled
|
||||
? const Icon(FeatherIcons.bell)
|
||||
: Icon(FeatherIcons.bellOff,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.25)),
|
||||
trailingDivider: true,
|
||||
trailing: Switch(
|
||||
onChanged: (v) => settings.update(
|
||||
bellDelayEnabled: v),
|
||||
value: settings.bellDelayEnabled,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (kDebugMode)
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: const Text("Debug"),
|
||||
child: Column(
|
||||
children: [
|
||||
PanelButton(
|
||||
title:
|
||||
const Text("Subject Icon Gallery"),
|
||||
leading: const Icon(CupertinoIcons
|
||||
.rectangle_3_offgrid_fill),
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward),
|
||||
onPressed: () {
|
||||
Navigator.of(context,
|
||||
rootNavigator: true)
|
||||
.push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const SubjectIconGallery()),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Secret Settings
|
||||
if (__ss)
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("secret".i18n),
|
||||
child: Column(
|
||||
children: [
|
||||
// Good student mode
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: Text("goodstudent".i18n,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500)),
|
||||
onChanged: (v) {
|
||||
if (v) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => PopScope(
|
||||
onPopInvoked: (didPop) =>
|
||||
false,
|
||||
child: AlertDialog(
|
||||
shape:
|
||||
RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(
|
||||
12.0)),
|
||||
title:
|
||||
Text("attention".i18n),
|
||||
content: Text(
|
||||
"goodstudent_disclaimer"
|
||||
.i18n),
|
||||
actions: [
|
||||
ActionButton(
|
||||
label:
|
||||
"understand".i18n,
|
||||
onTap: () {
|
||||
Navigator.of(
|
||||
context)
|
||||
.pop();
|
||||
settings.update(
|
||||
goodStudent: v);
|
||||
Provider.of<GradeProvider>(
|
||||
context,
|
||||
listen:
|
||||
false)
|
||||
.fetch();
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
settings.update(goodStudent: v);
|
||||
Provider.of<GradeProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.fetch();
|
||||
}
|
||||
},
|
||||
value: settings.goodStudent,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
|
||||
// Presentation mode
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: const Text("Presentation Mode",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500)),
|
||||
onChanged: (v) => settings.update(
|
||||
presentationMode: v),
|
||||
value: settings.presentationMode,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Theme Settings
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("appearance".i18n),
|
||||
child: Column(
|
||||
children: [
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.theme(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("theme".i18n),
|
||||
leading: const Icon(FeatherIcons.sun),
|
||||
trailing: Text(themeModeText),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () async {
|
||||
await _hideContainersController
|
||||
.forward();
|
||||
SettingsHelper.accentColor(context);
|
||||
setState(() {});
|
||||
_hideContainersController.reset();
|
||||
},
|
||||
title: Text("color".i18n),
|
||||
leading: const Icon(FeatherIcons.droplet),
|
||||
trailing: Container(
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.gradeColors(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("grade_colors".i18n),
|
||||
leading: const Icon(FeatherIcons.star),
|
||||
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: settings.gradeColors[i],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
FeatherIcons.barChart,
|
||||
color: settings.graphClassAvg
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary
|
||||
: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.25),
|
||||
),
|
||||
const SizedBox(width: 24.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"graph_class_avg".i18n,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.graphClassAvg
|
||||
? 1.0
|
||||
: .5),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onChanged: (v) =>
|
||||
settings.update(graphClassAvg: v),
|
||||
value: settings.graphClassAvg,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
// we need icon pack selector here
|
||||
// const PremiumIconPackSelector(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Notifications
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("notifications".i18n),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.newspaper_outlined,
|
||||
color: settings.newsEnabled
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary
|
||||
: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.25),
|
||||
),
|
||||
const SizedBox(width: 24.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"news".i18n,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.newsEnabled
|
||||
? 1.0
|
||||
: .5),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onChanged: (v) =>
|
||||
settings.update(newsEnabled: v),
|
||||
value: settings.newsEnabled,
|
||||
activeColor:
|
||||
Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Extras
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("extras".i18n),
|
||||
child: Column(children: [
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
FeatherIcons.gift,
|
||||
color: settings.gradeOpeningFun
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary
|
||||
: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.25),
|
||||
),
|
||||
const SizedBox(width: 24.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"surprise_grades".i18n,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.gradeOpeningFun
|
||||
? 1.0
|
||||
: .5),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onChanged: (v) =>
|
||||
settings.update(gradeOpeningFun: v),
|
||||
value: settings.gradeOpeningFun,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// About
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: Text("about".i18n),
|
||||
child: Column(children: [
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.atSign),
|
||||
title: const Text("Discord"),
|
||||
onPressed: () => launchUrl(
|
||||
Uri.parse("https://refilc.hu/discord"),
|
||||
mode: LaunchMode.externalApplication),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.globe),
|
||||
title: const Text("www.refilc.hu"),
|
||||
onPressed: () => launchUrl(
|
||||
Uri.parse("https://refilc.hu"),
|
||||
mode: LaunchMode.externalApplication),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.github),
|
||||
title: const Text("Github"),
|
||||
onPressed: () => launchUrl(
|
||||
Uri.parse("https://github.com/filc"),
|
||||
mode: LaunchMode.externalApplication),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.mail),
|
||||
title: Text("news".i18n),
|
||||
onPressed: () => _openNews(context),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.lock),
|
||||
title: Text("privacy".i18n),
|
||||
onPressed: () => _openPrivacy(context),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.award),
|
||||
title: Text("licenses".i18n),
|
||||
onPressed: () =>
|
||||
showLicensePage(context: context),
|
||||
),
|
||||
Tooltip(
|
||||
message: "data_collected".i18n,
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
textStyle: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.of(context).text),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.background),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
secondary: Icon(
|
||||
FeatherIcons.barChart2,
|
||||
color: settings.xFilcId != "none"
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary
|
||||
: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.25),
|
||||
),
|
||||
title: Text(
|
||||
"Analytics".i18n,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.xFilcId != "none"
|
||||
? 1.0
|
||||
: .5),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
"Anonymous Usage Analytics".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(
|
||||
settings.xFilcId != "none"
|
||||
? .5
|
||||
: .2),
|
||||
),
|
||||
),
|
||||
onChanged: (v) {
|
||||
String newId;
|
||||
if (v == false) {
|
||||
newId = "none";
|
||||
} else if (settings.xFilcId ==
|
||||
"none") {
|
||||
newId = SettingsProvider
|
||||
.defaultSettings()
|
||||
.xFilcId;
|
||||
} else {
|
||||
newId = settings.xFilcId;
|
||||
}
|
||||
settings.update(xFilcId: newId);
|
||||
},
|
||||
value: settings.xFilcId != "none",
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (settings.developerMode)
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12.0, horizontal: 24.0),
|
||||
child: Panel(
|
||||
title: const Text("Developer Settings"),
|
||||
child: Column(
|
||||
children: [
|
||||
Material(
|
||||
type: MaterialType.transparency,
|
||||
child: SwitchListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: const Text("Developer Mode",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500)),
|
||||
onChanged: (v) => settings.update(
|
||||
developerMode: false),
|
||||
value: settings.developerMode,
|
||||
activeColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
),
|
||||
),
|
||||
PanelButton(
|
||||
leading: const Icon(FeatherIcons.copy),
|
||||
title: const Text("Copy JWT"),
|
||||
onPressed: () => Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: Provider.of<KretaClient>(
|
||||
context,
|
||||
listen: false)
|
||||
.accessToken!)),
|
||||
),
|
||||
// if (Provider.of<PremiumProvider>(context,
|
||||
// listen: false)
|
||||
// .hasPremium)
|
||||
// PanelButton(
|
||||
// leading: const Icon(FeatherIcons.key),
|
||||
// title: const Text("Remove Premium"),
|
||||
// onPressed: () {
|
||||
// Provider.of<PremiumProvider>(
|
||||
// context,
|
||||
// listen: false)
|
||||
// .activate(removePremium: true);
|
||||
// settings.update(
|
||||
// accentColor: AccentColor.filc,
|
||||
// store: true);
|
||||
// Provider.of<ThemeModeObserver>(
|
||||
// context,
|
||||
// listen: false)
|
||||
// .changeTheme(settings.theme);
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
child: const Panel(
|
||||
title: Text("v" +
|
||||
String.fromEnvironment("APPVER",
|
||||
defaultValue: "?"))),
|
||||
onTap: () {
|
||||
if (devmodeCountdown > 0) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
content: Text(
|
||||
"You are $devmodeCountdown taps away from Developer Mode."),
|
||||
));
|
||||
|
||||
setState(() => devmodeCountdown--);
|
||||
} else if (devmodeCountdown == 0) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
"Developer Mode successfully activated."),
|
||||
));
|
||||
|
||||
settings.update(developerMode: true);
|
||||
|
||||
setState(() => devmodeCountdown--);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openNews(BuildContext context) =>
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.push(CupertinoPageRoute(builder: (context) => const NewsScreen()));
|
||||
void _openUpdates(BuildContext context) =>
|
||||
UpdateView.show(updateProvider.releases.first, context: context);
|
||||
void _openPrivacy(BuildContext context) => PrivacyView.show(context);
|
||||
}
|
||||
191
refilc_desktop_ui/lib/screens/settings/settings_screen.i18n.dart
Normal file
191
refilc_desktop_ui/lib/screens/settings/settings_screen.i18n.dart
Normal file
@@ -0,0 +1,191 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension SettingsLocalization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"personal_details": "Personal Details",
|
||||
"open_dkt": "Open DCS",
|
||||
"edit_nickname": "Edit Nickname",
|
||||
"edit_profile_picture": "Edit Profile Picture",
|
||||
"remove_profile_picture": "Remove Profile Picture",
|
||||
"light": "Light",
|
||||
"dark": "Dark",
|
||||
"system": "System",
|
||||
"add_user": "Add User",
|
||||
"log_out": "Log Out",
|
||||
"update_available": "Update Available",
|
||||
"general": "General",
|
||||
"language": "Language",
|
||||
"startpage": "Startpage",
|
||||
"rounding": "Rounding",
|
||||
"appearance": "Appearance",
|
||||
"theme": "Theme",
|
||||
"color": "Color",
|
||||
"grade_colors": "Grade Colors",
|
||||
"notifications": "Notifications",
|
||||
"news": "News",
|
||||
"extras": "Extras",
|
||||
"about": "About",
|
||||
"supporters": "Supporters",
|
||||
"privacy": "Privacy Policy",
|
||||
"licenses": "Licenses",
|
||||
"vibrate": "Vibration",
|
||||
"voff": "Off",
|
||||
"vlight": "Light",
|
||||
"vmedium": "Medium",
|
||||
"vstrong": "Strong",
|
||||
"cancel": "Cancel",
|
||||
"done": "Done",
|
||||
"reset": "Reset",
|
||||
"open": "Open",
|
||||
"data_collected":
|
||||
"Data collected: Platform (eg. Android), App version (eg. 3.0.0), Unique Install Identifier",
|
||||
"Analytics": "Analytics",
|
||||
"Anonymous Usage Analytics": "Anonymous Usage Analytics",
|
||||
"graph_class_avg": "Class average on graph",
|
||||
"goodstudent": "Good student mode",
|
||||
"attention": "Attention!",
|
||||
"goodstudent_disclaimer":
|
||||
"reFilc can not be held liable for the usage of this feature.\n\n(if your mother beats you up because you showed her fake grades, you can only blame yourself for it)",
|
||||
"understand": "I understand",
|
||||
"secret": "Secret Settings",
|
||||
"bell_delay": "Bell Delay",
|
||||
"delay": "Delay",
|
||||
"hurry": "Hurry",
|
||||
"sync": "Synchronize",
|
||||
"sync_help": "Press the Synchronize button when the bell rings.",
|
||||
"surprise_grades": "Surprise Grades",
|
||||
"icon_pack": "Icon Pack",
|
||||
"change_username": "Set a nickname",
|
||||
"Accent Color": "Accent Color",
|
||||
"Background Color": "Background Color",
|
||||
"Highlight Color": "Highlight Color",
|
||||
"Adaptive Theme": "Adaptive Theme",
|
||||
},
|
||||
"hu_hu": {
|
||||
"personal_details": "Személyes információk",
|
||||
"open_dkt": "DKT megnyitása",
|
||||
"edit_nickname": "Becenév szerkesztése",
|
||||
"edit_profile_picture": "Profil-kép szerkesztése",
|
||||
"remove_profile_picture": "Profil-kép törlése",
|
||||
"light": "Világos",
|
||||
"dark": "Sötét",
|
||||
"system": "Rendszer",
|
||||
"add_user": "Felhasználó hozzáadása",
|
||||
"log_out": "Kijelentkezés",
|
||||
"update_available": "Frissítés elérhető",
|
||||
"general": "Általános",
|
||||
"language": "Nyelv",
|
||||
"startpage": "Kezdőlap",
|
||||
"rounding": "Kerekítés",
|
||||
"appearance": "Kinézet",
|
||||
"theme": "Téma",
|
||||
"color": "Színek",
|
||||
"grade_colors": "Jegyek színei",
|
||||
"notifications": "Értesítések",
|
||||
"news": "Hírek",
|
||||
"extras": "Extrák",
|
||||
"about": "Névjegy",
|
||||
"supporters": "Támogatók",
|
||||
"privacy": "Adatvédelmi irányelvek",
|
||||
"licenses": "Licenszek",
|
||||
"vibrate": "Rezgés",
|
||||
"voff": "Kikapcsolás",
|
||||
"vlight": "Alacsony",
|
||||
"vmedium": "Közepes",
|
||||
"vstrong": "Erős",
|
||||
"cancel": "Mégsem",
|
||||
"done": "Kész",
|
||||
"reset": "Visszaállítás",
|
||||
"open": "Megnyitás",
|
||||
"data_collected":
|
||||
"Gyűjtött adat: Platform (pl. Android), App verzió (pl. 3.0.0), Egyedi telepítési azonosító",
|
||||
"Analytics": "Analitika",
|
||||
"Anonymous Usage Analytics": "Névtelen használati analitika",
|
||||
"graph_class_avg": "Osztályátlag a grafikonon",
|
||||
"goodstudent": "Jó tanuló mód",
|
||||
"attention": "Figyelem!",
|
||||
"goodstudent_disclaimer":
|
||||
"A reFilc minden felelősséget elhárít a funkció használatával kapcsolatban.\n\n(Értsd: ha az anyád megver, mert megtévesztő ábrákat mutattál neki, azért csakis magadadat hibáztathatod.)",
|
||||
"understand": "Értem",
|
||||
"secret": "Titkos Beállítások",
|
||||
"bell_delay": "Csengő eltolódása",
|
||||
"delay": "Késleltetés",
|
||||
"hurry": "Siettetés",
|
||||
"sync": "Szinkronizálás",
|
||||
"sync_help": "Csengetéskor nyomd meg a Szinkronizálás gombot.",
|
||||
"surprise_grades": "Meglepetés jegyek",
|
||||
"icon_pack": "Ikon séma",
|
||||
"change_username": "Becenév beállítása",
|
||||
"Accent Color": "Egyedi szín",
|
||||
"Background Color": "Háttér színe",
|
||||
"Highlight Color": "Panelek színe",
|
||||
"Adaptive Theme": "Adaptív téma",
|
||||
},
|
||||
"de_de": {
|
||||
"personal_details": "Persönliche Angaben",
|
||||
"open_dkt": "Öffnen RDZ",
|
||||
"edit_nickname": "Spitznamen bearbeiten",
|
||||
"edit_profile_picture": "Profilbild bearbeiten",
|
||||
"remove_profile_picture": "Profilbild entfernen",
|
||||
"light": "Licht",
|
||||
"dark": "Dunkel",
|
||||
"system": "System",
|
||||
"add_user": "Benutzer hinzufügen",
|
||||
"log_out": "Abmelden",
|
||||
"update_available": "Update verfügbar",
|
||||
"general": "Allgemein",
|
||||
"language": "Sprache",
|
||||
"startpage": "Startseite",
|
||||
"rounding": "Rundung",
|
||||
"appearance": "Erscheinungsbild",
|
||||
"theme": "Thema",
|
||||
"color": "Farbe",
|
||||
"grade_colors": "Grad Farben",
|
||||
"notifications": "Benachrichtigungen",
|
||||
"news": "Nachrichten",
|
||||
"extras": "Extras",
|
||||
"about": "Informationen",
|
||||
"supporters": "Unterstützer",
|
||||
"privacy": "Datenschutzbestimmungen",
|
||||
"licenses": "Lizenzen",
|
||||
"vibrate": "Vibration",
|
||||
"voff": "Aus",
|
||||
"vlight": "Leicht",
|
||||
"vmedium": "Mittel",
|
||||
"vstrong": "Stark",
|
||||
"cancel": "Abbrechen",
|
||||
"done": "Fertig",
|
||||
"reset": "Zurücksetzen",
|
||||
"open": "Öffnen",
|
||||
"data_collected":
|
||||
"Erhobene Daten: Plattform (z.B. Android), App version (z.B. 3.0.0), Eindeutige Installationskennung",
|
||||
"Analytics": "Analytik",
|
||||
"Anonymous Usage Analytics": "Anonyme Nutzungsanalyse",
|
||||
"graph_class_avg": "Klassendurchschnitt in der Grafik",
|
||||
"goodstudent": "Guter Student Modus",
|
||||
"attention": "Achtung!",
|
||||
"goodstudent_disclaimer": "Same in English.",
|
||||
"understand": "Ich verstehe",
|
||||
"secret": "Geheime Einstellungen",
|
||||
"bell_delay": "Klingelverzögerung",
|
||||
"delay": "Verzögern",
|
||||
"hurry": "Eile",
|
||||
"sync": "Synchronisieren",
|
||||
"sync_help": "Drücken Sie die Sync-Taste, wenn die Glocke läutet.",
|
||||
"surprise_grades": "Überraschungsnoten",
|
||||
"icon_pack": "Icon-Pack",
|
||||
"change_username": "Einen Spitznamen festlegen",
|
||||
"Accent Color": "Accent Color",
|
||||
"Background Color": "Background Color",
|
||||
"Highlight Color": "Highlight Color",
|
||||
"Adaptive Theme": "Adaptive Theme",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user