Skip to content

Commit

Permalink
Merge pull request #126 from refilc/dev
Browse files Browse the repository at this point in the history
dev to master (v5.0.3)
  • Loading branch information
kimaah committed Jun 21, 2024
2 parents 93eaa5a + 4128018 commit 4a45131
Show file tree
Hide file tree
Showing 75 changed files with 865 additions and 330 deletions.
2 changes: 1 addition & 1 deletion refilc/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {

defaultConfig {
applicationId "hu.refilc.naplo"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
2 changes: 1 addition & 1 deletion refilc/lib/api/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FilcAPI {
static const stripeSheet = "$payment/stripe-sheet";

static Future<bool> checkConnectivity() async =>
(await Connectivity().checkConnectivity()) != ConnectivityResult.none;
(await Connectivity().checkConnectivity())[0] != ConnectivityResult.none;

static Future<List<School>?> getSchools() async {
try {
Expand Down
6 changes: 3 additions & 3 deletions refilc/lib/api/providers/status_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StatusProvider extends ChangeNotifier {
StatusProvider() {
_handleNetworkChanges();
_handleDNSFailure();
Connectivity().checkConnectivity().then((value) => _networkType = value);
Connectivity().checkConnectivity().then((value) => _networkType = value[0]);
}

Status? getStatus() => _stack.isNotEmpty ? _stack[0] : null;
Expand All @@ -24,8 +24,8 @@ class StatusProvider extends ChangeNotifier {

void _handleNetworkChanges() {
Connectivity().onConnectivityChanged.listen((event) {
_networkType = event;
if (event == ConnectivityResult.none) {
_networkType = event[0];
if (event[0] == ConnectivityResult.none) {
if (!_stack.contains(Status.network)) {
_stack.remove(Status.apiError);
_stack.insert(0, Status.network);
Expand Down
1 change: 1 addition & 0 deletions refilc/lib/database/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const settingsDB = DatabaseStruct("settings", {
"new_colors": int,
"uwu_mode": int,
"new_popups": int,
"unseen_new_features": String,
// quick settings
"q_timetable_lesson_num": int, "q_timetable_sub_tiles": int,
"q_subjects_sub_tiles": int,
Expand Down
4 changes: 2 additions & 2 deletions refilc/lib/database/struct.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class DatabaseStruct {
String typeName = "";

switch (type.runtimeType) {
case int:
case const (int):
typeName = "integer";
break;
case String:
case const (String):
typeName = "text";
break;
}
Expand Down
4 changes: 2 additions & 2 deletions refilc/lib/helpers/notification_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'package:intl/intl.dart';
import 'package:refilc_kreta_api/models/message.dart';

// if you want to add a new category, also add it to the DB or else the app will probably crash
enum LastSeenCategory {
enum LastSeenCategory {
grade,
surprisegrade,
absence,
Expand Down Expand Up @@ -655,7 +655,7 @@ nem lesz tőle használhatatlan az app, de kikommenteltem, mert még a végén k
lesson.lessonIndex,
lesson.name,
dayTitle(lesson.date),
lesson.substituteTeacher!.isRenamed
(lesson.substituteTeacher?.isRenamed ?? false)
? lesson.substituteTeacher!.renamedTo!
: lesson.substituteTeacher!.name
],
Expand Down
5 changes: 2 additions & 3 deletions refilc/lib/helpers/share_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import 'package:share_plus/share_plus.dart';
class ShareHelper {
static Future<void> shareText(String text, {String? subject}) =>
Share.share(text, subject: subject);
// ignore: deprecated_member_use

static Future<void> shareFile(String path, {String? text, String? subject}) =>
// ignore: deprecated_member_use
Share.shareFiles([path], text: text, subject: subject);
Share.shareXFiles([XFile(path)], text: text, subject: subject);

static Future<void> shareAttachment(Attachment attachment,
{required BuildContext context}) async {
Expand Down
39 changes: 38 additions & 1 deletion refilc/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import 'package:refilc/utils/service_locator.dart';
import 'package:refilc_mobile_ui/screens/error_screen.dart';
import 'package:refilc_mobile_ui/screens/error_report_screen.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:shake_flutter/models/shake_report_configuration.dart';
import 'package:shake_flutter/shake_flutter.dart';

import 'helpers/live_activity_helper.dart';

Expand All @@ -38,6 +40,28 @@ void main() async {

BackgroundFetch.registerHeadlessTask(backgroundHeadlessTask);

// setting up things for shakebugs
// List<ShakePickerItem> pickerItems = [
// ShakePickerItem('Bug', 'Hiba', tag: 'bug'),
// ShakePickerItem('Suggestion', 'Fejlesztési javaslat', tag: 'suggestion'),
// ShakePickerItem('Question', 'Kérdés', tag: 'question')
// ];
// ShakePicker picker =
// ShakePicker('Feedback type', 'Visszajelzés típusa', pickerItems);
// ShakeTitle title = ShakeTitle('Title', 'Leírás', required: true);

// ShakeInspectButton inspect = ShakeInspectButton();
// ShakeAttachments attachments = ShakeAttachments();

// List<ShakeFormComponent> components = [picker, title, inspect, attachments];
// ShakeForm form = ShakeForm(components);

// Shake.setShakeForm(form);

// shakebugs initialization
// Shake.setInvokeShakeOnScreenshot(true);
Shake.start('Y44AwzfY6091xO2Nr0w59RHSpNxJhhiSFGs4enmoJwelN82ZRzTLE5X');

// pre-cache required icons
const todaySvg = SvgAssetLoader('assets/svg/menu_icons/today_selected.svg');
const gradesSvg = SvgAssetLoader('assets/svg/menu_icons/grades_selected.svg');
Expand Down Expand Up @@ -170,6 +194,18 @@ Widget errorBuilder(FlutterErrorDetails details) {
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
if (kReleaseMode) {
// silent report to shakebugs
ShakeReportConfiguration configuration = ShakeReportConfiguration();
configuration.blackBoxData = true;
configuration.activityHistoryData = true;
configuration.screenshot = true;
configuration.video = false;
Shake.silentReport(
configuration: configuration,
description:
'Silent Report #${DateTime.now().year}${DateTime.now().month}${DateTime.now().day}',
);
// show error report screen
return ErrorReportScreen(details);
} else {
return ErrorScreen(details);
Expand Down Expand Up @@ -244,7 +280,8 @@ void backgroundHeadlessTask(HeadlessTask task) {
LiveActivityHelper().backgroundJob();
} else {
NotificationsHelper().backgroundJob();
} BackgroundFetch.finish(task.taskId);
}
BackgroundFetch.finish(task.taskId);
}

Future<void> initAdditionalBackgroundFetch() async {
Expand Down
2 changes: 1 addition & 1 deletion refilc/lib/models/self_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TodoItem {
);
}

get toJson => {
Map<String, dynamic> get toJson => {
'id': id,
'title': title,
'content': content,
Expand Down
11 changes: 11 additions & 0 deletions refilc/lib/models/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class SettingsProvider extends ChangeNotifier {
bool _newColors;
bool _uwuMode;
bool _newPopups;
List<String> _unseenNewFeatures;
// quick settings
bool _qTimetableLessonNum;
bool _qTimetableSubTiles;
Expand Down Expand Up @@ -180,6 +181,7 @@ class SettingsProvider extends ChangeNotifier {
required bool newColors,
required bool uwuMode,
required bool newPopups,
required List<String> unseenNewFeatures,
required bool qTimetableLessonNum,
required bool qTimetableSubTiles,
required bool qSubjectsSubTiles,
Expand Down Expand Up @@ -250,6 +252,7 @@ class SettingsProvider extends ChangeNotifier {
_newColors = newColors,
_uwuMode = uwuMode,
_newPopups = newPopups,
_unseenNewFeatures = unseenNewFeatures,
_qTimetableLessonNum = qTimetableLessonNum,
_qTimetableSubTiles = qTimetableSubTiles,
_qSubjectsSubTiles = qSubjectsSubTiles;
Expand Down Expand Up @@ -339,6 +342,7 @@ class SettingsProvider extends ChangeNotifier {
newColors: map['new_colors'] == 1,
uwuMode: map['uwu_mode'] == 1,
newPopups: map['new_popups'] == 1,
unseenNewFeatures: jsonDecode(map["unseen_new_features"]).cast<String>(),
qTimetableLessonNum: map['q_timetable_lesson_num'] == 1,
qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1,
qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1,
Expand Down Expand Up @@ -416,6 +420,7 @@ class SettingsProvider extends ChangeNotifier {
"new_colors": _newColors ? 1 : 0,
"uwu_mode": _uwuMode ? 1 : 0,
"new_popups": _newPopups ? 1 : 0,
"unseen_new_features": jsonEncode(_unseenNewFeatures),
"q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0,
"q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0,
"q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0,
Expand Down Expand Up @@ -497,6 +502,7 @@ class SettingsProvider extends ChangeNotifier {
newColors: true,
uwuMode: false,
newPopups: true,
unseenNewFeatures: ['grade_exporting'],
qTimetableLessonNum: true,
qTimetableSubTiles: true,
qSubjectsSubTiles: true,
Expand Down Expand Up @@ -569,6 +575,7 @@ class SettingsProvider extends ChangeNotifier {
bool get newColors => _newColors;
bool get uwuMode => _uwuMode;
bool get newPopups => _newPopups;
List<String> get unseenNewFeatures => _unseenNewFeatures;
bool get qTimetableLessonNum => _qTimetableLessonNum;
bool get qTimetableSubTiles => _qTimetableSubTiles;
bool get qSubjectsSubTiles => _qSubjectsSubTiles;
Expand Down Expand Up @@ -637,6 +644,7 @@ class SettingsProvider extends ChangeNotifier {
bool? newColors,
bool? uwuMode,
bool? newPopups,
List<String>? unseenNewFeatures,
bool? qTimetableLessonNum,
bool? qTimetableSubTiles,
bool? qSubjectsSubTiles,
Expand Down Expand Up @@ -828,6 +836,9 @@ class SettingsProvider extends ChangeNotifier {
if (newPopups != null && newPopups != _newPopups) {
_newPopups = newPopups;
}
if (unseenNewFeatures != null && unseenNewFeatures != _unseenNewFeatures) {
_unseenNewFeatures = unseenNewFeatures;
}
if (qTimetableLessonNum != null &&
qTimetableLessonNum != _qTimetableLessonNum) {
_qTimetableLessonNum = qTimetableLessonNum;
Expand Down
13 changes: 12 additions & 1 deletion refilc/lib/theme/observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
import 'package:home_widget/home_widget.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:shake_flutter/models/shake_theme.dart';
import 'package:shake_flutter/shake_flutter.dart';

Future<bool?> updateWidget() async {
try {
Expand All @@ -22,7 +24,9 @@ class ThemeModeObserver extends ChangeNotifier {
ThemeMode get themeMode => _themeMode;
bool get updateNavbarColor => _updateNavbarColor;

ThemeModeObserver({ThemeMode initialTheme = ThemeMode.system, bool updateNavbarColor = true})
ThemeModeObserver(
{ThemeMode initialTheme = ThemeMode.system,
bool updateNavbarColor = true})
: _themeMode = initialTheme,
_updateNavbarColor = updateNavbarColor;

Expand All @@ -31,5 +35,12 @@ class ThemeModeObserver extends ChangeNotifier {
_updateNavbarColor = updateNavbarColor;
if (Platform.isAndroid) updateWidget();
notifyListeners();

// change shake theme as well
ShakeTheme darkTheme = ShakeTheme();
darkTheme.accentColor = "#FFFFFF";
ShakeTheme lightTheme = ShakeTheme();
lightTheme.accentColor = "#000000";
Shake.setShakeTheme(mode == ThemeMode.dark ? darkTheme : lightTheme);
}
}
12 changes: 4 additions & 8 deletions refilc/lib/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ class AppTheme {
onTertiary:
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
.withOpacity(.9),
background: highlightColor,
onBackground: Colors.black.withOpacity(.9),
brightness: Brightness.light,
error: lightColors.red,
onError: Colors.white.withOpacity(.9),
Expand All @@ -141,9 +139,9 @@ class AppTheme {
indicatorColor:
accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
iconTheme:
MaterialStateProperty.all(IconThemeData(color: lightColors.text)),
WidgetStateProperty.all(IconThemeData(color: lightColors.text)),
backgroundColor: highlightColor,
labelTextStyle: MaterialStateProperty.all(TextStyle(
labelTextStyle: WidgetStateProperty.all(TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.w500,
color: lightColors.text.withOpacity(0.8),
Expand Down Expand Up @@ -250,8 +248,6 @@ class AppTheme {
onTertiary:
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
.withOpacity(.9),
background: highlightColor,
onBackground: Colors.white.withOpacity(.9),
brightness: Brightness.dark,
error: darkColors.red,
onError: Colors.black.withOpacity(.9),
Expand All @@ -266,9 +262,9 @@ class AppTheme {
indicatorColor:
accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
iconTheme:
MaterialStateProperty.all(IconThemeData(color: darkColors.text)),
WidgetStateProperty.all(IconThemeData(color: darkColors.text)),
backgroundColor: highlightColor,
labelTextStyle: MaterialStateProperty.all(TextStyle(
labelTextStyle: WidgetStateProperty.all(TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.w500,
color: darkColors.text.withOpacity(0.8),
Expand Down
2 changes: 1 addition & 1 deletion refilc/lib/ui/filter/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Widget filterItemBuilder(
? const EdgeInsets.symmetric(vertical: 8.0)
: const EdgeInsets.symmetric(vertical: 4.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(
top: separated || isAfterSeparated
? const Radius.circular(16.0)
Expand Down
2 changes: 1 addition & 1 deletion refilc/lib/ui/flutter_colorpicker/palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class ColorPickerInputState extends State<ColorPickerInput> {
controller: textEditingController,
style: TextStyle(
fontSize: 18,
color: Theme.of(context).colorScheme.onBackground,
color: Theme.of(context).colorScheme.onSurface,
),
inputFormatters: [
UpperCaseTextFormatter(),
Expand Down
Loading

0 comments on commit 4a45131

Please sign in to comment.