Skip to content

Commit

Permalink
Merge pull request #69 from refilc/dev
Browse files Browse the repository at this point in the history
69-es szamu pr haha 😏
  • Loading branch information
kimaah committed Oct 8, 2023
2 parents 45c6fcc + b19da9c commit acbffd6
Show file tree
Hide file tree
Showing 23 changed files with 272 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
android:layout_below="@id/iv_1"
android:layout_marginHorizontal="15dp"
android:fontFamily="@font/montserrat_medium"
android:text="A widget használatához, bejelentkezés szükséges."
android:text="A widget használatához bejelentkezés szükséges."
android:textColor="@color/black"
android:paddingTop="10dp"
android:textSize="17sp"
Expand Down
5 changes: 4 additions & 1 deletion filcnaplo/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -39,5 +39,8 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
16 changes: 8 additions & 8 deletions filcnaplo/lib/api/providers/live_card_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LiveCardProvider extends ChangeNotifier {
_liveActivitiesPlugin.areActivitiesEnabled().then((value) {
// Console log
if (kDebugMode) {
print("Live card enabled: $value");
print("iOS LiveActivity enabled: $value");
}

if (value) {
Expand All @@ -62,13 +62,13 @@ class LiveCardProvider extends ChangeNotifier {
});
}
});

_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
_delay = settings.bellDelayEnabled
? Duration(seconds: settings.bellDelay)
: Duration.zero;
update();
}

_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
_delay = settings.bellDelayEnabled
? Duration(seconds: settings.bellDelay)
: Duration.zero;
update();
}

@override
Expand Down Expand Up @@ -196,7 +196,7 @@ class LiveCardProvider extends ChangeNotifier {
}
} catch (e) {
if (kDebugMode) {
print('ERROR: Unable to create or update iOS LiveCard!');
print('ERROR: Unable to create or update iOS LiveActivity!');
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions filcnaplo/lib/api/providers/status_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ class StatusProvider extends ChangeNotifier {
}
}

if (_stack.contains(Status.network)) return;
if (res.body == "invalid_grant" ||
if (res.body == 'invalid_grant' ||
res.body.replaceAll(' ', '') == '' ||
res.statusCode == 400) {
if (!_stack.contains(Status.apiError)) {
if (!_stack.contains(Status.apiError) &&
!_stack.contains(Status.network)) {
if (res.statusCode == 401) return;
_stack.insert(0, Status.apiError);
notifyListeners();
}
Expand Down
1 change: 1 addition & 0 deletions filcnaplo/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class App extends StatelessWidget {
create: (context) => HomeworkProvider(
context: context,
database: database,
user: user,
),
),
ChangeNotifierProvider<MessageProvider>(
Expand Down
4 changes: 2 additions & 2 deletions filcnaplo/lib/helpers/notification_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class NotificationsHelper {
if (userProvider.getUsers().length == 1) {
await flutterLocalNotificationsPlugin.show(
absence.id.hashCode,
"title_absence".i18n,
"title_absence".i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528
"body_absence".i18n.fill(
[
DateFormat("yyyy-MM-dd").format(absence.date),
Expand All @@ -210,7 +210,7 @@ class NotificationsHelper {
} else {
await flutterLocalNotificationsPlugin.show(
absence.id.hashCode,
"title_absence".i18n,
"title_absence".i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528
"body_absence_multiuser".i18n.fill(
[
userProvider.displayName!,
Expand Down
2 changes: 1 addition & 1 deletion filcnaplo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez"
homepage: https://refilc.hu
publish_to: "none"

version: 4.3.0+226
version: 4.3.1+230

environment:
sdk: ">=2.17.0 <3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions filcnaplo_desktop_ui/lib/pages/grades/grades_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class _GradesPageState extends State<GradesPage> {
Expanded(
child: StatisticsTile(
outline: true,
title: AutoSizeText(
"classavg".i18n,
title: AutoSizeText( // https://discord.com/channels/1111649116020285532/1153397476578050130
"classavg".i18n,
textAlign: TextAlign.center,
maxLines: 2,
wrapWords: false,
Expand Down
122 changes: 122 additions & 0 deletions filcnaplo_desktop_ui/lib/screens/login/school_input/school_input.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import 'package:filcnaplo_mobile_ui/screens/login/login_input.dart';
import 'package:filcnaplo_mobile_ui/screens/login/school_input/school_input_overlay.dart';
import 'package:filcnaplo_desktop_ui/screens/login/school_input/school_input_tile.dart';
import 'package:filcnaplo_mobile_ui/screens/login/school_input/school_search.dart';
import 'package:flutter/material.dart';
import 'package:filcnaplo_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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'package:filcnaplo_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,
),
),
],
),
],
),
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions filcnaplo_kreta_api/lib/providers/homework_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class HomeworkProvider with ChangeNotifier {
List<Homework> initialHomework = const [],
required BuildContext context,
required DatabaseProvider database,
required UserProvider user,
}) {
_homework = List.castFrom(initialHomework);
_context = context;
_database = database;
_user = user;

if (_homework.isEmpty) restore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AbsenceView extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
onPressed: () {
onPressed: () { // https://discord.com/channels/1111649116020285532/1149964760130002945
Navigator.of(context).pop();

if (outsideContext != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ChangedLessonTile extends StatelessWidget {
),
),
title: Text(
lesson.substituteTeacher?.name != ""
lesson.substituteTeacher?.name != "" || lesson.substituteTeacher?.name != null
? "substituted".i18n
: "cancelled".i18n,
maxLines: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AbsenceSubjectView extends StatelessWidget {
TimetablePage.jump(context, lesson: lesson);
} else {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("Cannot find lesson".i18n,
content: Text("lesson_not_found".i18n,
style: const TextStyle(color: Colors.white)),
backgroundColor: AppColors.of(context).red,
context: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension ScreensLocalization on String {
"Subjects": "Subjects",
"attention": "Attention!",
"attention_body": "Percentage calculations are only an approximation so they may not be accurate.",
"lesson_not_found": "Cannot find lesson",
},
"hu_hu": {
"Absences": "Hiányzások",
Expand All @@ -32,6 +33,7 @@ extension ScreensLocalization on String {
"Subjects": "Tantárgyak",
"attention": "Figyelem!",
"attention_body": "A százalékos számítások csak közelítések, ezért előfordulhat, hogy nem pontosak.",
"lesson_not_found": "Nem található óra",
},
"de_de": {
"Absences": "Fehlen",
Expand All @@ -47,6 +49,7 @@ extension ScreensLocalization on String {
"Subjects": "Fächer",
"attention": "Achtung!",
"attention_body": "Prozentberechnungen sind nur eine Annäherung und können daher ungenau sein.",
"lesson_not_found": "Lektion kann nicht gefunden werden",
},
};

Expand Down
Loading

0 comments on commit acbffd6

Please sign in to comment.