From aa1f003539e17885f5e960e0dc588b7fa66dd29d Mon Sep 17 00:00:00 2001 From: vyPal Date: Tue, 19 Nov 2024 15:57:21 +0100 Subject: [PATCH] Add localized title to grades page --- lib/grades.dart | 52 ++++++++++++++++++++++++--------------------- lib/l10n/app_cs.arb | 3 ++- lib/l10n/app_en.arb | 3 ++- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/grades.dart b/lib/grades.dart index 88c016a..7775e0a 100644 --- a/lib/grades.dart +++ b/lib/grades.dart @@ -1,8 +1,8 @@ import 'package:eduapge2/api.dart'; import 'package:eduapge2/main.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_session_manager/flutter_session_manager.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_session_manager/flutter_session_manager.dart'; class GradesPage extends StatefulWidget { final SessionManager sessionManager; @@ -17,7 +17,7 @@ class GradesPageState extends BaseState { bool loading = true; late List apidataMsg; - late Widget messages; + List messages = []; @override void initState() { @@ -44,8 +44,30 @@ class GradesPageState extends BaseState { toolbarHeight: 0, ), body: !loading - ? Stack( - children: [messages], + ? Card( + elevation: 5, + child: Padding( + padding: const EdgeInsets.all(10), + child: Stack( + children: [ + Text( + AppLocalizations.of(context)!.gradesTitle, + style: const TextStyle( + fontSize: 24, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 40), + child: RefreshIndicator( + onRefresh: _pullRefresh, + child: ListView( + children: messages, + ), + ), + ), + ], + ), + ), ) : Text(AppLocalizations.of(context)!.loading), backgroundColor: Theme.of(context).colorScheme.surface, @@ -64,7 +86,7 @@ class GradesPageState extends BaseState { setState(() {}); //refresh UI } - Widget getMessages(List apidataMsg) { + List getMessages(List apidataMsg) { List rows = []; apidataMsg = apidataMsg.where((msg) => msg.type == "znamka").toList(); Map> grades = {}; @@ -84,24 +106,6 @@ class GradesPageState extends BaseState { ), )); } - return Card( - elevation: 5, - child: Padding( - padding: const EdgeInsets.all(10), - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.only(top: 40), - child: RefreshIndicator( - onRefresh: _pullRefresh, - child: ListView( - children: rows, - ), - ), - ), - ], - ), - ), - ); + return rows; } } diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 380cda5..8f0f42a 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -149,5 +149,6 @@ "createMessageNotifError": "Chyba", "createMessageNotifErrorBody": "Při odesílání zprávy se vyskytla chyba, tato chyba byla nahlášena.", "qrLoginPleaseLogin": "EduPage2 QR Přihlášení", - "qrLoginUseExistingCredentials": "Chystáte se přihlásit pomocí QR kódu" + "qrLoginUseExistingCredentials": "Chystáte se přihlásit pomocí QR kódu", + "gradesTitle": "Známky" } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5748a5b..4fb3e27 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -81,5 +81,6 @@ "createMessageNotifError": "Error", "createMessageNotifErrorBody": "There was an issue sending your message, it has been reported!", "qrLoginPleaseLogin": "EduPage2 QR Login", - "qrLoginUseExistingCredentials": "You are about to login to EduPage2 using a QR code" + "qrLoginUseExistingCredentials": "You are about to login to EduPage2 using a QR code", + "gradesTitle": "Grades" }