From 21c9e830d0b4b1fe6b03fded3245aa732daf73ae Mon Sep 17 00:00:00 2001 From: kidozh <11661760+kidozh@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:46:42 +0000 Subject: [PATCH] remove dependency from flutter_html --- lib/page/AddDiscuzPage.dart | 7 +- lib/page/ChooseAdExemptPage.dart | 7 +- lib/page/SelectSignatureStylePage.dart | 3 +- lib/screen/ExtraFuncInThreadScreen.dart | 3 +- lib/widget/DiscuzHtmlWidget.dart | 468 +++++++----------------- lib/widget/ForumThreadWidget.dart | 15 +- lib/widget/PostWidget.dart | 5 +- pubspec.yaml | 7 +- 8 files changed, 160 insertions(+), 355 deletions(-) diff --git a/lib/page/AddDiscuzPage.dart b/lib/page/AddDiscuzPage.dart index e271d5c..9253dec 100644 --- a/lib/page/AddDiscuzPage.dart +++ b/lib/page/AddDiscuzPage.dart @@ -19,7 +19,6 @@ import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:form_validator/form_validator.dart'; import 'package:provider/provider.dart'; @@ -341,14 +340,14 @@ class _AddDiscuzFormFieldState child: Icon( Icons.verified, color: Colors.green, - size: FontSize.medium.value * 1.2, + size: 16, ), )), TextSpan( text:S.of(context).addDiscuzSuggestionVerifiedDiscuz, style: TextStyle( fontWeight: FontWeight.normal, - fontSize: FontSize.medium.value, + fontSize: 16, ) ), ]), @@ -556,7 +555,7 @@ class _AddDiscuzFormFieldState .colorScheme .onPrimaryContainer, fontWeight: FontWeight.normal, - fontSize: FontSize.medium.value, + fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize, )), leading: Icon(PlatformIcons(context).info, color: diff --git a/lib/page/ChooseAdExemptPage.dart b/lib/page/ChooseAdExemptPage.dart index f8f7780..fa7b860 100644 --- a/lib/page/ChooseAdExemptPage.dart +++ b/lib/page/ChooseAdExemptPage.dart @@ -8,7 +8,6 @@ import 'package:discuz_flutter/utility/URLUtils.dart'; import 'package:discuz_flutter/utility/UserPreferencesUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:provider/provider.dart'; import 'package:settings_ui/settings_ui.dart'; @@ -83,7 +82,7 @@ class _ChooseAdExemptState extends State { child: Text( S.of(context).adExemptNoNeedToConfirm, style: TextStyle( - fontSize: FontSize.large.value, + fontSize: Theme.of(context).textTheme.bodyLarge?.fontSize, color: Theme.of(context).disabledColor, ), ), @@ -138,13 +137,13 @@ class _ChooseAdExemptState extends State { SizedBox(height: 16, width: double.infinity,), Text(S.of(context).discuzInAdExemptBuiltInList(discuz.siteName), style: TextStyle( fontWeight: FontWeight.bold, - fontSize: FontSize.large.value + fontSize: Theme.of(context).textTheme.bodyLarge?.fontSize ) ), SizedBox(height: 8, width: double.infinity,), Text(S.of(context).discuzInAdExemptBuiltInListDescription(discuz.siteName), style: TextStyle( fontWeight: FontWeight.normal, - fontSize: FontSize.medium.value + fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize )), SizedBox(height: 16, width: double.infinity,), SizedBox( diff --git a/lib/page/SelectSignatureStylePage.dart b/lib/page/SelectSignatureStylePage.dart index 7f81453..db3a4ff 100644 --- a/lib/page/SelectSignatureStylePage.dart +++ b/lib/page/SelectSignatureStylePage.dart @@ -5,7 +5,6 @@ import 'dart:developer'; import 'package:discuz_flutter/utility/PostTextFieldUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; @@ -155,7 +154,7 @@ class SelectSignatureStyleState extends State{ children: [ Text(S.of(context).signaturePreview, style: TextStyle( fontWeight: FontWeight.bold, - fontSize: FontSize.xLarge.value + fontSize: Theme.of(context).textTheme.headlineMedium?.fontSize )), SizedBox(height: 8,), Container( diff --git a/lib/screen/ExtraFuncInThreadScreen.dart b/lib/screen/ExtraFuncInThreadScreen.dart index bcd798a..a46e0a2 100644 --- a/lib/screen/ExtraFuncInThreadScreen.dart +++ b/lib/screen/ExtraFuncInThreadScreen.dart @@ -16,7 +16,6 @@ import 'package:discuz_flutter/utility/NetworkUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:image_picker/image_picker.dart'; @@ -150,7 +149,7 @@ class ExtraFuncInThreadState extends State{ child: Text(S.of(context).attachmentUploadExceedingSizeDescription, style: TextStyle( color: Theme.of(context).colorScheme.onPrimary, - fontSize: FontSize.medium.value + fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize ), ), ), diff --git a/lib/widget/DiscuzHtmlWidget.dart b/lib/widget/DiscuzHtmlWidget.dart index 014ccd8..f3eea5c 100644 --- a/lib/widget/DiscuzHtmlWidget.dart +++ b/lib/widget/DiscuzHtmlWidget.dart @@ -1,4 +1,3 @@ - import 'dart:developer'; import 'package:cached_network_image/cached_network_image.dart'; @@ -12,12 +11,8 @@ import 'package:discuz_flutter/utility/AppPlatformIcons.dart'; import 'package:discuz_flutter/utility/PostTextUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; -import 'package:flutter_html_audio/flutter_html_audio.dart'; -import 'package:flutter_html_svg/flutter_html_svg.dart'; -import 'package:flutter_html_table/flutter_html_table.dart'; -import 'package:flutter_html_video/flutter_html_video.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:provider/provider.dart'; import 'package:slide_countdown/slide_countdown.dart'; @@ -26,360 +21,181 @@ import '../utility/URLUtils.dart'; typedef void JumpToPidCallback(int pid); // ignore: must_be_immutable -class DiscuzHtmlWidget extends StatelessWidget{ +class DiscuzHtmlWidget extends StatelessWidget { String html; Discuz discuz; JumpToPidCallback? callback; int? tid; final ValueChanged? onSelectTid; - DiscuzHtmlWidget(this.discuz,this.html,{this.callback, this.tid, this.onSelectTid}); - - - - - + DiscuzHtmlWidget(this.discuz, this.html, + {this.callback, this.tid, this.onSelectTid}); @override Widget build(BuildContext context) { - return Container( width: double.infinity, - //padding: EdgeInsets.zero, + padding: EdgeInsets.all(4.0), - child: Consumer(builder: (context, typesetting, _) { + child: Consumer( + builder: (context, typesetting, _) { double scalingParameter = typesetting.scalingParameter; bool useThinFont = typesetting.useThinFontWeight; Typography typography = Typography.material2021(); - String platformName = Provider.of(context, listen: false).platformName; + String platformName = + Provider.of(context, listen: false) + .platformName; TargetPlatform targetPlatform = TargetPlatform.android; bool useCompactParagraph = typesetting.useCompactParagraph; - switch(platformName){ - case "ios":{ - targetPlatform = TargetPlatform.iOS; - break; - } - case "android":{ - targetPlatform = TargetPlatform.android; - break; - } - case "":{ - targetPlatform = Theme.of(context).platform; - } + switch (platformName) { + case "ios": + { + targetPlatform = TargetPlatform.iOS; + break; + } + case "android": + { + targetPlatform = TargetPlatform.android; + break; + } + case "": + { + targetPlatform = Theme.of(context).platform; + } } - switch (typesetting.typographyTheme){ - case "material2014":{ - typography = Typography.material2014(platform: targetPlatform); - break; - } - case "material2018":{ - typography = Typography.material2018(platform: targetPlatform); - break; - } - case "material2021":{ - typography = Typography.material2021(platform: targetPlatform); - break; - } - default:{ - typography = Theme.of(context).typography; - } + switch (typesetting.typographyTheme) { + case "material2014": + { + typography = Typography.material2014(platform: targetPlatform); + break; + } + case "material2018": + { + typography = Typography.material2018(platform: targetPlatform); + break; + } + case "material2021": + { + typography = Typography.material2021(platform: targetPlatform); + break; + } + default: + { + typography = Theme.of(context).typography; + } } - TextTheme textTheme = typography.dense.useSystemChineseFont(Theme.of(context).brightness); + TextTheme textTheme = + typography.tall.useSystemChineseFont(Theme.of(context).brightness); TextStyle? defaultTextStyle = textTheme.bodyLarge; - double? themeFontSize = defaultTextStyle?.fontSize == null? 14 : defaultTextStyle?.fontSize!; - - return Html( - //shrinkWrap: true, - data: PostTextUtils.getDecodedString(html, useCompactParagraph), - - style: { - "p": Style( - color: defaultTextStyle?.color, - backgroundColor: defaultTextStyle?.backgroundColor, - fontStyle: defaultTextStyle?.fontStyle, - fontFamily: defaultTextStyle?.fontFamily, - fontFamilyFallback: defaultTextStyle?.fontFamilyFallback, - fontSize: defaultTextStyle?.fontSize == null? FontSize.medium:FontSize(defaultTextStyle!.fontSize!*scalingParameter), - fontWeight: defaultTextStyle?.fontWeight, - wordSpacing: defaultTextStyle?.wordSpacing, - - padding: HtmlPaddings.zero, - margin: Margins.zero - ), - "*": Style( - fontSize: defaultTextStyle?.fontSize == null? FontSize.medium:FontSize(defaultTextStyle!.fontSize!*scalingParameter), - fontWeight: useThinFont? FontWeight.w300: null, - lineHeight: LineHeight(1.8), - ), - "font": Style( - backgroundColor: Theme.of(context).brightness == Brightness.dark? Colors.transparent: null, - color: Theme.of(context).brightness == Brightness.dark? Theme.of(context).textTheme.bodySmall?.color: null, - fontSize: defaultTextStyle?.fontSize == null? FontSize.medium:FontSize(defaultTextStyle!.fontSize!*scalingParameter), - //fontWeight: defaultTextStyle?.fontWeight, - ), - ".reply_wrap" :Style( - backgroundColor: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade200: Colors.grey.shade600, - padding: HtmlPaddings.all(4.0), - margin: Margins(bottom: Margin(4.0)), - border: Border(left: BorderSide(color: Theme.of(context).colorScheme.primary, width: 4)), - width: Width.auto() - ), - "a":Style( - color: Theme.of(context).colorScheme.primary, - textDecoration: TextDecoration.underline, - textDecorationColor: Theme.of(context).colorScheme.primary, - - ), - "h1": Style( - fontSize: textTheme.titleLarge?.fontSize != null ? FontSize(textTheme.titleLarge!.fontSize!*scalingParameter): null, - color: Theme.of(context).colorScheme.onPrimaryContainer, - fontFamily: textTheme.titleLarge?.fontFamily, - fontWeight: FontWeight.bold, - fontStyle: textTheme.titleLarge?.fontStyle, - backgroundColor: Theme.of(context).colorScheme.primaryContainer, - padding: HtmlPaddings.all(6.0) - ), - "h2": Style( - fontSize: textTheme.titleLarge?.fontSize != null ? FontSize(textTheme.titleLarge!.fontSize!*scalingParameter): null, - color: Theme.of(context).colorScheme.primary, - fontFamily: textTheme.titleLarge?.fontFamily, - fontWeight: FontWeight.bold, - fontStyle: textTheme.titleLarge?.fontStyle, - backgroundColor: textTheme.titleLarge?.backgroundColor, - ), - "h3": Style( - fontSize: textTheme.titleLarge?.fontSize != null ? FontSize(textTheme.titleLarge!.fontSize!*scalingParameter): null, - color: Theme.of(context).colorScheme.primary, - fontFamily: textTheme.titleLarge?.fontFamily, - fontWeight: textTheme.titleLarge?.fontWeight, - fontStyle: textTheme.titleLarge?.fontStyle, - backgroundColor: textTheme.titleLarge?.backgroundColor - ), - "h4": Style( - fontSize: textTheme.titleLarge?.fontSize != null ? FontSize(textTheme.titleLarge!.fontSize!*scalingParameter): null, - color: textTheme.titleLarge?.color, - fontFamily: textTheme.titleLarge?.fontFamily, - fontWeight: textTheme.titleLarge?.fontWeight, - fontStyle: textTheme.titleLarge?.fontStyle, - backgroundColor: textTheme.titleLarge?.backgroundColor - ), - "h5": Style( - fontSize: textTheme.titleMedium?.fontSize != null ? FontSize(textTheme.titleMedium!.fontSize!*scalingParameter): null, - color: textTheme.titleMedium?.color, - fontFamily: textTheme.titleMedium?.fontFamily, - fontWeight: FontWeight.w300, - fontStyle: textTheme.titleMedium?.fontStyle, - backgroundColor: textTheme.titleMedium?.backgroundColor - ), - "h6": Style( - fontSize: textTheme.titleSmall?.fontSize != null ? FontSize(textTheme.titleSmall!.fontSize!*scalingParameter): null, - color: textTheme.titleSmall?.color, - fontFamily: textTheme.titleSmall?.fontFamily, - fontWeight: FontWeight.w300, - fontStyle: textTheme.titleSmall?.fontStyle, - backgroundColor: textTheme.titleSmall?.backgroundColor - ), - "br": Style( - lineHeight: useCompactParagraph? LineHeight(1): null, - ) - - - }, - onLinkTap: (urlString, context1,attribute) async{ - URLUtils.openURL(context, onSelectTid, urlString, callback, tid); - - + double themeFontSize = defaultTextStyle == null + ? 14: defaultTextStyle.fontSize == null? 14 : defaultTextStyle.fontSize!; + + return HtmlWidget( + PostTextUtils.getDecodedString(html, useCompactParagraph), + onTapUrl: (url) { + URLUtils.openURL(context, onSelectTid, url, callback, tid); + return true; }, - extensions: [ - //const IframeHtmlExtension(), - //MathHtmlExtension(), - const SvgHtmlExtension(), - const AudioHtmlExtension(), - const TableHtmlExtension(), - const VideoHtmlExtension(), - // TagWrapExtension( - // tagsToWrap: {"table"}, - // builder: (child) { - // return SingleChildScrollView( - // scrollDirection: Axis.horizontal, - // child: child, - // ); - // }), - ImageExtension( - //matchesAssetImages: false, - //matchesDataImages: false, - //networkSchemas: {"custom:"}, - builder: (extensionContext) { - final element = extensionContext.styledElement; - if(element?.node.attributes["src"] != null){ - return InkWell( - child: CachedNetworkImage( - imageUrl: element!.node.attributes["src"]!, - errorWidget: (context, url, error) => Icon(Icons.error), - progressIndicatorBuilder: (context, url, progress) => PlatformCircularProgressIndicator( - material: (_, __) => MaterialProgressIndicatorData( - value: progress.progress - ), - ), - ), - onTap: () { - String? src = element.node.attributes["src"]; - if (src != null) { - VibrationUtils.vibrateWithClickIfPossible(); - Navigator.push( - context, - platformPageRoute(context: context, - builder: (context) => FullImagePage(src)) - ); + onTapImage: (imageMetaData){ + for(var source in imageMetaData.sources){ + String src = source.url; + VibrationUtils.vibrateWithClickIfPossible(); + Navigator.push( + context, + platformPageRoute( + context: context, + builder: (context) => FullImagePage(src))); } - } - ); - } - else{ - return Container(); - } - - } - ), - OnImageTapExtension(onImageTap: (src, imgAttributes, element){ - if (src!= null){ - VibrationUtils.vibrateWithClickIfPossible(); - Navigator.push( - context, - platformPageRoute(context:context,builder: (context) => FullImagePage(src)) - ); - } - - }), - TagExtension( - tagsToExtend: {"collapse", "spoil"}, - builder: (extensionContext){ - String title = S.of(context).collapseItem; - if(extensionContext.attributes["title"] != null){ - title = extensionContext.attributes["title"]!; - } - return ExpansionTile( - title: Text(title), - onExpansionChanged: (bool){ - VibrationUtils.vibrateWithClickIfPossible(); - }, - controlAffinity: ListTileControlAffinity.platform, - children: [ - DiscuzHtmlWidget(discuz, extensionContext.innerHtml) - ], - collapsedBackgroundColor: Theme.of(context).colorScheme.primary, - collapsedTextColor: Theme.of(context).colorScheme.onPrimary, - collapsedIconColor: Theme.of(context).colorScheme.onPrimary, - backgroundColor: Theme.of(context).colorScheme.primaryContainer, - textColor: Theme.of(context).colorScheme.onPrimaryContainer, - iconColor: Theme.of(context).colorScheme.onPrimaryContainer, - ); + }, + textStyle: TextStyle( + fontSize: themeFontSize * scalingParameter, + fontWeight: useThinFont? FontWeight.w300: FontWeight.normal + ), + // textStyle: Theme.of(context).useSystemChineseFont(Theme.of(context).brightness).textTheme.bodyLarge?..copyWith( + // fontSize: 12 * scalingParameter + // ), + customWidgetBuilder: (element) { + // "collapse", "spoil" + if (element.localName == "collapse" || + element.localName == "spoil") { + String title = S.of(context).collapseItem; + if (element.attributes["title"] != null) { + title = element.attributes["title"]!; } - ), - TagExtension( - tagsToExtend: {"countdown"}, - builder: (extensionContext){ - String timeString = ""; - if(extensionContext.attributes["time"] != null){ - timeString = extensionContext.attributes["time"]!; - DateTime? datetime = DateTime.tryParse(timeString); - - if(datetime!=null){ - // most of them located in Asia/Shanghai - Duration duration = datetime.difference(DateTime.now()); - - log("get time string ${timeString} ${datetime}"); - return Padding( - padding: EdgeInsets.symmetric(vertical: 32), - child: ListTile( - leading: Icon(Icons.timer), - title: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SlideCountdown( - duration: duration, - style: TextStyle(color: Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20)), - color: Theme.of(context).colorScheme.primary, - ), - separatorType: SeparatorType.title, - durationTitle: DurationTitle( - days: S.of(context).day, - hours:S.of(context).hour, - minutes:S.of(context).minute, - seconds:S.of(context).second, - ), - ) - ], - ), - subtitle: DateTime.now().timeZoneOffset != Duration(hours: 8)? Text(S.of(context).countDownTimeZoneNotify): null, - ), - ); - } - else{ - return Text(S.of(context).brokenCountDown); - } - } - else{ - return Text(S.of(context).brokenCountDown); - } - } - ), - TagExtension( - tagsToExtend: {"iframe"}, - builder: (extensionContext){ - String? url = extensionContext.attributes["src"]; - if(url != null ){ - return InkWell( - child: Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: BorderRadius.all(Radius.circular(4.0)) - ), - - child: PlatformListTile( - leading: Icon(AppPlatformIcons(context).iframeOutline, - color: Theme.of(context).colorScheme.onPrimary,), - title: Text(S.of(context).inlineFramePage, style: TextStyle( + return ExpansionTile( + title: Text(title), + onExpansionChanged: (bool) { + VibrationUtils.vibrateWithClickIfPossible(); + }, + controlAffinity: ListTileControlAffinity.platform, + children: [DiscuzHtmlWidget(discuz, element.innerHtml)], + collapsedBackgroundColor: Theme.of(context).colorScheme.primary, + collapsedTextColor: Theme.of(context).colorScheme.onPrimary, + collapsedIconColor: Theme.of(context).colorScheme.onPrimary, + backgroundColor: Theme.of(context).colorScheme.primaryContainer, + textColor: Theme.of(context).colorScheme.onPrimaryContainer, + iconColor: Theme.of(context).colorScheme.onPrimaryContainer, + ); + } else if (element.localName == "countdown") { + String timeString = ""; + if (element.attributes["time"] != null) { + DateTime? datetime = DateTime.tryParse(timeString); + + if (datetime != null) { + // most of them located in Asia/Shanghai + Duration duration = datetime.difference(DateTime.now()); + + log("get time string ${timeString} ${datetime}"); + return Padding( + padding: EdgeInsets.symmetric(vertical: 32), + child: ListTile( + leading: Icon(Icons.timer), + title: Row( + mainAxisSize: MainAxisSize.min, + children: [ + SlideCountdown( + duration: duration, + style: TextStyle( color: Theme.of(context).colorScheme.onPrimary, - fontWeight: FontWeight.bold - ),), - subtitle: Text(extensionContext.attributes["src"]!,style: TextStyle( - color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.6), - fontWeight: FontWeight.w300 + fontWeight: FontWeight.bold), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(20)), + color: Theme.of(context).colorScheme.primary, ), - maxLines: 1, - overflow: TextOverflow.ellipsis, + separatorType: SeparatorType.title, + durationTitle: DurationTitle( + days: S.of(context).day, + hours: S.of(context).hour, + minutes: S.of(context).minute, + seconds: S.of(context).second, ), - ), - ), - onTap: (){ - VibrationUtils.vibrateWithClickIfPossible(); - URLUtils.checkWithDbAndOpenURL(context, url); - }, - ); - } - else{ - return Container(); - } - + ) + ], + ), + subtitle: + DateTime.now().timeZoneOffset != Duration(hours: 8) + ? Text(S.of(context).countDownTimeZoneNotify) + : null, + ), + ); + } else { + return Text(S.of(context).brokenCountDown); } - ), + } else { + return Text(S.of(context).brokenCountDown); + } - ], + } + return null; + }, ); }), - - ); } - - - -} \ No newline at end of file +} diff --git a/lib/widget/ForumThreadWidget.dart b/lib/widget/ForumThreadWidget.dart index 4742664..2caea38 100644 --- a/lib/widget/ForumThreadWidget.dart +++ b/lib/widget/ForumThreadWidget.dart @@ -18,7 +18,6 @@ import 'package:discuz_flutter/utility/TimeDisplayUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:discuz_flutter/widget/UserAvatar.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:provider/provider.dart'; @@ -270,7 +269,7 @@ class ForumThreadState extends State{ mainAxisSize: MainAxisSize.max, children: [ UserAvatar( - _discuz, _forumThread.getAuthorId(), _forumThread.author, size: FontSize.small.value, + _discuz, _forumThread.getAuthorId(), _forumThread.author, size: Theme.of(context).textTheme.bodySmall?.fontSize, ), SizedBox(width: 2,), @@ -279,7 +278,7 @@ class ForumThreadState extends State{ text: TextSpan( text: " ", style: TextStyle( - fontSize: FontSize.small.value, + fontSize: Theme.of(context).textTheme.bodySmall?.fontSize, fontWeight: viewed? FontWeight.w300:FontWeight.normal, color: selected? Theme.of(context).colorScheme.onPrimaryContainer:viewed? Theme.of(context).unselectedWidgetColor: Theme.of(context).textTheme.bodySmall?.color, ), @@ -330,7 +329,7 @@ class ForumThreadState extends State{ child: Text(message, style: TextStyle( fontWeight: viewed? FontWeight.w300:FontWeight.normal, - fontSize: FontSize.medium.value, + fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize, color: selected? Theme.of(context).colorScheme.onPrimaryContainer: viewed? Theme.of(context).unselectedWidgetColor: null, ), maxLines: 3, @@ -495,7 +494,7 @@ class ForumThreadState extends State{ text: "", style: TextStyle( color: Theme.of(context).colorScheme.onSecondaryContainer, - fontSize: FontSize.small.value + fontSize: Theme.of(context).textTheme.bodySmall?.fontSize ), children: [ @@ -601,7 +600,7 @@ class ForumThreadState extends State{ children: [ Text(S.of(context).contentPostByBlockUserTitle(_forumThread.author), style:TextStyle( - fontSize: FontSize.large.value, + fontSize: Theme.of(context).textTheme.bodyLarge?.fontSize, color: Theme.of(context).textTheme.titleMedium?.color, ) ), @@ -664,7 +663,7 @@ class ForumThreadState extends State{ WidgetSpan( child: Icon( AppPlatformIcons(context).stickyPostSolid, - size: FontSize.large.value, + size: Theme.of(context).textTheme.bodyLarge?.fontSize, color: selected?Theme.of(context).colorScheme.onSecondary: viewed? Theme.of(context).colorScheme.secondary: Theme.of(context).colorScheme.onSecondary, ) ), @@ -672,7 +671,7 @@ class ForumThreadState extends State{ TextSpan( text: S.of(context).stickyThread, style: TextStyle( - fontSize: FontSize.large.value, + fontSize: Theme.of(context).textTheme.bodyLarge?.fontSize, fontWeight: FontWeight.normal, color: selected?Theme.of(context).colorScheme.onSecondary: viewed? Theme.of(context).colorScheme.secondary: Theme.of(context).colorScheme.onSecondary, ) diff --git a/lib/widget/PostWidget.dart b/lib/widget/PostWidget.dart index de556aa..34ebb46 100644 --- a/lib/widget/PostWidget.dart +++ b/lib/widget/PostWidget.dart @@ -26,7 +26,6 @@ import 'package:discuz_flutter/widget/DiscuzHtmlWidget.dart'; import 'package:discuz_flutter/widget/PostCommentWidget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:provider/provider.dart'; @@ -560,7 +559,7 @@ class PostState extends State { .colorScheme .onPrimary, fontWeight: FontWeight.bold, - fontSize: FontSize.small.value)), + fontSize: Theme.of(context).textTheme.bodySmall?.fontSize)), ), ), Padding( @@ -576,7 +575,7 @@ class PostState extends State { .colorScheme .onPrimaryContainer, fontWeight: FontWeight.normal, - fontSize: FontSize.small.value)), + fontSize: Theme.of(context).textTheme.bodySmall?.fontSize)), ) ) ], diff --git a/pubspec.yaml b/pubspec.yaml index a28b03d..1f850bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,7 +40,6 @@ dependencies: provider: ^6.0.1 flutter_localizations: sdk: flutter - flutter_html: ^3.0.0-beta.2 flutter_spinkit: ^5.1.0 flutter_easyloading: ^3.0.3 json_serializable: ^6.1.3 @@ -84,12 +83,7 @@ dependencies: dynamic_color: ^1.6.7 intl_utils: ^2.8.1 dual_screen: ^1.0.3 - flutter_html_iframe: ^3.0.0-beta.2 carousel_slider: ^5.0.0 - flutter_html_audio: ^3.0.0-beta.2 - flutter_html_svg: ^3.0.0-beta.2 - flutter_html_table: ^3.0.0-beta.2 - flutter_html_video: ^3.0.0-beta.2 upgrader: ^11.3.0 flutter_secure_storage: ^9.0.0 local_auth: ^2.1.7 @@ -105,6 +99,7 @@ dependencies: ios_utsname_ext: ^2.3.0 ua_client_hints: ^1.4.0 random_user_agents: ^1.0.6 + flutter_widget_from_html: ^0.15.3 dev_dependencies: flutter_test: sdk: flutter