did everything, like really
This commit is contained in:
parent
6d8d11cd87
commit
25a72da3a8
@ -1,8 +1,5 @@
|
|||||||
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:refilc/api/providers/liveactivity/platform_channel.dart';
|
import 'package:refilc/api/providers/liveactivity/platform_channel.dart';
|
||||||
import 'package:refilc/helpers/subject.dart';
|
import 'package:refilc/helpers/subject.dart';
|
||||||
import 'package:refilc/models/settings.dart';
|
import 'package:refilc/models/settings.dart';
|
||||||
@ -39,13 +36,11 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
//
|
//
|
||||||
|
|
||||||
LiveCardState currentState = LiveCardState.empty;
|
LiveCardState currentState = LiveCardState.empty;
|
||||||
late Timer _timer;
|
|
||||||
late final TimetableProvider _timetable;
|
late final TimetableProvider _timetable;
|
||||||
late final SettingsProvider _settings;
|
late final SettingsProvider _settings;
|
||||||
|
|
||||||
late Duration _delay;
|
late Duration _delay;
|
||||||
|
|
||||||
|
|
||||||
bool _hasCheckedTimetable = false;
|
bool _hasCheckedTimetable = false;
|
||||||
|
|
||||||
LiveCardProvider({
|
LiveCardProvider({
|
||||||
@ -53,7 +48,6 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
required SettingsProvider settings,
|
required SettingsProvider settings,
|
||||||
}) : _timetable = timetable,
|
}) : _timetable = timetable,
|
||||||
_settings = settings {
|
_settings = settings {
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
|
|
||||||
_delay = settings.bellDelayEnabled
|
_delay = settings.bellDelayEnabled
|
||||||
? Duration(seconds: settings.bellDelay)
|
? Duration(seconds: settings.bellDelay)
|
||||||
: Duration.zero;
|
: Duration.zero;
|
||||||
@ -94,12 +88,17 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
"title": "Első órádig:",
|
"title": "Első órádig:",
|
||||||
"subtitle": "",
|
"subtitle": "",
|
||||||
"description": "",
|
"description": "",
|
||||||
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",
|
"startDate": storeFirstRunDate != null
|
||||||
|
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||||
|
(_delay.inMilliseconds))
|
||||||
|
.toString()
|
||||||
|
: "",
|
||||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||||
_delay.inMilliseconds)
|
_delay.inMilliseconds)
|
||||||
.toString(),
|
.toString(),
|
||||||
"nextSubject": nextLesson != null
|
"nextSubject": nextLesson != null
|
||||||
? nextLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
? nextLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||||
: "",
|
: "",
|
||||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
};
|
};
|
||||||
@ -114,12 +113,17 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
"title": "Első órádig:",
|
"title": "Első órádig:",
|
||||||
"subtitle": "",
|
"subtitle": "",
|
||||||
"description": "",
|
"description": "",
|
||||||
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",
|
"startDate": storeFirstRunDate != null
|
||||||
|
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||||
|
(_delay.inMilliseconds))
|
||||||
|
.toString()
|
||||||
|
: "",
|
||||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||||
_delay.inMilliseconds)
|
_delay.inMilliseconds)
|
||||||
.toString(),
|
.toString(),
|
||||||
"nextSubject": nextLesson != null
|
"nextSubject": nextLesson != null
|
||||||
? nextLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
? nextLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||||
: "",
|
: "",
|
||||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
};
|
};
|
||||||
@ -134,12 +138,17 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
"title": "Első órádig:",
|
"title": "Első órádig:",
|
||||||
"subtitle": "",
|
"subtitle": "",
|
||||||
"description": "",
|
"description": "",
|
||||||
"startDate": storeFirstRunDate != null ? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) - (_delay.inMilliseconds)).toString(): "",
|
"startDate": storeFirstRunDate != null
|
||||||
|
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||||
|
(_delay.inMilliseconds))
|
||||||
|
.toString()
|
||||||
|
: "",
|
||||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||||
_delay.inMilliseconds)
|
_delay.inMilliseconds)
|
||||||
.toString(),
|
.toString(),
|
||||||
"nextSubject": nextLesson != null
|
"nextSubject": nextLesson != null
|
||||||
? nextLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
? nextLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||||
: "",
|
: "",
|
||||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
};
|
};
|
||||||
@ -154,7 +163,9 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
"index":
|
"index":
|
||||||
currentLesson != null ? '${currentLesson!.lessonIndex}. ' : "",
|
currentLesson != null ? '${currentLesson!.lessonIndex}. ' : "",
|
||||||
"title": currentLesson != null
|
"title": currentLesson != null
|
||||||
? currentLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: currentLesson?.subject).capital()
|
? currentLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: currentLesson?.subject)
|
||||||
|
.capital()
|
||||||
: "",
|
: "",
|
||||||
"subtitle": currentLesson?.room.replaceAll("_", " ") ?? "",
|
"subtitle": currentLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
"description": currentLesson?.description ?? "",
|
"description": currentLesson?.description ?? "",
|
||||||
@ -165,7 +176,8 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
_delay.inMilliseconds)
|
_delay.inMilliseconds)
|
||||||
.toString(),
|
.toString(),
|
||||||
"nextSubject": nextLesson != null
|
"nextSubject": nextLesson != null
|
||||||
? nextLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
? nextLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||||
: "",
|
: "",
|
||||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
};
|
};
|
||||||
@ -194,7 +206,9 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
_delay.inMilliseconds)
|
_delay.inMilliseconds)
|
||||||
.toString(),
|
.toString(),
|
||||||
"nextSubject": (nextLesson != null
|
"nextSubject": (nextLesson != null
|
||||||
? nextLesson?.subject.renamedTo ?? ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
? nextLesson?.subject.renamedTo ??
|
||||||
|
ShortSubject.resolve(subject: nextLesson?.subject)
|
||||||
|
.capital()
|
||||||
: "")
|
: "")
|
||||||
.capital(),
|
.capital(),
|
||||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||||
@ -219,12 +233,12 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
? Duration(seconds: _settings.bellDelay)
|
? Duration(seconds: _settings.bellDelay)
|
||||||
: Duration.zero;
|
: Duration.zero;
|
||||||
|
|
||||||
|
|
||||||
DateTime now = _now().add(_delay);
|
DateTime now = _now().add(_delay);
|
||||||
|
|
||||||
if ((currentState == LiveCardState.morning ||
|
if ((currentState == LiveCardState.morning ||
|
||||||
currentState == LiveCardState.afternoon ||
|
currentState == LiveCardState.afternoon ||
|
||||||
currentState == LiveCardState.night) && storeFirstRunDate == null) {
|
currentState == LiveCardState.night) &&
|
||||||
|
storeFirstRunDate == null) {
|
||||||
storeFirstRunDate = now;
|
storeFirstRunDate = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,22 +305,21 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
//LIVE ACTIVITIES
|
//LIVE ACTIVITIES
|
||||||
|
|
||||||
//CREATE
|
//CREATE
|
||||||
if (!hasActivityStarted && nextLesson != null && nextLesson!
|
if (!hasActivityStarted &&
|
||||||
.start
|
nextLesson != null &&
|
||||||
.difference(now)
|
nextLesson!.start.difference(now).inMinutes <= 60 &&
|
||||||
.inMinutes <= 60 && (currentState == LiveCardState.morning ||
|
(currentState == LiveCardState.morning ||
|
||||||
currentState == LiveCardState.afternoon ||
|
currentState == LiveCardState.afternoon ||
|
||||||
currentState == LiveCardState.night)) {
|
currentState == LiveCardState.night)) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"Az első óra előtt állunk, kevesebb mint egy órával. Létrehozás...");
|
"Az első óra előtt állunk, kevesebb mint egy órával. Létrehozás...");
|
||||||
PlatformChannel.createLiveActivity(toMap());
|
PlatformChannel.createLiveActivity(toMap());
|
||||||
hasActivityStarted = true;
|
hasActivityStarted = true;
|
||||||
}
|
} else if (!hasActivityStarted &&
|
||||||
else if (!hasActivityStarted && ((currentState == LiveCardState.duringLesson &&
|
((currentState == LiveCardState.duringLesson &&
|
||||||
currentLesson != null) ||
|
currentLesson != null) ||
|
||||||
currentState == LiveCardState.duringBreak)) {
|
currentState == LiveCardState.duringBreak)) {
|
||||||
debugPrint(
|
debugPrint("Óra van, vagy szünet, de nincs LiveActivity. létrehozás...");
|
||||||
"Óra van, vagy szünet, de nincs LiveActivity. létrehozás...");
|
|
||||||
PlatformChannel.createLiveActivity(toMap());
|
PlatformChannel.createLiveActivity(toMap());
|
||||||
hasActivityStarted = true;
|
hasActivityStarted = true;
|
||||||
}
|
}
|
||||||
@ -317,15 +330,18 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
debugPrint("Valamelyik beállítás megváltozott. Frissítés...");
|
debugPrint("Valamelyik beállítás megváltozott. Frissítés...");
|
||||||
PlatformChannel.updateLiveActivity(toMap());
|
PlatformChannel.updateLiveActivity(toMap());
|
||||||
hasActivitySettingsChanged = false;
|
hasActivitySettingsChanged = false;
|
||||||
}
|
} else if (nextLesson != null || currentLesson != null) {
|
||||||
else if (nextLesson != null || currentLesson != null) {
|
|
||||||
bool afterPrevLessonEnd = prevLesson != null &&
|
bool afterPrevLessonEnd = prevLesson != null &&
|
||||||
now.subtract(const Duration(seconds: 1)).isBefore(
|
now
|
||||||
prevLesson!.end) && now.isAfter(prevLesson!.end);
|
.subtract(const Duration(seconds: 1))
|
||||||
|
.isBefore(prevLesson!.end) &&
|
||||||
|
now.isAfter(prevLesson!.end);
|
||||||
|
|
||||||
bool afterCurrentLessonStart = currentLesson != null &&
|
bool afterCurrentLessonStart = currentLesson != null &&
|
||||||
now.subtract(const Duration(seconds: 1)).isBefore(
|
now
|
||||||
currentLesson!.start) && now.isAfter(currentLesson!.start);
|
.subtract(const Duration(seconds: 1))
|
||||||
|
.isBefore(currentLesson!.start) &&
|
||||||
|
now.isAfter(currentLesson!.start);
|
||||||
if (afterPrevLessonEnd || afterCurrentLessonStart) {
|
if (afterPrevLessonEnd || afterCurrentLessonStart) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"Óra kezdete/vége után 1 másodperccel vagyunk. Frissítés...");
|
"Óra kezdete/vége után 1 másodperccel vagyunk. Frissítés...");
|
||||||
@ -335,7 +351,9 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//END
|
//END
|
||||||
if (hasActivityStarted && !hasDayEnd && nextLesson == null &&
|
if (hasActivityStarted &&
|
||||||
|
!hasDayEnd &&
|
||||||
|
nextLesson == null &&
|
||||||
now.isAfter(prevLesson!.end)) {
|
now.isAfter(prevLesson!.end)) {
|
||||||
debugPrint("Az utolsó óra véget ért. Befejezés...");
|
debugPrint("Az utolsó óra véget ért. Befejezés...");
|
||||||
PlatformChannel.endLiveActivity();
|
PlatformChannel.endLiveActivity();
|
||||||
|
@ -24,6 +24,10 @@ class SelfNoteProvider with ChangeNotifier {
|
|||||||
Future<void> restore() async {
|
Future<void> restore() async {
|
||||||
String? userId = Provider.of<UserProvider>(_context, listen: false).id;
|
String? userId = Provider.of<UserProvider>(_context, listen: false).id;
|
||||||
|
|
||||||
|
// await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||||
|
// .userStore
|
||||||
|
// .storeSelfNotes([], userId: userId!);
|
||||||
|
|
||||||
// load self notes from db
|
// load self notes from db
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
var dbNotes = await Provider.of<DatabaseProvider>(_context, listen: false)
|
var dbNotes = await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
|
enum NoteType { text, image }
|
||||||
|
|
||||||
class SelfNote {
|
class SelfNote {
|
||||||
String id;
|
String id;
|
||||||
String? title;
|
String? title;
|
||||||
String content;
|
String content;
|
||||||
|
NoteType noteType;
|
||||||
|
|
||||||
Map? json;
|
Map? json;
|
||||||
|
|
||||||
SelfNote({
|
SelfNote({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.title,
|
this.title,
|
||||||
required this.content,
|
required this.content,
|
||||||
|
required this.noteType,
|
||||||
this.json,
|
this.json,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -16,6 +21,7 @@ class SelfNote {
|
|||||||
id: json['id'],
|
id: json['id'],
|
||||||
title: json['title'],
|
title: json['title'],
|
||||||
content: json['content'],
|
content: json['content'],
|
||||||
|
noteType: json['note_type'] == 'image' ? NoteType.image : NoteType.text,
|
||||||
json: json,
|
json: json,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -24,5 +30,6 @@ class SelfNote {
|
|||||||
'id': id,
|
'id': id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'content': content,
|
'content': content,
|
||||||
|
'note_type': noteType == NoteType.image ? 'image' : 'text',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:refilc/models/settings.dart';
|
import 'package:refilc/models/settings.dart';
|
||||||
import 'package:refilc/theme/colors/accent.dart';
|
import 'package:refilc/theme/colors/accent.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:refilc/theme/colors/new_colors.dart';
|
|
||||||
import 'package:refilc/theme/colors/utils.dart';
|
import 'package:refilc/theme/colors/utils.dart';
|
||||||
import 'package:refilc/theme/observer.dart';
|
import 'package:refilc/theme/observer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:refilc/models/settings.dart';
|
import 'package:refilc/models/settings.dart';
|
||||||
import 'package:refilc/theme/colors/new_colors.dart';
|
|
||||||
import 'package:refilc_kreta_api/providers/exam_provider.dart';
|
import 'package:refilc_kreta_api/providers/exam_provider.dart';
|
||||||
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:googleapis/privateca/v1.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/absence.dart';
|
import 'package:refilc_kreta_api/models/absence.dart';
|
||||||
import 'package:refilc_kreta_api/models/category.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||||
import 'package:refilc_kreta_api/models/subject.dart';
|
import 'package:refilc_kreta_api/models/subject.dart';
|
||||||
import 'package:refilc_kreta_api/models/week.dart';
|
import 'package:refilc_kreta_api/models/week.dart';
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -7,22 +6,11 @@ import 'package:refilc/api/providers/user_provider.dart';
|
|||||||
import 'package:refilc/helpers/subject.dart';
|
import 'package:refilc/helpers/subject.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:refilc/theme/colors/utils.dart';
|
import 'package:refilc/theme/colors/utils.dart';
|
||||||
import 'package:refilc/utils/reverse_search.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||||
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||||
import 'package:refilc_mobile_ui/common/viewable.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/widgets/card_handle.dart';
|
|
||||||
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
||||||
import 'package:refilc_mobile_ui/common/widgets/lesson/lesson_view.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/grades/grades_page.dart';
|
|
||||||
import 'package:refilc_plus/models/premium_scopes.dart';
|
|
||||||
import 'package:refilc_plus/providers/plus_provider.dart';
|
|
||||||
import 'package:refilc_plus/ui/mobile/plus/upsell.dart';
|
|
||||||
import 'lesson_view.i18n.dart';
|
|
||||||
|
|
||||||
class LessonViewable extends StatefulWidget {
|
class LessonViewable extends StatefulWidget {
|
||||||
const LessonViewable(
|
const LessonViewable(
|
||||||
|
@ -33,7 +33,6 @@ import 'package:refilc_mobile_ui/pages/grades/fail_warning.dart';
|
|||||||
import 'package:refilc_mobile_ui/pages/grades/grades_count.dart';
|
import 'package:refilc_mobile_ui/pages/grades/grades_count.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/grades/graph.dart';
|
import 'package:refilc_mobile_ui/pages/grades/graph.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/grades/grade_subject_view.dart';
|
import 'package:refilc_mobile_ui/pages/grades/grade_subject_view.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/timetable/timetable_page.dart';
|
|
||||||
import 'package:refilc_mobile_ui/screens/navigation/navigation_route_handler.dart';
|
import 'package:refilc_mobile_ui/screens/navigation/navigation_route_handler.dart';
|
||||||
import 'package:refilc_mobile_ui/screens/navigation/navigation_screen.dart';
|
import 'package:refilc_mobile_ui/screens/navigation/navigation_screen.dart';
|
||||||
import 'package:refilc_plus/models/premium_scopes.dart';
|
import 'package:refilc_plus/models/premium_scopes.dart';
|
||||||
@ -640,27 +639,6 @@ class GradesPageState extends State<GradesPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showQuickSettings(BuildContext context) {
|
void showQuickSettings(BuildContext context) {
|
||||||
// _sheetController = _scaffoldKey.currentState?.showBottomSheet(
|
|
||||||
// (context) => RoundedBottomSheet(
|
|
||||||
// borderRadius: 14.0,
|
|
||||||
// child: BottomSheetMenu(items: [
|
|
||||||
// SwitchListTile(
|
|
||||||
// title: Text('show_lesson_num'.i18n),
|
|
||||||
// value:
|
|
||||||
// Provider.of<SettingsProvider>(context).qTimetableLessonNum,
|
|
||||||
// onChanged: (v) {
|
|
||||||
// Provider.of<SettingsProvider>(context, listen: false)
|
|
||||||
// .update(qTimetableLessonNum: v);
|
|
||||||
// })
|
|
||||||
// ])),
|
|
||||||
// backgroundColor: const Color(0x00000000),
|
|
||||||
// elevation: 12.0,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// _sheetController!.closed.then((value) {
|
|
||||||
// // Show fab and grades
|
|
||||||
// if (mounted) {}
|
|
||||||
// });
|
|
||||||
showRoundedModalBottomSheet(
|
showRoundedModalBottomSheet(
|
||||||
context,
|
context,
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
@ -161,6 +161,11 @@ class GradeGraphState extends State<GradeGraph> {
|
|||||||
final x = halfYearGrade.writeDate.month +
|
final x = halfYearGrade.writeDate.month +
|
||||||
(halfYearGrade.writeDate.day / 31) +
|
(halfYearGrade.writeDate.day / 31) +
|
||||||
((halfYearGrade.writeDate.year - data.last.writeDate.year) * 12);
|
((halfYearGrade.writeDate.year - data.last.writeDate.year) * 12);
|
||||||
|
|
||||||
|
List<Grade> dataBeforeMidYr = data
|
||||||
|
.where((e) => e.writeDate.isBefore(halfYearGrade.writeDate))
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (x <= maxX) {
|
if (x <= maxX) {
|
||||||
extraLinesV.add(
|
extraLinesV.add(
|
||||||
VerticalLine(
|
VerticalLine(
|
||||||
@ -170,7 +175,9 @@ class GradeGraphState extends State<GradeGraph> {
|
|||||||
label: VerticalLineLabel(
|
label: VerticalLineLabel(
|
||||||
labelResolver: (_) => " ${"mid".i18n} ", // <- zwsp for padding
|
labelResolver: (_) => " ${"mid".i18n} ", // <- zwsp for padding
|
||||||
show: true,
|
show: true,
|
||||||
alignment: Alignment.topLeft,
|
alignment: dataBeforeMidYr.length < 2
|
||||||
|
? Alignment.topRight
|
||||||
|
: Alignment.topLeft,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
color: AppColors.of(context).text,
|
color: AppColors.of(context).text,
|
||||||
@ -218,11 +225,12 @@ class GradeGraphState extends State<GradeGraph> {
|
|||||||
horizontalLines: extraLinesH),
|
horizontalLines: extraLinesH),
|
||||||
lineBarsData: [
|
lineBarsData: [
|
||||||
LineChartBarData(
|
LineChartBarData(
|
||||||
preventCurveOverShooting: true,
|
preventCurveOverShooting: false,
|
||||||
spots: subjectSpots,
|
spots: subjectSpots,
|
||||||
isCurved: true,
|
isCurved: true,
|
||||||
colors: averageColors.reversed.toList(),
|
colors: averageColors.reversed.toList(),
|
||||||
barWidth: 8,
|
barWidth: 6,
|
||||||
|
curveSmoothness: 0.2,
|
||||||
isStrokeCapRound: true,
|
isStrokeCapRound: true,
|
||||||
dotData: FlDotData(show: false),
|
dotData: FlDotData(show: false),
|
||||||
belowBarData: BarAreaData(
|
belowBarData: BarAreaData(
|
||||||
@ -339,11 +347,13 @@ class GradeGraphState extends State<GradeGraph> {
|
|||||||
ghostData.isNotEmpty ? ghostData : data;
|
ghostData.isNotEmpty ? ghostData : data;
|
||||||
tData.sort((a, b) =>
|
tData.sort((a, b) =>
|
||||||
a.writeDate.compareTo(b.writeDate));
|
a.writeDate.compareTo(b.writeDate));
|
||||||
return tData.first.writeDate
|
return ghostData.isNotEmpty
|
||||||
|
? 3.0
|
||||||
|
: tData.first.writeDate
|
||||||
.add(const Duration(days: 120))
|
.add(const Duration(days: 120))
|
||||||
.isBefore(tData.last.writeDate)
|
.isBefore(tData.last.writeDate)
|
||||||
? 2.0
|
? 2.0
|
||||||
: 1.0;
|
: 2.5;
|
||||||
}(),
|
}(),
|
||||||
checkToShowTitle: (double minValue,
|
checkToShowTitle: (double minValue,
|
||||||
double maxValue,
|
double maxValue,
|
||||||
|
@ -6,17 +6,9 @@ import 'package:refilc/helpers/subject.dart';
|
|||||||
import 'package:refilc/models/settings.dart';
|
import 'package:refilc/models/settings.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
||||||
import 'package:refilc_kreta_api/models/category.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/subject.dart';
|
|
||||||
import 'package:refilc_kreta_api/models/teacher.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||||
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
||||||
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||||
// import 'package:refilc_kreta_api/models/category.dart';
|
|
||||||
// import 'package:refilc_kreta_api/models/lesson.dart';
|
|
||||||
// import 'package:refilc_kreta_api/models/subject.dart';
|
|
||||||
// import 'package:refilc_kreta_api/models/teacher.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/home/live_card/heads_up_countdown.dart';
|
import 'package:refilc_mobile_ui/pages/home/live_card/heads_up_countdown.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/home/live_card/segmented_countdown.dart';
|
import 'package:refilc_mobile_ui/pages/home/live_card/segmented_countdown.dart';
|
||||||
@ -94,7 +86,7 @@ class LiveCardStateA extends State<LiveCard> {
|
|||||||
name: 'name',
|
name: 'name',
|
||||||
);*/
|
);*/
|
||||||
|
|
||||||
liveCard.nextLesson = liveCard.currentLesson;
|
// liveCard.nextLesson = liveCard.currentLesson;
|
||||||
|
|
||||||
// final dt = DateTime(2024, 3, 22, 17, 12, 1, 1, 1);
|
// final dt = DateTime(2024, 3, 22, 17, 12, 1, 1, 1);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// ignore_for_file: no_leading_underscores_for_local_identifiers, use_build_context_synchronously
|
// ignore_for_file: no_leading_underscores_for_local_identifiers, use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@ -7,6 +8,8 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
|||||||
import 'package:refilc/api/providers/database_provider.dart';
|
import 'package:refilc/api/providers/database_provider.dart';
|
||||||
import 'package:refilc/api/providers/self_note_provider.dart';
|
import 'package:refilc/api/providers/self_note_provider.dart';
|
||||||
import 'package:refilc/api/providers/update_provider.dart';
|
import 'package:refilc/api/providers/update_provider.dart';
|
||||||
|
import 'package:refilc/models/self_note.dart';
|
||||||
|
import 'package:refilc/models/settings.dart';
|
||||||
import 'package:refilc/utils/format.dart';
|
import 'package:refilc/utils/format.dart';
|
||||||
import 'package:refilc_kreta_api/models/absence.dart';
|
import 'package:refilc_kreta_api/models/absence.dart';
|
||||||
import 'package:refilc_kreta_api/models/homework.dart';
|
import 'package:refilc_kreta_api/models/homework.dart';
|
||||||
@ -14,6 +17,8 @@ import 'package:refilc_kreta_api/models/subject.dart';
|
|||||||
import 'package:refilc/api/providers/user_provider.dart';
|
import 'package:refilc/api/providers/user_provider.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/bottom_sheet_menu.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||||
import 'package:refilc_mobile_ui/common/profile_image/profile_button.dart';
|
import 'package:refilc_mobile_ui/common/profile_image/profile_button.dart';
|
||||||
@ -23,6 +28,7 @@ import 'package:refilc_mobile_ui/common/widgets/tick_tile.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/notes/submenu/add_note_screen.dart';
|
import 'package:refilc_mobile_ui/pages/notes/submenu/add_note_screen.dart';
|
||||||
|
import 'package:refilc_mobile_ui/pages/notes/submenu/create_image_note.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/notes/submenu/note_view_screen.dart';
|
import 'package:refilc_mobile_ui/pages/notes/submenu/note_view_screen.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/notes/submenu/self_note_tile.dart';
|
import 'package:refilc_mobile_ui/pages/notes/submenu/self_note_tile.dart';
|
||||||
import 'package:refilc_plus/models/premium_scopes.dart';
|
import 'package:refilc_plus/models/premium_scopes.dart';
|
||||||
@ -114,12 +120,36 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
if (selfNoteProvider.notes.isNotEmpty) {
|
if (selfNoteProvider.notes.isNotEmpty) {
|
||||||
selfNoteTiles.addAll(selfNoteProvider.notes.reversed.map(
|
selfNoteTiles.addAll(selfNoteProvider.notes.reversed.map(
|
||||||
(e) => SelfNoteTile(
|
(e) => e.noteType == NoteType.text
|
||||||
|
? SelfNoteTile(
|
||||||
title: e.title ?? e.content.split(' ')[0],
|
title: e.title ?? e.content.split(' ')[0],
|
||||||
content: e.content,
|
content: e.content,
|
||||||
onTap: () => Navigator.of(context, rootNavigator: true).push(
|
onTap: () => Navigator.of(context, rootNavigator: true).push(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => NoteViewScreen(note: e))),
|
builder: (context) => NoteViewScreen(note: e))),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
height: MediaQuery.of(context).size.width / 2.42,
|
||||||
|
width: MediaQuery.of(context).size.width / 2.42,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
boxShadow: [
|
||||||
|
if (Provider.of<SettingsProvider>(context, listen: false)
|
||||||
|
.shadowEffect)
|
||||||
|
BoxShadow(
|
||||||
|
offset: const Offset(0, 21),
|
||||||
|
blurRadius: 23.0,
|
||||||
|
color: Theme.of(context).shadowColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(16.0),
|
||||||
|
child: Image.memory(
|
||||||
|
const Base64Decoder().convert(e.content),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
gaplessPlayback: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -235,9 +265,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
|||||||
feature: PremiumFeature.selfNotes);
|
feature: PremiumFeature.selfNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.of(context, rootNavigator: true).push(
|
showCreationModal(context);
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => const AddNoteScreen()));
|
|
||||||
},
|
},
|
||||||
child: Icon(
|
child: Icon(
|
||||||
FeatherIcons.plus,
|
FeatherIcons.plus,
|
||||||
@ -312,4 +340,77 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showCreationModal(BuildContext context) {
|
||||||
|
// _sheetController = _scaffoldKey.currentState?.showBottomSheet(
|
||||||
|
// (context) => RoundedBottomSheet(
|
||||||
|
// borderRadius: 14.0,
|
||||||
|
// child: BottomSheetMenu(items: [
|
||||||
|
// SwitchListTile(
|
||||||
|
// title: Text('show_lesson_num'.i18n),
|
||||||
|
// value:
|
||||||
|
// Provider.of<SettingsProvider>(context).qTimetableLessonNum,
|
||||||
|
// onChanged: (v) {
|
||||||
|
// Provider.of<SettingsProvider>(context, listen: false)
|
||||||
|
// .update(qTimetableLessonNum: v);
|
||||||
|
// })
|
||||||
|
// ])),
|
||||||
|
// backgroundColor: const Color(0x00000000),
|
||||||
|
// elevation: 12.0,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// _sheetController!.closed.then((value) {
|
||||||
|
// // Show fab and grades
|
||||||
|
// if (mounted) {}
|
||||||
|
// });
|
||||||
|
showRoundedModalBottomSheet(
|
||||||
|
context,
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
child: BottomSheetMenu(items: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
color: Theme.of(context).colorScheme.background),
|
||||||
|
child: ListTile(
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.sticky_note_2_outlined),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10.0,
|
||||||
|
),
|
||||||
|
Text('new_note'.i18n),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.of(context, rootNavigator: true).push(
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => const AddNoteScreen())),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
color: Theme.of(context).colorScheme.background),
|
||||||
|
child: ListTile(
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.photo_library_outlined),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10.0,
|
||||||
|
),
|
||||||
|
Text('new_image'.i18n),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => ImageNoteEditor(user.user!));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ extension ScreensLocalization on String {
|
|||||||
"hint": "Note content...",
|
"hint": "Note content...",
|
||||||
"hint_t": "Note title...",
|
"hint_t": "Note title...",
|
||||||
"your_notes": "Your Notes",
|
"your_notes": "Your Notes",
|
||||||
|
"new_image": "New Image",
|
||||||
},
|
},
|
||||||
"hu_hu": {
|
"hu_hu": {
|
||||||
"notes": "Füzet",
|
"notes": "Füzet",
|
||||||
@ -24,6 +25,7 @@ extension ScreensLocalization on String {
|
|||||||
"hint": "Jegyzet tartalma...",
|
"hint": "Jegyzet tartalma...",
|
||||||
"hint_t": "Jegyzet címe...",
|
"hint_t": "Jegyzet címe...",
|
||||||
"your_notes": "Jegyzeteid",
|
"your_notes": "Jegyzeteid",
|
||||||
|
"new_image": "Új kép",
|
||||||
},
|
},
|
||||||
"de_de": {
|
"de_de": {
|
||||||
"notes": "Broschüre",
|
"notes": "Broschüre",
|
||||||
@ -35,6 +37,7 @@ extension ScreensLocalization on String {
|
|||||||
"hint": "Inhalt beachten...",
|
"hint": "Inhalt beachten...",
|
||||||
"hint_t": "Titel notieren...",
|
"hint_t": "Titel notieren...",
|
||||||
"your_notes": "Deine Noten",
|
"your_notes": "Deine Noten",
|
||||||
|
"new_image": "Neues Bild",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,7 +153,8 @@ class AddNoteScreenState extends State<AddNoteScreen> {
|
|||||||
'title': _titleController.text.replaceAll(' ', '') == ''
|
'title': _titleController.text.replaceAll(' ', '') == ''
|
||||||
? null
|
? null
|
||||||
: _titleController.text,
|
: _titleController.text,
|
||||||
'content': _contentController.text
|
'content': _contentController.text,
|
||||||
|
'note_type': 'text',
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
var i =
|
var i =
|
||||||
@ -165,6 +166,7 @@ class AddNoteScreenState extends State<AddNoteScreen> {
|
|||||||
? null
|
? null
|
||||||
: _titleController.text,
|
: _titleController.text,
|
||||||
'content': _contentController.text,
|
'content': _contentController.text,
|
||||||
|
'note_type': 'text',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
214
refilc_mobile_ui/lib/pages/notes/submenu/create_image_note.dart
Normal file
214
refilc_mobile_ui/lib/pages/notes/submenu/create_image_note.dart
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:image_crop/image_crop.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:refilc/api/providers/database_provider.dart';
|
||||||
|
import 'package:refilc/api/providers/self_note_provider.dart';
|
||||||
|
import 'package:refilc/models/self_note.dart';
|
||||||
|
import 'package:refilc/models/user.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
import 'notes_screen.i18n.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class ImageNoteEditor extends StatefulWidget {
|
||||||
|
late User u;
|
||||||
|
|
||||||
|
ImageNoteEditor(this.u, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ImageNoteEditor> createState() => _ImageNoteEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ImageNoteEditorState extends State<ImageNoteEditor> {
|
||||||
|
final cropKey = GlobalKey<CropState>();
|
||||||
|
File? _file;
|
||||||
|
File? _sample;
|
||||||
|
File? _lastCropped;
|
||||||
|
|
||||||
|
File? image;
|
||||||
|
Future pickImage() async {
|
||||||
|
try {
|
||||||
|
final image = await ImagePicker().pickImage(source: ImageSource.gallery);
|
||||||
|
if (image == null) return;
|
||||||
|
File imageFile = File(image.path);
|
||||||
|
|
||||||
|
final sample = await ImageCrop.sampleImage(
|
||||||
|
file: imageFile,
|
||||||
|
preferredSize: context.size!.longestSide.ceil(),
|
||||||
|
);
|
||||||
|
|
||||||
|
_sample?.delete();
|
||||||
|
_file?.delete();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_sample = sample;
|
||||||
|
_file = imageFile;
|
||||||
|
});
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
log('Failed to pick image: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget cropImageWidget() {
|
||||||
|
return SizedBox(
|
||||||
|
height: 300,
|
||||||
|
child: Crop.file(
|
||||||
|
_sample!,
|
||||||
|
key: cropKey,
|
||||||
|
aspectRatio: 1.0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget openImageWidget() {
|
||||||
|
return InkWell(
|
||||||
|
customBorder: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14.0),
|
||||||
|
),
|
||||||
|
onTap: () => pickImage(),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: Colors.grey),
|
||||||
|
borderRadius: BorderRadius.circular(14.0),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 8.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"click_here".i18n,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22.0,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"select_image".i18n,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _cropImage() async {
|
||||||
|
final scale = cropKey.currentState!.scale;
|
||||||
|
final area = cropKey.currentState!.area;
|
||||||
|
if (area == null || _file == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final sample = await ImageCrop.sampleImage(
|
||||||
|
file: _file!,
|
||||||
|
preferredSize: (2000 / scale).round(),
|
||||||
|
);
|
||||||
|
|
||||||
|
final file = await ImageCrop.cropImage(
|
||||||
|
file: sample,
|
||||||
|
area: area,
|
||||||
|
);
|
||||||
|
|
||||||
|
sample.delete();
|
||||||
|
|
||||||
|
_lastCropped?.delete();
|
||||||
|
_lastCropped = file;
|
||||||
|
|
||||||
|
List<int> imageBytes = await _lastCropped!.readAsBytes();
|
||||||
|
String base64Image = base64Encode(imageBytes);
|
||||||
|
|
||||||
|
List<SelfNote> selfNotes =
|
||||||
|
await Provider.of<DatabaseProvider>(context, listen: false)
|
||||||
|
.userQuery
|
||||||
|
.getSelfNotes(userId: widget.u.id);
|
||||||
|
|
||||||
|
selfNotes.add(SelfNote.fromJson({
|
||||||
|
'id': const Uuid().v4(),
|
||||||
|
'content': base64Image,
|
||||||
|
'note_type': 'image'
|
||||||
|
}));
|
||||||
|
|
||||||
|
await Provider.of<DatabaseProvider>(context, listen: false)
|
||||||
|
.userStore
|
||||||
|
.storeSelfNotes(selfNotes, userId: widget.u.id);
|
||||||
|
|
||||||
|
Provider.of<SelfNoteProvider>(context, listen: false).restore();
|
||||||
|
|
||||||
|
debugPrint('$file');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_file?.delete();
|
||||||
|
_sample?.delete();
|
||||||
|
_lastCropped?.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(14.0))),
|
||||||
|
contentPadding: const EdgeInsets.only(top: 10.0),
|
||||||
|
title: Text("new_image".i18n),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
|
||||||
|
child: _sample == null ? openImageWidget() : cropImageWidget(),
|
||||||
|
),
|
||||||
|
// if (widget.u.picture != "")
|
||||||
|
// TextButton(
|
||||||
|
// child: Text(
|
||||||
|
// "remove_profile_picture".i18n,
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontWeight: FontWeight.w500, color: Colors.red),
|
||||||
|
// ),
|
||||||
|
// onPressed: () {
|
||||||
|
// widget.u.picture = "";
|
||||||
|
// Provider.of<DatabaseProvider>(context, listen: false)
|
||||||
|
// .store
|
||||||
|
// .storeUser(widget.u);
|
||||||
|
// Provider.of<UserProvider>(context, listen: false).refresh();
|
||||||
|
// Navigator.of(context).pop(true);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: Text(
|
||||||
|
"cancel".i18n,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).maybePop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: Text(
|
||||||
|
"next".i18n,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
await _cropImage();
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,11 @@ extension SettingsLocalization on String {
|
|||||||
"hint": "Note content...",
|
"hint": "Note content...",
|
||||||
"hint_t": "Note title...",
|
"hint_t": "Note title...",
|
||||||
"your_notes": "Your Notes",
|
"your_notes": "Your Notes",
|
||||||
|
"next": "Next",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"click_here": "Click here",
|
||||||
|
"select_image": "to select an image",
|
||||||
|
"new_image": "New Image",
|
||||||
},
|
},
|
||||||
"hu_hu": {
|
"hu_hu": {
|
||||||
"notes": "Füzet",
|
"notes": "Füzet",
|
||||||
@ -24,6 +29,11 @@ extension SettingsLocalization on String {
|
|||||||
"hint": "Jegyzet tartalma...",
|
"hint": "Jegyzet tartalma...",
|
||||||
"hint_t": "Jegyzet címe...",
|
"hint_t": "Jegyzet címe...",
|
||||||
"your_notes": "Jegyzeteid",
|
"your_notes": "Jegyzeteid",
|
||||||
|
"next": "Tovább",
|
||||||
|
"cancel": "Mégse",
|
||||||
|
"click_here": "Kattints ide",
|
||||||
|
"select_image": "kép kiválasztásához",
|
||||||
|
"new_image": "Új kép",
|
||||||
},
|
},
|
||||||
"de_de": {
|
"de_de": {
|
||||||
"notes": "Broschüre",
|
"notes": "Broschüre",
|
||||||
@ -35,6 +45,11 @@ extension SettingsLocalization on String {
|
|||||||
"hint": "Inhalt beachten...",
|
"hint": "Inhalt beachten...",
|
||||||
"hint_t": "Titel notieren...",
|
"hint_t": "Titel notieren...",
|
||||||
"your_notes": "Deine Noten",
|
"your_notes": "Deine Noten",
|
||||||
|
"next": "Weiter",
|
||||||
|
"cancel": "Abbrechen",
|
||||||
|
"click_here": "Klicken Sie hier",
|
||||||
|
"select_image": "um ein Bild auszuwählen",
|
||||||
|
"new_image": "Neues Bild",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import 'package:refilc/api/providers/user_provider.dart';
|
|||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
import 'package:refilc_kreta_api/models/lesson.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.dart';
|
||||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/bottom_sheet_menu_item.dart';
|
|
||||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||||
import 'package:refilc_mobile_ui/common/dot.dart';
|
import 'package:refilc_mobile_ui/common/dot.dart';
|
||||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||||
@ -73,8 +72,6 @@ class TimetablePageState extends State<TimetablePage>
|
|||||||
with TickerProviderStateMixin, WidgetsBindingObserver {
|
with TickerProviderStateMixin, WidgetsBindingObserver {
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
PersistentBottomSheetController? _sheetController;
|
|
||||||
|
|
||||||
late UserProvider user;
|
late UserProvider user;
|
||||||
late TimetableProvider timetableProvider;
|
late TimetableProvider timetableProvider;
|
||||||
late UpdateProvider updateProvider;
|
late UpdateProvider updateProvider;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user