forked from firka/firka
refactor
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
@@ -39,7 +38,7 @@ enum FormatMode { yearly, grades, welcome, hmm, da, dd }
|
||||
enum Cycle { morning, day, afternoon, night }
|
||||
|
||||
extension DateExtension on DateTime {
|
||||
String format(BuildContext context, FormatMode mode) {
|
||||
String format(AppLocalizations l10n, FormatMode mode) {
|
||||
var today = timeNow();
|
||||
today = today.subtract(Duration(
|
||||
hours: today.hour,
|
||||
@@ -55,19 +54,19 @@ extension DateExtension on DateTime {
|
||||
switch (mode) {
|
||||
case FormatMode.grades:
|
||||
if (isBefore(yesterdayLim)) {
|
||||
return format(context, FormatMode.yearly);
|
||||
return format(l10n, FormatMode.yearly);
|
||||
}
|
||||
if (isAfter(yesterdayLim) && isBefore(today)) {
|
||||
return AppLocalizations.of(context)!.yesterday;
|
||||
return l10n.yesterday;
|
||||
}
|
||||
if (isAfter(yesterday) && isBefore(tomorrow)) {
|
||||
return AppLocalizations.of(context)!.today;
|
||||
return l10n.today;
|
||||
}
|
||||
if (isAfter(today) && isBefore(tomorrowLim)) {
|
||||
return AppLocalizations.of(context)!.tomorrow;
|
||||
return l10n.tomorrow;
|
||||
}
|
||||
|
||||
return format(context, FormatMode.yearly);
|
||||
return format(l10n, FormatMode.yearly);
|
||||
case FormatMode.yearly:
|
||||
return DateFormat('MMMM dd').format(this);
|
||||
case FormatMode.hmm:
|
||||
|
||||
@@ -25,7 +25,7 @@ class SettingsStore {
|
||||
"settings_padding": SettingsPadding(0, 20),
|
||||
"application": SettingsSubGroup(
|
||||
0,
|
||||
FirkaIconType.Majesticons,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
"Alkalmazás",
|
||||
LinkedHashMap.of({
|
||||
@@ -60,13 +60,13 @@ class SettingsStore {
|
||||
})),
|
||||
"customization": SettingsSubGroup(
|
||||
0,
|
||||
FirkaIconType.Majesticons,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.flower2Solid,
|
||||
"Személyre szabás",
|
||||
LinkedHashMap.of({})),
|
||||
"notifications": SettingsSubGroup(0, FirkaIconType.Majesticons,
|
||||
"notifications": SettingsSubGroup(0, FirkaIconType.majesticons,
|
||||
Majesticon.bellSolid, "Értesítések", LinkedHashMap.of({})),
|
||||
"extras": SettingsSubGroup(0, FirkaIconType.Majesticons,
|
||||
"extras": SettingsSubGroup(0, FirkaIconType.majesticons,
|
||||
Majesticon.lightningBoltSolid, "Extrák", LinkedHashMap.of({})),
|
||||
"settings_other_padding": SettingsPadding(0, 20),
|
||||
"settings_other_header": SettingsHeaderSmall(0, "Egyéb"),
|
||||
|
||||
@@ -17,25 +17,36 @@ class FirkaCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
var right = this.right ?? [];
|
||||
|
||||
var _attached = attached != null ? attached! : Attach.none;
|
||||
var attached = this.attached != null ? this.attached! : Attach.none;
|
||||
final defaultRounding = 16.0;
|
||||
final attachedRounding = 8.0;
|
||||
|
||||
if (extra != null) {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
child: Card(
|
||||
color: appStyle.colors.card,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(
|
||||
_attached == Attach.top ? attachedRounding : defaultRounding),
|
||||
attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(
|
||||
_attached == Attach.top ? attachedRounding : defaultRounding),
|
||||
attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(
|
||||
_attached == Attach.bottom ? attachedRounding : defaultRounding),
|
||||
attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(
|
||||
_attached == Attach.bottom ? attachedRounding : defaultRounding)),
|
||||
attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -56,19 +67,30 @@ class FirkaCard extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
child: Card(
|
||||
color: appStyle.colors.card,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(
|
||||
_attached == Attach.top ? attachedRounding : defaultRounding),
|
||||
attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(
|
||||
_attached == Attach.top ? attachedRounding : defaultRounding),
|
||||
attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(
|
||||
_attached == Attach.bottom ? attachedRounding : defaultRounding),
|
||||
attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(
|
||||
_attached == Attach.bottom ? attachedRounding : defaultRounding)),
|
||||
attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:firka/helpers/db/models/token_model.dart';
|
||||
import 'package:firka/helpers/db/widget.dart';
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/settings/setting.dart';
|
||||
import 'package:firka/l10n/app_localizations_hu.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/phone/pages/error/error_page.dart';
|
||||
import 'package:firka/ui/phone/screens/debug/debug_screen.dart';
|
||||
@@ -41,11 +42,13 @@ class AppInitialization {
|
||||
bool hasWatchListener = false;
|
||||
Uint8List? profilePicture;
|
||||
SettingsStore settings;
|
||||
AppLocalizations l10n;
|
||||
|
||||
AppInitialization({
|
||||
required this.isar,
|
||||
required this.tokenCount,
|
||||
required this.settings,
|
||||
required this.l10n,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,6 +83,7 @@ Future<AppInitialization> initializeApp() async {
|
||||
isar: isar,
|
||||
tokenCount: tokenCount,
|
||||
settings: SettingsStore(),
|
||||
l10n: AppLocalizationsHu(),
|
||||
);
|
||||
|
||||
resetOldTimeTableCache(isar);
|
||||
@@ -128,13 +132,12 @@ void main() async {
|
||||
class InitializationScreen extends StatelessWidget {
|
||||
InitializationScreen({super.key});
|
||||
|
||||
// Place to store the initialization future
|
||||
final Future<AppInitialization> _initialization = initializeApp();
|
||||
final Future<AppInitialization> _init = initializeApp();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<AppInitialization>(
|
||||
future: _initialization,
|
||||
future: _init,
|
||||
builder: (context, snapshot) {
|
||||
// Check if initialization is complete
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../helpers/api/model/subject.dart';
|
||||
import '../../../../helpers/debug_helper.dart';
|
||||
import '../../../../l10n/app_localizations.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../model/style.dart';
|
||||
|
||||
@@ -82,7 +81,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.subjects,
|
||||
data.l10n.subjects,
|
||||
style: appStyle.fonts.H_H2
|
||||
.apply(color: appStyle.colors.textSecondary),
|
||||
)
|
||||
@@ -97,7 +96,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
child: ListView(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.your_subjects,
|
||||
data.l10n.your_subjects,
|
||||
style: appStyle.fonts.H_14px
|
||||
.apply(color: appStyle.colors.textSecondary),
|
||||
),
|
||||
@@ -105,7 +104,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
...gradeCards,
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.data,
|
||||
data.l10n.data,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textSecondary),
|
||||
),
|
||||
@@ -113,7 +112,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
FirkaCard(
|
||||
left: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.subject_avg,
|
||||
data.l10n.subject_avg,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
@@ -136,7 +135,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
),
|
||||
FirkaCard(left: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.class_avg,
|
||||
data.l10n.class_avg,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
@@ -144,7 +143,7 @@ class HomeGradesScreen extends StatelessAsyncWidget {
|
||||
FirkaCard(
|
||||
left: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.class_n,
|
||||
data.l10n.class_n,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:firka/helpers/ui/grade.dart';
|
||||
import 'package:firka/helpers/ui/stateless_async_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../l10n/app_localizations.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../model/style.dart';
|
||||
|
||||
@@ -30,7 +29,7 @@ class HomeGradesSubjectScreen extends StatelessAsyncWidget {
|
||||
height: 8,
|
||||
));
|
||||
gradeWidgets.add(Text(
|
||||
group.key.format(context, FormatMode.grades),
|
||||
group.key.format(data.l10n, FormatMode.grades),
|
||||
style: appStyle.fonts.H_14px,
|
||||
));
|
||||
gradeWidgets.add(SizedBox(
|
||||
@@ -75,7 +74,7 @@ class HomeGradesSubjectScreen extends StatelessAsyncWidget {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.subjects,
|
||||
data.l10n.subjects,
|
||||
style: appStyle
|
||||
.fonts.H_16px // TODO: Replace this with the proper font
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
|
||||
@@ -19,13 +19,11 @@ class HomeMainScreen extends StatefulWidget {
|
||||
const HomeMainScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<HomeMainScreen> createState() => _HomeMainScreen(data);
|
||||
State<HomeMainScreen> createState() => _HomeMainScreen();
|
||||
}
|
||||
|
||||
class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
final AppInitialization data;
|
||||
|
||||
_HomeMainScreen(this.data);
|
||||
_HomeMainScreen();
|
||||
|
||||
DateTime now = timeNow();
|
||||
List<Lesson>? lessons;
|
||||
@@ -40,7 +38,7 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
now = timeNow();
|
||||
var midnight = now.getMidnight();
|
||||
(() async {
|
||||
var resp = await data.client.getTimeTable(
|
||||
var resp = await widget.data.client.getTimeTable(
|
||||
midnight, midnight.add(Duration(hours: 23, minutes: 59)));
|
||||
|
||||
if (disposed) return;
|
||||
@@ -49,7 +47,7 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
});
|
||||
})();
|
||||
(() async {
|
||||
var resp = await data.client.getStudent();
|
||||
var resp = await widget.data.client.getStudent();
|
||||
|
||||
if (disposed) return;
|
||||
setState(() {
|
||||
@@ -81,7 +79,7 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
|
||||
if (lessons != null && lessons!.isNotEmpty) {
|
||||
if (now.isBefore(lessons!.first.start)) {
|
||||
welcomeWidget = StartingSoonWidget(now, lessons!);
|
||||
welcomeWidget = StartingSoonWidget(widget.data.l10n, now, lessons!);
|
||||
} else {
|
||||
var currentLesson = lessons!.firstWhereOrNull(
|
||||
(lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end));
|
||||
@@ -97,13 +95,16 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
lessonActive = true;
|
||||
}
|
||||
|
||||
welcomeWidget = LessonBigWidget(
|
||||
now, lessonIndex, currentLesson, prevLesson, nextLesson);
|
||||
welcomeWidget = LessonBigWidget(widget.data.l10n, now, lessonIndex,
|
||||
currentLesson, prevLesson, nextLesson);
|
||||
}
|
||||
}
|
||||
if (lessons != null && lessons!.isNotEmpty) {
|
||||
var nextLesson = lessons!.getNextLesson(now);
|
||||
if (nextLesson != null) nextClass = LessonSmallWidget(nextLesson, lessonActive);
|
||||
if (nextLesson != null) {
|
||||
nextClass =
|
||||
LessonSmallWidget(widget.data.l10n, nextLesson, lessonActive);
|
||||
}
|
||||
}
|
||||
|
||||
if (student != null && lessons != null) {
|
||||
@@ -117,7 +118,7 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
WelcomeWidget(now, student!, lessons!),
|
||||
WelcomeWidget(widget.data.l10n, now, student!, lessons!),
|
||||
SizedBox(height: 48),
|
||||
welcomeWidget,
|
||||
lessonActive ? SizedBox(height: 5) : SizedBox(height: 0),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:firka/helpers/api/model/timetable.dart';
|
||||
import 'package:firka/helpers/debug_helper.dart';
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/phone/widgets/bottom_tt_icon.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson.dart';
|
||||
@@ -15,19 +14,20 @@ import '../../../../main.dart';
|
||||
|
||||
class HomeTimetableScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
|
||||
const HomeTimetableScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<HomeTimetableScreen> createState() => _HomeTimetableScreen(data);
|
||||
State<HomeTimetableScreen> createState() => _HomeTimetableScreen();
|
||||
}
|
||||
|
||||
class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
final AppInitialization data;
|
||||
List<Lesson>? lessons;
|
||||
List<DateTime>? dates;
|
||||
DateTime? active;
|
||||
bool disposed = false;
|
||||
_HomeTimetableScreen(this.data);
|
||||
|
||||
_HomeTimetableScreen();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -44,7 +44,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
var sunday = monday.add(Duration(days: 6));
|
||||
|
||||
(() async {
|
||||
var lessonsResp = await data.client.getTimeTable(monday, sunday);
|
||||
var lessonsResp = await widget.data.client.getTimeTable(monday, sunday);
|
||||
List<DateTime> dates = List.empty(growable: true);
|
||||
|
||||
if (lessonsResp.response != null) {
|
||||
@@ -89,7 +89,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
.toList();
|
||||
|
||||
for (final date in dates!) {
|
||||
ttWidgets.add(BottomTimeTableNavIconWidget(() {
|
||||
ttWidgets.add(BottomTimeTableNavIconWidget(widget.data.l10n, () {
|
||||
setState(() {
|
||||
active = date;
|
||||
});
|
||||
@@ -109,8 +109,8 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
SvgPicture.asset("assets/images/logos/dave.svg",
|
||||
width: 48, height: 48),
|
||||
SizedBox(height: 12),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l1),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l2)
|
||||
Text(widget.data.l10n.tt_no_classes_l1),
|
||||
Text(widget.data.l10n.tt_no_classes_l2)
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
var lesson = lessonsToday[i];
|
||||
Lesson? nextLesson =
|
||||
lessonsToday.length > i + 1 ? lessonsToday[i + 1] : null;
|
||||
ttBody.add(LessonWidget(
|
||||
ttBody.add(LessonWidget(widget.data.l10n,
|
||||
lessonsToday.getLessonNo(lesson), lesson, nextLesson));
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.timetable,
|
||||
widget.data.l10n.timetable,
|
||||
style: appStyle.fonts.H_H2
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
@@ -149,7 +149,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.Majesticons,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.tableSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
@@ -161,7 +161,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.Majesticons,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.plusLine,
|
||||
size: 32.0,
|
||||
color: appStyle.colors.accent,
|
||||
@@ -173,7 +173,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.Majesticons,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/icon_helper.dart';
|
||||
import 'package:firka/helpers/profile_picture.dart';
|
||||
import 'package:firka/main.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/phone/screens/login/login_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@@ -21,13 +20,11 @@ class DebugScreen extends StatefulWidget {
|
||||
const DebugScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<DebugScreen> createState() => _DebugScreen(data);
|
||||
State<DebugScreen> createState() => _DebugScreen();
|
||||
}
|
||||
|
||||
class _DebugScreen extends State<DebugScreen> {
|
||||
final AppInitialization data;
|
||||
|
||||
_DebugScreen(this.data);
|
||||
_DebugScreen();
|
||||
|
||||
late ImagePicker _picker;
|
||||
Uint8List? profilePictureData;
|
||||
@@ -39,7 +36,7 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
super.initState();
|
||||
|
||||
_picker = ImagePicker();
|
||||
profilePictureData = data.profilePicture;
|
||||
profilePictureData = widget.data.profilePicture;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -98,11 +95,11 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
profilePicture,
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await pickProfilePicture(data, _picker);
|
||||
await pickProfilePicture(widget.data, _picker);
|
||||
|
||||
setState(() {
|
||||
if (data.profilePicture != null) {
|
||||
profilePictureData = data.profilePicture;
|
||||
if (widget.data.profilePicture != null) {
|
||||
profilePictureData = widget.data.profilePicture;
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -139,21 +136,21 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
print(
|
||||
"getStudent(): ${await data.client.getStudent(forceCache: useCache)}");
|
||||
"getStudent(): ${await widget.data.client.getStudent(forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getStudent()'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
print(
|
||||
"getNoticeBoard(): ${await data.client.getNoticeBoard(forceCache: useCache)}");
|
||||
"getNoticeBoard(): ${await widget.data.client.getNoticeBoard(forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getNoticeBoard()'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
print(
|
||||
"getGrades(): ${await data.client.getGrades(forceCache: useCache)}");
|
||||
"getGrades(): ${await widget.data.client.getGrades(forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getGrades()'),
|
||||
),
|
||||
@@ -165,7 +162,7 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
var end = now.add(Duration(days: 7));
|
||||
|
||||
print(
|
||||
"getLessons(): ${await data.client.getTimeTable(start, end, forceCache: useCache)}");
|
||||
"getLessons(): ${await widget.data.client.getTimeTable(start, end, forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getLessons()'),
|
||||
),
|
||||
@@ -177,21 +174,21 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
var end = now.add(Duration(days: 14));
|
||||
|
||||
print(
|
||||
"getHomework(): ${await data.client.getHomework(start, end, forceCache: useCache)}");
|
||||
"getHomework(): ${await widget.data.client.getHomework(start, end, forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getHomework()'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
print(
|
||||
"getTests(): ${await data.client.getTests(forceCache: useCache)}");
|
||||
"getTests(): ${await widget.data.client.getTests(forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getTests()'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
print(
|
||||
"getOmissions(): ${await data.client.getOmissions(forceCache: useCache)}");
|
||||
"getOmissions(): ${await widget.data.client.getOmissions(forceCache: useCache)}");
|
||||
},
|
||||
child: const Text('getOmissions()'),
|
||||
),
|
||||
@@ -203,12 +200,13 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty<Color>.fromMap(<WidgetStatesConstraint, Color>{
|
||||
backgroundColor: WidgetStateProperty<
|
||||
Color>.fromMap(<WidgetStatesConstraint, Color>{
|
||||
WidgetState.any: Colors.red,
|
||||
}),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isar = data.isar;
|
||||
var isar = widget.data.isar;
|
||||
|
||||
await isar.writeTxn(() async {
|
||||
await isar.tokenModels.clear();
|
||||
@@ -217,9 +215,9 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
widget.data.tokenCount = 0;
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LoginScreen(data)));
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LoginScreen(widget.data)));
|
||||
},
|
||||
child: const Text('wipe users'),
|
||||
),
|
||||
@@ -238,7 +236,7 @@ class _DebugScreen extends State<DebugScreen> {
|
||||
),
|
||||
Center(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.Majesticons, getIconData(e),
|
||||
FirkaIconType.majesticons, getIconData(e),
|
||||
color: Colors.black),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -15,7 +15,6 @@ import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import '../../../../helpers/db/widget.dart';
|
||||
import '../../../../helpers/debug_helper.dart';
|
||||
import '../../../../l10n/app_localizations.dart';
|
||||
import '../../../widget/firka_icon.dart';
|
||||
import '../../pages/extras/extras.dart';
|
||||
import '../../pages/extras/main_error.dart';
|
||||
@@ -28,7 +27,7 @@ class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<HomeScreen> createState() => _HomeScreenState(data);
|
||||
State<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
enum HomePages { home, grades, timetable }
|
||||
@@ -55,9 +54,7 @@ bool _prefetched = false;
|
||||
bool canPop = true;
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
final AppInitialization data;
|
||||
|
||||
_HomeScreenState(this.data);
|
||||
_HomeScreenState();
|
||||
|
||||
ActiveHomePage page = ActiveHomePage(HomePages.home);
|
||||
List<ActiveHomePage> previousPages = List.empty(growable: true);
|
||||
@@ -81,9 +78,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
_prefetched = true;
|
||||
var random = Random();
|
||||
|
||||
ApiResponse<Object> res = await data.client.getGrades(forceCache: false);
|
||||
ApiResponse<Object> res =
|
||||
await widget.data.client.getGrades(forceCache: false);
|
||||
|
||||
if (res.err != null) throw "await data.client.getGrades\n${res.err!}";
|
||||
if (res.err != null) {
|
||||
throw "await widget.data.client.getGrades\n${res.err!}";
|
||||
}
|
||||
|
||||
await Future.delayed(Duration(seconds: 1 + random.nextInt(2)));
|
||||
|
||||
@@ -91,10 +91,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
var start = now.subtract(Duration(days: now.weekday - 1));
|
||||
var end = start.add(Duration(days: 6));
|
||||
|
||||
res = await data.client.getTimeTable(start, end, forceCache: false);
|
||||
if (res.err != null) throw "await data.client.getTimeTable\n${res.err!}";
|
||||
res =
|
||||
await widget.data.client.getTimeTable(start, end, forceCache: false);
|
||||
if (res.err != null) {
|
||||
throw "await widget.data.client.getTimeTable\n${res.err!}";
|
||||
}
|
||||
|
||||
await WidgetCacheHelper.updateWidgetCache(appStyle, data.client);
|
||||
await WidgetCacheHelper.updateWidgetCache(appStyle, widget.data.client);
|
||||
await HomeWidget.updateWidget(
|
||||
qualifiedAndroidName: "app.firka.naplo.glance.TimetableWidget");
|
||||
} catch (e) {
|
||||
@@ -129,13 +132,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
// Use min to prevent filling the width
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.api_error,
|
||||
widget.data.l10n.api_error,
|
||||
style: appStyle.fonts.B_14SB
|
||||
.copyWith(color: appStyle.colors.errorText),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
child: FirkaIconWidget(FirkaIconType.Majesticons,
|
||||
child: FirkaIconWidget(FirkaIconType.majesticons,
|
||||
Majesticon.questionCircleSolid,
|
||||
color: appStyle.colors.errorAccent, size: 24),
|
||||
onTap: () {
|
||||
@@ -214,7 +217,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.refreshing,
|
||||
widget.data.l10n.refreshing,
|
||||
style: appStyle.fonts.B_14SB
|
||||
.copyWith(color: appStyle.colors.textPrimary),
|
||||
)
|
||||
@@ -242,7 +245,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [HomeSubPage(page, setPageCB, data)],
|
||||
children: [HomeSubPage(page, setPageCB, widget.data)],
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -279,7 +282,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
page.page == HomePages.home
|
||||
? Majesticon.homeSolid
|
||||
: Majesticon.homeLine,
|
||||
AppLocalizations.of(context)!.home,
|
||||
widget.data.l10n.home,
|
||||
page.page == HomePages.home
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.secondary,
|
||||
@@ -300,7 +303,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
page.page == HomePages.grades
|
||||
? Majesticon.bookmarkSolid
|
||||
: Majesticon.bookmarkLine,
|
||||
AppLocalizations.of(context)!.grades,
|
||||
widget.data.l10n.grades,
|
||||
page.page == HomePages.grades
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.secondary,
|
||||
@@ -321,7 +324,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
page.page == HomePages.timetable
|
||||
? Majesticon.calendarSolid
|
||||
: Majesticon.calendarLine,
|
||||
AppLocalizations.of(context)!.timetable,
|
||||
widget.data.l10n.timetable,
|
||||
page.page == HomePages.timetable
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.secondary,
|
||||
@@ -329,11 +332,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
// More Button
|
||||
BottomNavIconWidget(() {
|
||||
HapticFeedback.lightImpact();
|
||||
showExtrasBottomSheet(context, data);
|
||||
showExtrasBottomSheet(context, widget.data);
|
||||
},
|
||||
false,
|
||||
Majesticon.globeEarthLine,
|
||||
AppLocalizations.of(context)!.other,
|
||||
widget.data.l10n.other,
|
||||
appStyle.colors.secondary,
|
||||
appStyle.colors.textPrimary),
|
||||
],
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import '../../../../helpers/api/token_grant.dart';
|
||||
import '../../../../l10n/app_localizations.dart';
|
||||
import '../../../model/style.dart';
|
||||
import '../home/home_screen.dart';
|
||||
|
||||
@@ -101,8 +100,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
MediaQuery.of(context).size.width * 0.95;
|
||||
List<Map<String, Object>> slides = [
|
||||
{
|
||||
'title': AppLocalizations.of(context)!.title1,
|
||||
'subtitle': AppLocalizations.of(context)!.subtitle1,
|
||||
'title': widget.data.l10n.title1,
|
||||
'subtitle': widget.data.l10n.subtitle1,
|
||||
'picture': 'assets/images/carousel/slide1.png',
|
||||
'background': 'assets/images/carousel/slide1_background.gif',
|
||||
'foreground': '',
|
||||
@@ -113,8 +112,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
'y': 150.00,
|
||||
},
|
||||
{
|
||||
'title': AppLocalizations.of(context)!.title2,
|
||||
'subtitle': AppLocalizations.of(context)!.subtitle2,
|
||||
'title': widget.data.l10n.title2,
|
||||
'subtitle': widget.data.l10n.subtitle2,
|
||||
'picture': 'assets/images/carousel/slide2.png',
|
||||
'background': 'assets/images/carousel/slide2_background.gif',
|
||||
'foreground': '',
|
||||
@@ -125,8 +124,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
'y': 160.00,
|
||||
},
|
||||
{
|
||||
'title': AppLocalizations.of(context)!.title3,
|
||||
'subtitle': AppLocalizations.of(context)!.subtitle3,
|
||||
'title': widget.data.l10n.title3,
|
||||
'subtitle': widget.data.l10n.subtitle3,
|
||||
'picture': 'assets/images/carousel/slide3.png',
|
||||
'background': '',
|
||||
'foreground': 'assets/images/carousel/slide3_foreground.gif',
|
||||
@@ -136,8 +135,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
'y': 25.00,
|
||||
},
|
||||
{
|
||||
'title': AppLocalizations.of(context)!.title4,
|
||||
'subtitle': AppLocalizations.of(context)!.subtitle4,
|
||||
'title': widget.data.l10n.title4,
|
||||
'subtitle': widget.data.l10n.subtitle4,
|
||||
'picture': 'assets/images/carousel/slide4.png',
|
||||
'background': 'assets/images/carousel/slide4_background.gif',
|
||||
'foreground': '',
|
||||
@@ -431,7 +430,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.loginBtn,
|
||||
widget.data.l10n.loginBtn,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_16px.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
@@ -445,7 +444,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
const SizedBox(height: 20),
|
||||
GestureDetector(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.privacyLabel,
|
||||
widget.data.l10n.privacyLabel,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_12px
|
||||
.copyWith(color: appStyle.colors.textTertiary),
|
||||
|
||||
@@ -17,14 +17,11 @@ class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen(this.data, this.items, {super.key});
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState(data, items);
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
final AppInitialization data;
|
||||
final LinkedHashMap<String, SettingsItem> items;
|
||||
|
||||
_SettingsScreenState(this.data, this.items);
|
||||
_SettingsScreenState();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -92,7 +89,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SettingsScreen(data, item.children)));
|
||||
builder: (context) =>
|
||||
SettingsScreen(widget.data, item.children)));
|
||||
},
|
||||
child: FirkaCard(left: cardWidgets),
|
||||
));
|
||||
@@ -127,8 +125,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
item.value = v;
|
||||
});
|
||||
|
||||
data.isar.writeTxn(() async {
|
||||
item.save(data.isar.appSettingsModels);
|
||||
widget.data.isar.writeTxn(() async {
|
||||
item.save(widget.data.isar.appSettingsModels);
|
||||
});
|
||||
})
|
||||
],
|
||||
@@ -154,8 +152,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
item.activeIndex = i;
|
||||
});
|
||||
|
||||
data.isar.writeTxn(() async {
|
||||
item.save(data.isar.appSettingsModels);
|
||||
widget.data.isar.writeTxn(() async {
|
||||
item.save(widget.data.isar.appSettingsModels);
|
||||
});
|
||||
})
|
||||
]));
|
||||
@@ -170,7 +168,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
_updateSystemUI(); // Update system UI on every build, to compensate for the android system being dumb
|
||||
|
||||
var body = createWidgetTree(items.values);
|
||||
var body = createWidgetTree(widget.items.values);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
|
||||
@@ -17,14 +17,13 @@ class WearLoginScreen extends StatefulWidget {
|
||||
const WearLoginScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<WearLoginScreen> createState() => _WearLoginScreenState(data);
|
||||
State<WearLoginScreen> createState() => _WearLoginScreenState();
|
||||
}
|
||||
|
||||
class _WearLoginScreenState extends State<WearLoginScreen> {
|
||||
late WebViewController _webViewController;
|
||||
final AppInitialization data;
|
||||
|
||||
_WearLoginScreenState(this.data);
|
||||
_WearLoginScreenState();
|
||||
|
||||
final watch = WatchConnectivity();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class BottomNavIconWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FirkaIconWidget(FirkaIconType.Majesticons, icon,
|
||||
FirkaIconWidget(FirkaIconType.majesticons, icon,
|
||||
color: iconColor, size: 24)
|
||||
.build(context),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../model/style.dart';
|
||||
|
||||
class BottomTimeTableNavIconWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final void Function() onTap;
|
||||
final bool active;
|
||||
final DateTime date;
|
||||
|
||||
const BottomTimeTableNavIconWidget(this.onTap, this.active, this.date,
|
||||
const BottomTimeTableNavIconWidget(
|
||||
this.l10n, this.onTap, this.active, this.date,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
@@ -28,11 +31,11 @@ class BottomTimeTableNavIconWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 6),
|
||||
Text(date.format(context, FormatMode.da),
|
||||
Text(date.format(l10n, FormatMode.da),
|
||||
style: appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
Text(
|
||||
date.format(context, FormatMode.dd),
|
||||
date.format(l10n, FormatMode.dd),
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textSecondary),
|
||||
)
|
||||
|
||||
@@ -7,10 +7,11 @@ import 'package:flutter/material.dart';
|
||||
import '../../../helpers/api/model/timetable.dart';
|
||||
|
||||
class StartingSoonWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final List<Lesson> lessons;
|
||||
final DateTime now;
|
||||
|
||||
const StartingSoonWidget(this.now, this.lessons, {super.key});
|
||||
const StartingSoonWidget(this.l10n, this.now, this.lessons, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -19,15 +20,9 @@ class StartingSoonWidget extends StatelessWidget {
|
||||
var min = diff.inMinutes % 60;
|
||||
var sec = diff.inSeconds % 60;
|
||||
|
||||
var hourTxt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_hour
|
||||
: AppLocalizations.of(context)!.starting_hour_plural;
|
||||
var minTxt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_min
|
||||
: AppLocalizations.of(context)!.starting_min_plural;
|
||||
var secTxt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_sec
|
||||
: AppLocalizations.of(context)!.starting_sec_plural;
|
||||
var hourTxt = hour == 1 ? l10n.starting_hour : l10n.starting_hour_plural;
|
||||
var minTxt = hour == 1 ? l10n.starting_min : l10n.starting_min_plural;
|
||||
var secTxt = hour == 1 ? l10n.starting_sec : l10n.starting_sec_plural;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -42,7 +37,7 @@ class StartingSoonWidget extends StatelessWidget {
|
||||
children: [
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.starting_soon,
|
||||
l10n.starting_soon,
|
||||
style: appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
|
||||
@@ -9,44 +9,46 @@ import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../model/style.dart';
|
||||
|
||||
class WelcomeWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final Student student;
|
||||
final List<Lesson> lessons;
|
||||
final DateTime now;
|
||||
|
||||
const WelcomeWidget(this.now, this.student, this.lessons, {super.key});
|
||||
const WelcomeWidget(this.l10n, this.now, this.student, this.lessons,
|
||||
{super.key});
|
||||
|
||||
getIconForCycle(Cycle dayCycle) {
|
||||
switch (dayCycle) {
|
||||
case Cycle.morning:
|
||||
return FirkaIconWidget(FirkaIconType.MajesticonsLocal, "sunSolid",
|
||||
return FirkaIconWidget(FirkaIconType.majesticonsLocal, "sunSolid",
|
||||
color: appStyle.colors.accent);
|
||||
case Cycle.day:
|
||||
return FirkaIconWidget(
|
||||
FirkaIconType.MajesticonsLocal, "parkSolidSchool",
|
||||
FirkaIconType.majesticonsLocal, "parkSolidSchool",
|
||||
color: appStyle.colors.accent);
|
||||
case Cycle.afternoon:
|
||||
return FirkaIconWidget(FirkaIconType.Majesticons, Majesticon.moonSolid,
|
||||
return FirkaIconWidget(FirkaIconType.majesticons, Majesticon.moonSolid,
|
||||
color: appStyle.colors.accent);
|
||||
case Cycle.night:
|
||||
return FirkaIconWidget(FirkaIconType.Majesticons, Majesticon.moonSolid,
|
||||
return FirkaIconWidget(FirkaIconType.majesticons, Majesticon.moonSolid,
|
||||
color: appStyle.colors.accent);
|
||||
}
|
||||
}
|
||||
|
||||
String getRawTitle(BuildContext context, String name, Cycle dayCycle) {
|
||||
String getRawTitle(String name, Cycle dayCycle) {
|
||||
switch (dayCycle) {
|
||||
case Cycle.morning:
|
||||
return AppLocalizations.of(context)!.good_morning(name);
|
||||
return l10n.good_morning(name);
|
||||
case Cycle.day:
|
||||
return AppLocalizations.of(context)!.good_day(name);
|
||||
return l10n.good_day(name);
|
||||
case Cycle.afternoon:
|
||||
return AppLocalizations.of(context)!.good_afternoon(name);
|
||||
return l10n.good_afternoon(name);
|
||||
case Cycle.night:
|
||||
return AppLocalizations.of(context)!.good_night(name);
|
||||
return l10n.good_night(name);
|
||||
}
|
||||
}
|
||||
|
||||
String getTitle(BuildContext context, Cycle dayCycle) {
|
||||
String getTitle(Cycle dayCycle) {
|
||||
var name = "";
|
||||
|
||||
try {
|
||||
@@ -56,35 +58,35 @@ class WelcomeWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (lessons.isEmpty) {
|
||||
return getRawTitle(context, name, dayCycle);
|
||||
return getRawTitle(name, dayCycle);
|
||||
} else {
|
||||
if (now.isBefore(lessons.first.start)) {
|
||||
return getRawTitle(context, name, dayCycle);
|
||||
return getRawTitle(name, dayCycle);
|
||||
}
|
||||
return getRawTitle(context, name, dayCycle);
|
||||
return getRawTitle(name, dayCycle);
|
||||
}
|
||||
}
|
||||
|
||||
String getSubtitle(BuildContext context, Cycle dayCycle) {
|
||||
String getSubtitle(Cycle dayCycle) {
|
||||
if (lessons.isEmpty) {
|
||||
return now.format(context, FormatMode.welcome);
|
||||
return now.format(l10n, FormatMode.welcome);
|
||||
} else {
|
||||
if (now.isBefore(lessons.first.start)) {
|
||||
return now.format(context, FormatMode.welcome);
|
||||
return now.format(l10n, FormatMode.welcome);
|
||||
}
|
||||
var lessonsLeft =
|
||||
lessons.where((lesson) => lesson.start.isAfter(now)).length;
|
||||
if (lessonsLeft < 1) {
|
||||
return AppLocalizations.of(context)!.tomorrow_subtitle;
|
||||
return l10n.tomorrow_subtitle;
|
||||
}
|
||||
if (lessonsLeft == 1) {
|
||||
return AppLocalizations.of(context)!.suffering_almost_over_subtitle;
|
||||
return l10n.suffering_almost_over_subtitle;
|
||||
}
|
||||
if (lessonsLeft <= 3) {
|
||||
return AppLocalizations.of(context)!.n_left_subtitle(lessonsLeft);
|
||||
return l10n.n_left_subtitle(lessonsLeft);
|
||||
}
|
||||
|
||||
return now.format(context, FormatMode.welcome);
|
||||
return now.format(l10n, FormatMode.welcome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +99,11 @@ class WelcomeWidget extends StatelessWidget {
|
||||
children: [
|
||||
getIconForCycle(dayCycle),
|
||||
const SizedBox(height: 16.0),
|
||||
Text(getTitle(context, dayCycle),
|
||||
Text(getTitle(dayCycle),
|
||||
style: appStyle.fonts.H_H2
|
||||
.copyWith(color: appStyle.colors.textPrimary)),
|
||||
const SizedBox(height: 2.0),
|
||||
Text(getSubtitle(context, dayCycle),
|
||||
Text(getSubtitle(dayCycle),
|
||||
style: appStyle.fonts.B_14R
|
||||
.copyWith(color: appStyle.colors.textSecondary)),
|
||||
],
|
||||
|
||||
@@ -8,11 +8,13 @@ import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../widget/class_icon.dart';
|
||||
|
||||
class LessonWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final int? lessonNo;
|
||||
final Lesson lesson;
|
||||
final Lesson? nextLesson;
|
||||
|
||||
const LessonWidget(this.lessonNo, this.lesson, this.nextLesson, {super.key});
|
||||
const LessonWidget(this.l10n, this.lessonNo, this.lesson, this.nextLesson,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,7 +41,7 @@ class LessonWidget extends StatelessWidget {
|
||||
elements.add(GestureDetector(
|
||||
onTap: () {
|
||||
showLessonBottomSheet(
|
||||
context, lesson, lessonNo, accent, secondary, bgColor);
|
||||
context, l10n, lesson, lessonNo, accent, secondary, bgColor);
|
||||
},
|
||||
child: FirkaCard(
|
||||
left: [
|
||||
@@ -75,8 +77,8 @@ class LessonWidget extends StatelessWidget {
|
||||
right: [
|
||||
Text(
|
||||
isDismissed
|
||||
? AppLocalizations.of(context)!.class_dismissed
|
||||
: lesson.start.toLocal().format(context, FormatMode.hmm),
|
||||
? l10n.class_dismissed
|
||||
: lesson.start.toLocal().format(l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
isDismissed
|
||||
@@ -98,7 +100,7 @@ class LessonWidget extends StatelessWidget {
|
||||
if (isSubstituted) {
|
||||
elements.add(FirkaCard(
|
||||
left: [
|
||||
Text(AppLocalizations.of(context)!.class_substitution,
|
||||
Text(l10n.class_substitution,
|
||||
style: appStyle.fonts.H_14px
|
||||
.apply(color: appStyle.colors.textPrimary))
|
||||
],
|
||||
@@ -116,13 +118,13 @@ class LessonWidget extends StatelessWidget {
|
||||
|
||||
elements.add(FirkaCard(
|
||||
left: [
|
||||
Text(AppLocalizations.of(context)!.breakTxt,
|
||||
Text(l10n.breakTxt,
|
||||
style: appStyle.fonts.B_14SB
|
||||
.apply(color: appStyle.colors.textSecondary))
|
||||
],
|
||||
right: [
|
||||
Text(
|
||||
"$breakMins ${breakMins == 1 ? AppLocalizations.of(context)!.starting_min : AppLocalizations.of(context)!.starting_min_plural}",
|
||||
"$breakMins ${breakMins == 1 ? l10n.starting_min : l10n.starting_min_plural}",
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textTertiary))
|
||||
],
|
||||
@@ -137,8 +139,14 @@ class LessonWidget extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void showLessonBottomSheet(BuildContext context, Lesson lesson, int? lessonNo,
|
||||
Color accent, Color secondary, Color bgColor) {
|
||||
void showLessonBottomSheet(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
Lesson lesson,
|
||||
int? lessonNo,
|
||||
Color accent,
|
||||
Color secondary,
|
||||
Color bgColor) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
elevation: 100,
|
||||
@@ -216,7 +224,7 @@ void showLessonBottomSheet(BuildContext context, Lesson lesson, int? lessonNo,
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
Text(
|
||||
'${lesson.start.format(context, FormatMode.hmm)} - ${lesson.end.format(context, FormatMode.hmm)}',
|
||||
'${lesson.start.format(l10n, FormatMode.hmm)} - ${lesson.end.format(l10n, FormatMode.hmm)}',
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
@@ -229,7 +237,7 @@ void showLessonBottomSheet(BuildContext context, Lesson lesson, int? lessonNo,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.lesson_subject,
|
||||
l10n.lesson_subject,
|
||||
style: appStyle.fonts.H_14px,
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
|
||||
@@ -9,14 +9,15 @@ import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../widget/class_icon.dart';
|
||||
|
||||
class LessonBigWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final DateTime now;
|
||||
final int? lessonNo;
|
||||
final Lesson? lesson;
|
||||
final Lesson? prevLesson;
|
||||
final Lesson? nextLesson;
|
||||
|
||||
const LessonBigWidget(
|
||||
this.now, this.lessonNo, this.lesson, this.prevLesson, this.nextLesson,
|
||||
const LessonBigWidget(this.l10n, this.now, this.lessonNo, this.lesson,
|
||||
this.prevLesson, this.nextLesson,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
@@ -40,10 +41,10 @@ class LessonBigWidget extends StatelessWidget {
|
||||
var secsLeft = timeLeft.inSeconds;
|
||||
|
||||
var timeLeftStr =
|
||||
"$minsLeft ${minsLeft == 1 ? AppLocalizations.of(context)!.starting_min : AppLocalizations.of(context)!.starting_min_plural}";
|
||||
"$minsLeft ${minsLeft == 1 ? l10n.starting_min : l10n.starting_min_plural}";
|
||||
if (minsLeft < 1) {
|
||||
timeLeftStr =
|
||||
"$secsLeft ${secsLeft == 1 ? AppLocalizations.of(context)!.starting_sec : AppLocalizations.of(context)!.starting_sec_plural}";
|
||||
"$secsLeft ${secsLeft == 1 ? l10n.starting_sec : l10n.starting_sec_plural}";
|
||||
}
|
||||
|
||||
return Column(
|
||||
@@ -101,10 +102,7 @@ class LessonBigWidget extends StatelessWidget {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
lesson!.start
|
||||
.toLocal()
|
||||
.format(context, FormatMode.hmm),
|
||||
Text(lesson!.start.toLocal().format(l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
Card(
|
||||
@@ -122,8 +120,7 @@ class LessonBigWidget extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 18),
|
||||
Text(
|
||||
lesson!.end.toLocal().format(context, FormatMode.hmm),
|
||||
Text(lesson!.end.toLocal().format(l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_12R
|
||||
.apply(color: appStyle.colors.textSecondary)),
|
||||
],
|
||||
@@ -147,8 +144,7 @@ class LessonBigWidget extends StatelessWidget {
|
||||
duration - nextLesson!.start.difference(now).inMilliseconds;
|
||||
var timeLeft = nextLesson!.start.difference(now);
|
||||
|
||||
var timeLeftStr =
|
||||
AppLocalizations.of(context)!.timeLeft(timeLeft.inMinutes + 1);
|
||||
var timeLeftStr = l10n.timeLeft(timeLeft.inMinutes + 1);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -166,11 +162,11 @@ class LessonBigWidget extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.MajesticonsLocal, 'cupFilled',
|
||||
FirkaIconType.majesticonsLocal, 'cupFilled',
|
||||
color: wearStyle.colors.accent, size: 24),
|
||||
),
|
||||
),
|
||||
Text(AppLocalizations.of(context)!.breakTxt,
|
||||
Text(l10n.breakTxt,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
@@ -193,7 +189,7 @@ class LessonBigWidget extends StatelessWidget {
|
||||
Text(
|
||||
prevLesson!.end
|
||||
.toLocal()
|
||||
.format(context, FormatMode.hmm),
|
||||
.format(l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
@@ -203,7 +199,7 @@ class LessonBigWidget extends StatelessWidget {
|
||||
Text(
|
||||
nextLesson!.start
|
||||
.toLocal()
|
||||
.format(context, FormatMode.hmm),
|
||||
.format(l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/ui/firka_card.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -7,10 +8,12 @@ import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../widget/class_icon.dart';
|
||||
|
||||
class LessonSmallWidget extends StatelessWidget {
|
||||
final AppLocalizations l10n;
|
||||
final Lesson lesson;
|
||||
final bool lessonActive;
|
||||
|
||||
const LessonSmallWidget(this.lesson, this.lessonActive, {super.key});
|
||||
const LessonSmallWidget(this.l10n, this.lesson, this.lessonActive,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -44,7 +47,7 @@ class LessonSmallWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${lesson.start.toLocal().format(context, FormatMode.hmm)} - ${lesson.end.toLocal().format(context, FormatMode.hmm)}",
|
||||
"${lesson.start.toLocal().format(l10n, FormatMode.hmm)} - ${lesson.end.toLocal().format(l10n, FormatMode.hmm)}",
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
|
||||
@@ -25,7 +25,7 @@ class ClassIconWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
var iconCategory = getIconType(_uid, _className, _category);
|
||||
|
||||
return FirkaIconWidget(FirkaIconType.Majesticons, getIconData(iconCategory),
|
||||
return FirkaIconWidget(FirkaIconType.majesticons, getIconData(iconCategory),
|
||||
color: color, size: size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
enum FirkaIconType {
|
||||
Majesticons,
|
||||
MajesticonsLocal,
|
||||
majesticons,
|
||||
majesticonsLocal,
|
||||
}
|
||||
|
||||
class FirkaIconWidget extends StatelessWidget {
|
||||
@@ -21,9 +21,9 @@ class FirkaIconWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (iconType) {
|
||||
case FirkaIconType.Majesticons:
|
||||
case FirkaIconType.majesticons:
|
||||
return Majesticon(iconData as Uint8List, color: color, size: size);
|
||||
case FirkaIconType.MajesticonsLocal:
|
||||
case FirkaIconType.majesticonsLocal:
|
||||
return SvgPicture.asset(
|
||||
'assets/majesticons/${iconData as String}.svg',
|
||||
color: color,
|
||||
|
||||
Reference in New Issue
Block a user