- Fixed UI/UX bugs in the Live Activities

- Fixed the unhandled language get, when the Live Activity is turned off
- Fixed bellDelay bugs
This commit is contained in:
Horváth Gergely
2025-11-26 05:05:14 +01:00
parent 6d33f6b0d8
commit ea8315a993
5 changed files with 106 additions and 68 deletions

View File

@@ -31,6 +31,7 @@ class LiveActivityBackendClient {
required String deviceToken,
required List<Lesson> timetable,
String? language,
double? bellDelay,
}) async {
try {
final lessonsData = timetable.map((lesson) {
@@ -66,6 +67,10 @@ class LiveActivityBackendClient {
requestData['language'] = language;
}
if (bellDelay != null) {
requestData['bellDelay'] = bellDelay;
}
_logger.info('Registering device with backend. Sending ${lessonsData.length} lessons.');
if (_logger.isLoggable(Level.FINE)) {
lessonsData.forEach((lesson) => _logger.fine(' Lesson data: ${lesson}'));
@@ -93,6 +98,7 @@ class LiveActivityBackendClient {
Future<bool> updateTimetable({
required String deviceToken,
required List<Lesson> timetable,
double? bellDelay,
}) async {
try {
final lessonsData = timetable.map((lesson) {
@@ -100,7 +106,7 @@ class LiveActivityBackendClient {
if (validLastModified.year < 1900) {
validLastModified = lesson.start;
}
return {
'uid': lesson.uid,
'date': lesson.date,
@@ -123,13 +129,19 @@ class LiveActivityBackendClient {
lessonsData.forEach((lesson) => _logger.fine(' Lesson data: ${lesson}'));
}
final requestData = {
'deviceToken': deviceToken,
'lessons': lessonsData,
'lastUpdated': DateTime.now().toIso8601String(),
};
if (bellDelay != null) {
requestData['bellDelay'] = bellDelay;
}
final response = await _dio.put(
'/live-activity/timetable',
data: {
'deviceToken': deviceToken,
'lessons': lessonsData,
'lastUpdated': DateTime.now().toIso8601String(),
},
data: requestData,
);
if (response.statusCode == 200) {

View File

@@ -34,6 +34,21 @@ class LiveActivityService {
static double? _lastSentBellDelay;
static const Duration _bellDelayDebounceInterval = Duration(seconds: 5);
/// Get current bellDelay value from settings
static double? _getCurrentBellDelay() {
try {
if (!initDone || initData.settings == null) {
return null;
}
final bellDelaySetting = initData.settings.group("settings")
.subGroup("application")["bell_delay"] as SettingsDouble?;
return bellDelaySetting?.value;
} catch (e) {
_logger.warning('Error getting current bellDelay: $e');
return null;
}
}
/// Get current user's studentId for user-specific settings
/// If client is provided, use it directly instead of initData.client
static String? _getCurrentStudentId({KretaClient? client}) {
@@ -158,6 +173,12 @@ class LiveActivityService {
try {
if (!Platform.isIOS) return;
final isEnabled = await _getUserLiveActivityEnabled();
if (!isEnabled) {
_logger.fine('Skipping language update: Live Activity is disabled');
return;
}
final prefs = await SharedPreferences.getInstance();
final deviceToken = prefs.getString(_deviceTokenKey);
@@ -374,6 +395,7 @@ class LiveActivityService {
final success = await _backendClient.updateTimetable(
deviceToken: deviceToken,
timetable: allLessons,
bellDelay: _getCurrentBellDelay(),
);
if (success) {
@@ -663,6 +685,7 @@ class LiveActivityService {
deviceToken: deviceToken,
timetable: allLessons,
language: currentLanguage,
bellDelay: _getCurrentBellDelay(),
);
if (success) {
@@ -849,6 +872,7 @@ class LiveActivityService {
final success = await _backendClient.updateTimetable(
deviceToken: deviceToken,
timetable: allLessons,
bellDelay: _getCurrentBellDelay(),
);
if (success) {

View File

@@ -117,10 +117,10 @@ class _FullPrivacyPolicyScreenState extends FirkaState<FullPrivacyPolicyScreen>
style:
appStyle.fonts.H_16px.apply(color: appStyle.colors.textPrimary),
),
SizedBox(height: 8),
SizedBox(height: 10),
Text(
body,
style: appStyle.fonts.B_14R
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textSecondary),
),
],

View File

@@ -118,7 +118,7 @@ class _LiveActivityConsentScreenState
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textPrimary),
),
SizedBox(height: 16),
SizedBox(height: 20),
_buildPrivacySummaryItem(
icon: Majesticon.editPen4Solid,
title: widget.data.l10n.la_privacy_section1_title,
@@ -144,18 +144,19 @@ class _LiveActivityConsentScreenState
FullPrivacyPolicyScreen(data: widget.data)));
},
child: FirkaCard(
left: [
color: appStyle.colors.buttonSecondaryFill,
left: [],
center: [
Text(
widget.data.l10n.la_learn_more,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.accent),
.apply(color: appStyle.colors.textSecondary),
),
],
right: [
SizedBox(width: 8),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.chevronRightLine,
color: appStyle.colors.accent,
color: appStyle.colors.textSecondary,
),
],
),
@@ -167,34 +168,30 @@ class _LiveActivityConsentScreenState
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, false);
},
child: FirkaButton(
text: widget.data.l10n.la_decline,
bgColor: appStyle.colors.buttonSecondaryFill,
fontStyle: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textSecondary),
),
GestureDetector(
onTap: () {
Navigator.pop(context, true);
},
child: FirkaButton(
text: widget.data.l10n.la_accept,
bgColor: appStyle.colors.accent,
fontStyle: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary),
),
),
SizedBox(width: 12),
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, true);
},
child: FirkaButton(
text: widget.data.l10n.la_accept,
bgColor: appStyle.colors.accent,
fontStyle: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondaryLight),
),
SizedBox(height: 12),
GestureDetector(
onTap: () {
Navigator.pop(context, false);
},
child: FirkaButton(
text: widget.data.l10n.la_decline,
bgColor: appStyle.colors.buttonSecondaryFill,
fontStyle: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textSecondary),
),
),
],
@@ -212,7 +209,7 @@ class _LiveActivityConsentScreenState
required String description,
}) {
return Padding(
padding: const EdgeInsets.only(bottom: 12.0),
padding: const EdgeInsets.only(bottom: 16.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -220,7 +217,7 @@ class _LiveActivityConsentScreenState
FirkaIconType.majesticons,
icon,
color: appStyle.colors.accent,
size: 20,
size: 24,
),
SizedBox(width: 12),
Expanded(
@@ -229,13 +226,13 @@ class _LiveActivityConsentScreenState
children: [
Text(
title,
style: appStyle.fonts.B_14SB
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
SizedBox(height: 4),
SizedBox(height: 6),
Text(
description,
style: appStyle.fonts.B_14R
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textSecondary),
),
],

View File

@@ -176,24 +176,28 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
var v = item.toRoundedString();
widgets.add(GestureDetector(
child: FirkaCard(left: [
item.iconType != null
? Row(
children: [
FirkaIconWidget(item.iconType!, item.iconData!,
color: appStyle.colors.accent),
SizedBox(width: 4),
],
)
: SizedBox(),
Text(item.title,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary))
], right: [
Text(v == "0.0" ? "0" : v,
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textPrimary))
]),
child: FirkaCard(
height: 52 + 12,
left: [
item.iconType != null
? Row(
children: [
FirkaIconWidget(item.iconType!, item.iconData!,
color: appStyle.colors.accent),
SizedBox(width: 4),
],
)
: SizedBox(),
Text(item.title,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary))
],
right: [
Text(v == "0.0" ? "0" : v,
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textPrimary))
]
),
onTap: () async {
showSetDoubleSheet(context, item, widget.data, setState);
},
@@ -203,15 +207,16 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
}
if (item is SettingsBoolean) {
widgets.add(FirkaCard(
height: 52 + 12,
left: [
item.iconType != null
? Row(
children: [
FirkaIconWidget(item.iconType!, item.iconData!,
color: appStyle.colors.accent),
SizedBox(width: 4),
],
)
children: [
FirkaIconWidget(item.iconType!, item.iconData!,
color: appStyle.colors.accent),
SizedBox(width: 4),
],
)
: SizedBox(),
Text(item.title,
style: appStyle.fonts.B_16SB