forked from firka/firka
fix: certain messages crashing flutter_html
This commit is contained in:
@@ -317,4 +317,16 @@ extension StringExtension on String {
|
||||
"${string[0]}.",
|
||||
).shortenName(index - string.length + 2 + 1);
|
||||
}
|
||||
|
||||
/// Removes CSS font-feature-settings. flutter_html passes values like
|
||||
/// `normal` into FontFeature, which requires a 4-character OpenType tag.
|
||||
String withoutFontFeatureSettings() {
|
||||
return replaceAll(
|
||||
RegExp(
|
||||
r'''font-feature-settings\s*:\s*[^;}"']+;?''',
|
||||
caseSensitive: false,
|
||||
),
|
||||
"",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:firka/ui/phone/pages/home/home_omissions.dart';
|
||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firka/core/firka_bundle.dart';
|
||||
@@ -24,8 +25,6 @@ import 'package:firka/routing/shell_with_nav_bar.dart';
|
||||
import 'package:firka/routing/swipable_navigator_container.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
|
||||
GoRouter createAppRouter() {
|
||||
final subjectRoute = GoRoute(
|
||||
path: 'subject',
|
||||
@@ -99,7 +98,7 @@ GoRouter createAppRouter() {
|
||||
GoRoute(
|
||||
path: '/message',
|
||||
builder: (context, state) {
|
||||
final info = state.extra as MessageItem?;
|
||||
final info = state.extra as MessageCacheModel?;
|
||||
if (info == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ Future<void> showHomeworkBottomSheet(
|
||||
margin: EdgeInsets.all(0),
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Html(
|
||||
data: homework.description,
|
||||
data: homework.description.withoutFontFeatureSettings(),
|
||||
style: {
|
||||
"*": Style.fromTextStyle(
|
||||
appStyle.fonts.B_16R.apply(color: appStyle.colors.textPrimary),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:firka/core/firka_bundle.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
@@ -12,7 +12,7 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class MessageScreen extends StatelessWidget {
|
||||
final AppInitialization data;
|
||||
final MessageItem message;
|
||||
final MessageCacheModel message;
|
||||
|
||||
const MessageScreen(this.data, this.message, {super.key});
|
||||
|
||||
@@ -84,7 +84,10 @@ class MessageScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
message.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||
message.createdAt.format(
|
||||
data.l10n,
|
||||
FormatMode.yyyymmdd,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
@@ -153,7 +156,8 @@ class MessageScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: SingleChildScrollView(
|
||||
child: Html(
|
||||
data: message.contentHTML,
|
||||
data: message.contentHtml
|
||||
.withoutFontFeatureSettings(),
|
||||
onLinkTap: (url, map, element) => {
|
||||
if (url != null) launchUrlString(url),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user