From 2a88300a945db9c545d6db3e9df58ec5a8a669b6 Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Fri, 20 May 2022 19:06:37 +0800 Subject: [PATCH] upgrade to flutter 3 --- lib/data/decoder/flarum/src/discussions.dart | 12 +- lib/generated/intl/messages_all.dart | 9 +- lib/generated/intl/messages_en.dart | 47 ++-- lib/generated/intl/messages_zh_CN.dart | 42 +-- lib/generated/l10n.dart | 45 ++-- lib/ui/AddSiteUI.dart | 31 +-- lib/ui/MainUI.dart | 2 +- lib/ui/MainUI_desktop.dart | 2 +- lib/ui/SplashUI.dart | 2 + lib/ui/lists/main_discuss_list.dart | 239 +++++++++--------- lib/ui/widgets/bouncing_box.dart | 12 +- lib/ui/widgets/cache_image/image_view.dart | 37 ++- lib/ui/widgets/flarum_html_content.dart | 52 ++-- lib/util/color.dart | 1 - linux/flutter/generated_plugin_registrant.cc | 4 - linux/flutter/generated_plugins.cmake | 9 +- macos/Flutter/GeneratedPluginRegistrant.swift | 4 - pubspec.yaml | 36 +-- windows/flutter/generated_plugins.cmake | 8 + 19 files changed, 314 insertions(+), 280 deletions(-) diff --git a/lib/data/decoder/flarum/src/discussions.dart b/lib/data/decoder/flarum/src/discussions.dart index 26ed0a6..ea24d19 100644 --- a/lib/data/decoder/flarum/src/discussions.dart +++ b/lib/data/decoder/flarum/src/discussions.dart @@ -5,8 +5,12 @@ class FlarumDiscussionsData extends FlarumBaseData { final List discussionsList; - FlarumDiscussionsData(FlarumLinkData? links, data, FlarumIncludedData? included, - String sourceJsonString, this.discussionsList) + FlarumDiscussionsData( + FlarumLinkData? links, + data, + FlarumIncludedData? included, + String sourceJsonString, + this.discussionsList) : super(links, data, included, sourceJsonString); factory FlarumDiscussionsData.formBase(FlarumBaseData flarumBaseData) { @@ -38,8 +42,8 @@ class FlarumDiscussionsData extends FlarumBaseData { class FlarumDiscussionData extends FlarumBaseData { static const String typeName = "discussions"; - FlarumDiscussionData(FlarumLinkData? links, data, FlarumIncludedData? included, - String sourceJsonString) + FlarumDiscussionData(FlarumLinkData? links, data, + FlarumIncludedData? included, String sourceJsonString) : super(links, data, included, sourceJsonString); factory FlarumDiscussionData.formBase(FlarumBaseData flarumBaseData) { diff --git a/lib/generated/intl/messages_all.dart b/lib/generated/intl/messages_all.dart index af9cda2..ed52fdf 100644 --- a/lib/generated/intl/messages_all.dart +++ b/lib/generated/intl/messages_all.dart @@ -38,9 +38,8 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) async { var availableLocale = Intl.verifiedLocale( - localeName, - (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null); + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); if (availableLocale == null) { return new Future.value(false); } @@ -60,8 +59,8 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, - onFailure: (_) => null); + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index b51b501..2a6d596 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -7,7 +7,8 @@ // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -19,21 +20,31 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; - final Map messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { - "c_site_follow" : MessageLookupByLibrary.simpleMessage("This site will show on your Home Page"), - "c_site_speed_level" : MessageLookupByLibrary.simpleMessage("A good connection speed will improve your experience."), - "c_site_speed_warning" : MessageLookupByLibrary.simpleMessage("The speed of this site is not good, which may affect your experience, do you continue to follow?"), - "c_site_url_label" : MessageLookupByLibrary.simpleMessage("Flarum site URL,Must use HTTPS"), - "c_site_url_label_error" : MessageLookupByLibrary.simpleMessage("ERROR! Please check network or URL"), - "title_SPEED_LEVEL" : MessageLookupByLibrary.simpleMessage("SPEED LEVEL: "), - "title_add_site" : MessageLookupByLibrary.simpleMessage("Add Flarum Site:"), - "title_add_site_first" : MessageLookupByLibrary.simpleMessage("Welcome! \\nAdd Your First Flarum Site:"), - "title_no" : MessageLookupByLibrary.simpleMessage("NO"), - "title_retest_speed" : MessageLookupByLibrary.simpleMessage("RETEST SPEED"), - "title_site_conf" : MessageLookupByLibrary.simpleMessage("Site Conf"), - "title_site_follow" : MessageLookupByLibrary.simpleMessage("Follow This Site"), - "title_warning" : MessageLookupByLibrary.simpleMessage("WARNING"), - "title_yes" : MessageLookupByLibrary.simpleMessage("YES") - }; + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "c_site_follow": MessageLookupByLibrary.simpleMessage( + "This site will show on your Home Page"), + "c_site_speed_level": MessageLookupByLibrary.simpleMessage( + "A good connection speed will improve your experience."), + "c_site_speed_warning": MessageLookupByLibrary.simpleMessage( + "The speed of this site is not good, which may affect your experience, do you continue to follow?"), + "c_site_url_label": MessageLookupByLibrary.simpleMessage( + "Flarum site URL,Must use HTTPS"), + "c_site_url_label_error": MessageLookupByLibrary.simpleMessage( + "ERROR! Please check network or URL"), + "title_SPEED_LEVEL": + MessageLookupByLibrary.simpleMessage("SPEED LEVEL: "), + "title_add_site": + MessageLookupByLibrary.simpleMessage("Add Flarum Site:"), + "title_add_site_first": MessageLookupByLibrary.simpleMessage( + "Welcome! \\nAdd Your First Flarum Site:"), + "title_no": MessageLookupByLibrary.simpleMessage("NO"), + "title_retest_speed": + MessageLookupByLibrary.simpleMessage("RETEST SPEED"), + "title_site_conf": MessageLookupByLibrary.simpleMessage("Site Conf"), + "title_site_follow": + MessageLookupByLibrary.simpleMessage("Follow This Site"), + "title_warning": MessageLookupByLibrary.simpleMessage("WARNING"), + "title_yes": MessageLookupByLibrary.simpleMessage("YES") + }; } diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 53a7051..ac0b6a8 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -7,7 +7,8 @@ // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -19,21 +20,26 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'zh_CN'; - final Map messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { - "c_site_follow" : MessageLookupByLibrary.simpleMessage("这个网站将会出现在您的首页"), - "c_site_speed_level" : MessageLookupByLibrary.simpleMessage("优秀的连接速度可以提高您的浏览体验。"), - "c_site_speed_warning" : MessageLookupByLibrary.simpleMessage("此站点速度不佳,可能会影响您的使用体验,是否继续关注?"), - "c_site_url_label" : MessageLookupByLibrary.simpleMessage("Flarum 站点链接,必须使用 HTTPS"), - "c_site_url_label_error" : MessageLookupByLibrary.simpleMessage("出错了!请检网络是否正常,链接是否正确。"), - "title_SPEED_LEVEL" : MessageLookupByLibrary.simpleMessage("速度等级: "), - "title_add_site" : MessageLookupByLibrary.simpleMessage("添加 Flarum 站点:"), - "title_add_site_first" : MessageLookupByLibrary.simpleMessage("欢迎! \n添加您的第一个 Flarum 站点:"), - "title_no" : MessageLookupByLibrary.simpleMessage("不"), - "title_retest_speed" : MessageLookupByLibrary.simpleMessage("重新测速"), - "title_site_conf" : MessageLookupByLibrary.simpleMessage("站点配置"), - "title_site_follow" : MessageLookupByLibrary.simpleMessage("关注此站点"), - "title_warning" : MessageLookupByLibrary.simpleMessage("警告"), - "title_yes" : MessageLookupByLibrary.simpleMessage("是的") - }; + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "c_site_follow": MessageLookupByLibrary.simpleMessage("这个网站将会出现在您的首页"), + "c_site_speed_level": + MessageLookupByLibrary.simpleMessage("优秀的连接速度可以提高您的浏览体验。"), + "c_site_speed_warning": + MessageLookupByLibrary.simpleMessage("此站点速度不佳,可能会影响您的使用体验,是否继续关注?"), + "c_site_url_label": + MessageLookupByLibrary.simpleMessage("Flarum 站点链接,必须使用 HTTPS"), + "c_site_url_label_error": + MessageLookupByLibrary.simpleMessage("出错了!请检网络是否正常,链接是否正确。"), + "title_SPEED_LEVEL": MessageLookupByLibrary.simpleMessage("速度等级: "), + "title_add_site": MessageLookupByLibrary.simpleMessage("添加 Flarum 站点:"), + "title_add_site_first": + MessageLookupByLibrary.simpleMessage("欢迎! \n添加您的第一个 Flarum 站点:"), + "title_no": MessageLookupByLibrary.simpleMessage("不"), + "title_retest_speed": MessageLookupByLibrary.simpleMessage("重新测速"), + "title_site_conf": MessageLookupByLibrary.simpleMessage("站点配置"), + "title_site_follow": MessageLookupByLibrary.simpleMessage("关注此站点"), + "title_warning": MessageLookupByLibrary.simpleMessage("警告"), + "title_yes": MessageLookupByLibrary.simpleMessage("是的") + }; } diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 87973f6..fd036be 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -10,35 +10,50 @@ import 'intl/messages_all.dart'; // ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars // ignore_for_file: join_return_with_assignment, prefer_final_in_for_each -// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes class S { S(); - - static late S current; - - static const AppLocalizationDelegate delegate = - AppLocalizationDelegate(); + + static S? _current; + + static S get current { + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + return _current!; + } + + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); static Future load(Locale locale) { - final name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString(); - final localeName = Intl.canonicalizedLocale(name); + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((_) { Intl.defaultLocale = localeName; - S.current = S(); - - return S.current; + final instance = S(); + S._current = instance; + + return instance; }); - } + } + + static S of(BuildContext context) { + final instance = S.maybeOf(context); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + return instance!; + } - static S? of(BuildContext context) { + static S? maybeOf(BuildContext context) { return Localizations.of(context, S); } /// `Welcome! \nAdd Your First Flarum Site:` String get title_add_site_first { return Intl.message( - 'Welcome! \nAdd Your First Flarum Site:', + 'Welcome! \\nAdd Your First Flarum Site:', name: 'title_add_site_first', desc: '', args: [], @@ -201,4 +216,4 @@ class AppLocalizationDelegate extends LocalizationsDelegate { } return false; } -} \ No newline at end of file +} diff --git a/lib/ui/AddSiteUI.dart b/lib/ui/AddSiteUI.dart index cdb0252..057b3bc 100644 --- a/lib/ui/AddSiteUI.dart +++ b/lib/ui/AddSiteUI.dart @@ -129,8 +129,8 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { context: context, builder: (context) { return AlertDialog( - title: Text(S.of(context)!.title_warning), - content: Text(S.of(context)!.c_site_speed_warning), + title: Text(S.of(context).title_warning), + content: Text(S.of(context).c_site_speed_warning), actions: [ TextButton( onPressed: () { @@ -139,18 +139,18 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { follow = true; }); }, - child: Text(S.of(context)!.title_yes)), + child: Text(S.of(context).title_yes)), TextButton( onPressed: () { Navigator.pop(context); _checkSpeed(); }, - child: Text(S.of(context)!.title_retest_speed)), + child: Text(S.of(context).title_retest_speed)), TextButton( onPressed: () { Navigator.pop(context); }, - child: Text(S.of(context)!.title_no)) + child: Text(S.of(context).title_no)) ], ); }); @@ -258,7 +258,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { children: [ ListTile( title: Text( - S.of(context)!.title_site_conf, + S.of(context).title_site_conf, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), @@ -268,7 +268,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { ListTile( title: RichText( text: TextSpan( - text: S.of(context)!.title_SPEED_LEVEL, + text: S.of(context).title_SPEED_LEVEL, style: TextStyle( color: getTextColor(context), fontSize: 18, @@ -279,7 +279,8 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { itemBuilder: (BuildContext context, int index) { Color c = Colors.amber; - if (info!.siteConnectionSpeedLevel! <= + if (info! + .siteConnectionSpeedLevel! <= 1) { c = Colors.green; } else if (info! @@ -303,7 +304,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { ) ]), ), - subtitle: Text(S.of(context)!.c_site_speed_level), + subtitle: Text(S.of(context).c_site_speed_level), trailing: IconButton( onPressed: isSpeedChecking ? null : _checkSpeed, icon: isSpeedChecking @@ -315,9 +316,9 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> { /// Site Follow ListTile( title: Text( - S.of(context)!.title_site_follow, + S.of(context).title_site_follow, ), - subtitle: Text(S.of(context)!.c_site_follow), + subtitle: Text(S.of(context).c_site_follow), leading: Checkbox( onChanged: _followSite, value: follow, @@ -427,8 +428,8 @@ class _AddSiteMainPageState extends State<_AddSiteMainPage> { children: [ Text( widget.firstSite - ? S.of(context)!.title_add_site_first - : S.of(context)!.title_add_site, + ? S.of(context).title_add_site_first + : S.of(context).title_add_site, style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), @@ -444,9 +445,9 @@ class _AddSiteMainPageState extends State<_AddSiteMainPage> { enabled: loadStatus != 1, controller: urlTextController, decoration: InputDecoration( - labelText: S.of(context)!.c_site_url_label, + labelText: S.of(context).c_site_url_label, errorText: loadStatus == -2 - ? S.of(context)!.c_site_url_label_error + ? S.of(context).c_site_url_label_error : null), onChanged: (String text) { if (StringUtil.isHTTPSUrl(text)) { diff --git a/lib/ui/MainUI.dart b/lib/ui/MainUI.dart index 8896cbb..f408bd2 100644 --- a/lib/ui/MainUI.dart +++ b/lib/ui/MainUI.dart @@ -39,7 +39,7 @@ class _MainUIState extends State { child: fabIsLoading ? CircularProgressIndicator() : FaIcon( - FontAwesomeIcons.pencilAlt, + FontAwesomeIcons.pencil, color: getTextColor(context), ), onPressed: () {}, diff --git a/lib/ui/MainUI_desktop.dart b/lib/ui/MainUI_desktop.dart index 95d2ed7..37d0334 100644 --- a/lib/ui/MainUI_desktop.dart +++ b/lib/ui/MainUI_desktop.dart @@ -81,7 +81,7 @@ class _MainUIDesktopState extends State { heroTag: "main_fab", isExtended: isExtended, icon: FaIcon( - FontAwesomeIcons.pencilAlt, + FontAwesomeIcons.pencil, color: getTextColor(context), ), label: makeTitleText(context, "Start a Discussion"), diff --git a/lib/ui/SplashUI.dart b/lib/ui/SplashUI.dart index 16e6657..ea4aefb 100644 --- a/lib/ui/SplashUI.dart +++ b/lib/ui/SplashUI.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import '../conf.dart'; +import '../generated/l10n.dart'; class SplashUI extends StatefulWidget { @override @@ -84,6 +85,7 @@ class _SplashUIState extends State with TickerProviderStateMixin { GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, + S.delegate, ], supportedLocales: [ Locale('en', ''), diff --git a/lib/ui/lists/main_discuss_list.dart b/lib/ui/lists/main_discuss_list.dart index 3b1cb80..4bc70a8 100644 --- a/lib/ui/lists/main_discuss_list.dart +++ b/lib/ui/lists/main_discuss_list.dart @@ -1,20 +1,21 @@ +import 'dart:math'; + import 'package:fluam_app/api.dart'; import 'package:fluam_app/conf.dart'; import 'package:fluam_app/data/app/Flarum.dart'; import 'package:fluam_app/data/app/FlarumSite.dart'; import 'package:fluam_app/data/decoder/flarum/flarum.dart'; import 'package:fluam_app/route.dart'; -import 'package:fluam_app/ui/widgets.dart'; -import 'package:fluam_app/ui/widgets/bouncing_box.dart'; import 'package:fluam_app/ui/widgets/cache_image/cache_image.dart'; -import 'package:fluam_app/ui/widgets/desktop_scroll/desktop_scroll.dart'; import 'package:fluam_app/ui/widgets/flarum_html_content.dart'; import 'package:fluam_app/ui/widgets/flarum_user_avatar.dart'; import 'package:fluam_app/util/StringUtil.dart'; import 'package:fluam_app/util/color.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:waterfall_flow/waterfall_flow.dart'; +import '../widgets.dart'; typedef SiteIndexCallBack(int index); typedef FabStatueCallBack(int index); @@ -49,10 +50,31 @@ class _MainDiscussListState extends State /// if site loaded END,ignore it. static late List ignoredSiteList; + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + @override void initState() { /// init sitePageMap scrollController.addListener(() { + //fix desktop scroll + if (AppConf.isDesktop) { + const EXTRA_SCROLL_SPEED = 60; + ScrollDirection scrollDirection = + scrollController.position.userScrollDirection; + if (scrollDirection != ScrollDirection.idle) { + double scrollEnd = scrollController.offset + + (scrollDirection == ScrollDirection.reverse + ? EXTRA_SCROLL_SPEED + : -EXTRA_SCROLL_SPEED); + scrollEnd = min(scrollController.position.maxScrollExtent, + max(scrollController.position.minScrollExtent, scrollEnd)); + scrollController.jumpTo(scrollEnd); + } + } if (scrollController.offset == 0) { /// show All fab widget.fabStatueCallBack(0); @@ -234,13 +256,12 @@ class _MainDiscussListState extends State child: Text("no followSites"), ); } else { - final view = CustomScrollView( - controller: scrollController, - semanticChildCount: listData!.length, - physics: AppConf.isDesktop ? NeverScrollableScrollPhysics() : null, - slivers: [ - SliverToBoxAdapter( - child: SitesHorizonList( + // return CustomScrollView( + // controller: scrollController, + // ); + return Column( + children: [ + SitesHorizonList( widget.sites, siteIndexCallBack: (index) { final i = index - 1; @@ -250,56 +271,35 @@ class _MainDiscussListState extends State } _updateCurrentSite(context, index); }, - )), - (listData!.length == 0) - ? SliverWaterfallFlow.count( - crossAxisCount: 1, - children: [ - Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - height: 20, - ), - CircularProgressIndicator() - ], - ), - ) - ], - ) - : SliverWaterfallFlow( - gridDelegate: - SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - crossAxisCount: AppConf.isDesktop ? 3 : 1, - crossAxisSpacing: 5.0, - mainAxisSpacing: 5.0, - ), - delegate: - SliverChildBuilderDelegate((BuildContext c, int index) { - // return widgets[index]; - - return _DiscussCard( - listData![index], - showSiteBanner: siteIndex == -1, - ); - }, childCount: listData!.length), - ) + ), + SizedBox( + height: 8, + ), + Expanded( + child: (listData!.length == 0) + ? Center( + child: CircularProgressIndicator(), + ) + : Scrollbar( + controller: scrollController, + child: WaterfallFlow.builder( + controller: scrollController, + itemCount: listData!.length, + gridDelegate: + SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: AppConf.isDesktop ? 3 : 1, + crossAxisSpacing: 5.0, + mainAxisSpacing: 5.0, + ), + itemBuilder: (context, index) { + return _DiscussCard( + listData![index], + showSiteBanner: siteIndex == -1, + ); + })), + ) ], ); - final v = Scrollbar( - controller: scrollController, - isAlwaysShown: AppConf.isDesktop, - child: view); - if (AppConf.isDesktop) { - return SmoothScrollDesktop( - controller: scrollController, - child: v, - scrollSpeed: 200, - scrollAnimationLength: 200, - ); - } - return v; } } @@ -428,83 +428,72 @@ class _DiscussCard extends StatelessWidget { @override Widget build(BuildContext context) { - FlarumUserData userData = - discussionInfo.data.included!.users![discussionInfo.data.user?.id]!; + FlarumUserData? userData = + discussionInfo.data.included!.users![discussionInfo.data.user?.id]; FlarumPostData? firstPost; try { firstPost = discussionInfo .data.included!.posts![discussionInfo.data.firstPost?.id]; } catch (_) {} - return BouncingBox( - onTap: () async { - /// open Card page - /// for preview,use Browser - await Future.delayed(Duration(milliseconds: 300)); - // url_launcher.launch( - // "${discussionInfo.site.data.baseUrl}/d/${discussionInfo.data.id}"); - }, - child: SizedBox( - width: MediaQuery.of(context).size.width, - child: Padding( - padding: const EdgeInsets.only( - top: 10, - left: 10, - right: 10, + return SizedBox( + width: MediaQuery.of(context).size.width, + child: Padding( + padding: const EdgeInsets.only( + top: 10, + left: 10, + right: 10, + ), + child: Card( + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: const BorderRadius.all(Radius.circular(6)), ), - child: Card( - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: const BorderRadius.all(Radius.circular(6)), - ), - child: Padding( - padding: - EdgeInsets.only(top: 10, bottom: 20, left: 20, right: 20), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - /// Title - SizedBox( - width: MediaQuery.of(context).size.width, - child: Text( - discussionInfo.data.title!, - style: - TextStyle(fontSize: 20, fontWeight: FontWeight.bold), - ), + child: Padding( + padding: EdgeInsets.only(top: 10, bottom: 20, left: 20, right: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + /// Title + SizedBox( + width: MediaQuery.of(context).size.width, + child: Text( + discussionInfo.data.title!, + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), + ), - /// User HEAD - ListTile( - title: Text(userData.displayName!), - subtitle: Text(discussionInfo.data.createdAt!), - leading: FlarumUserAvatar(userData.avatarUrl), - ), - SizedBox( - height: 10, - ), + /// User HEAD + ListTile( + title: Text(userData?.displayName ?? "[unknown]"), + subtitle: Text(discussionInfo.data.createdAt!), + leading: FlarumUserAvatar(userData?.avatarUrl), + ), + SizedBox( + height: 10, + ), - /// content - SizedBox( - width: MediaQuery.of(context).size.width, - child: firstPost == null - ? Padding( - padding: EdgeInsets.only(bottom: 5), - child: Text("..."), - ) - : HtmlView(StringUtil.getHtmlContentSummary( - firstPost.contentHtml) - .outerHtml)), - - /// SiteBanner - showSiteBanner ? makeSiteBanner(context) : SizedBox(), - - SizedBox( - height: 5, - ), + /// content + SizedBox( + width: MediaQuery.of(context).size.width, + child: firstPost == null + ? Padding( + padding: EdgeInsets.only(bottom: 5), + child: Text("..."), + ) + : HtmlView(StringUtil.getHtmlContentSummary( + firstPost.contentHtml) + .outerHtml)), + + /// SiteBanner + showSiteBanner ? makeSiteBanner(context) : SizedBox(), + + SizedBox( + height: 5, + ), - /// Tags - makeTags(context) - ], - ), + /// Tags + makeTags(context) + ], ), ), ), diff --git a/lib/ui/widgets/bouncing_box.dart b/lib/ui/widgets/bouncing_box.dart index 9dc06ee..7662fa2 100644 --- a/lib/ui/widgets/bouncing_box.dart +++ b/lib/ui/widgets/bouncing_box.dart @@ -13,7 +13,7 @@ class BouncingBox extends StatefulWidget { class _BouncingBoxState extends State with SingleTickerProviderStateMixin { - double? _scale; + // double? _scale; // late AnimationController _controller; @@ -52,9 +52,9 @@ class _BouncingBoxState extends State // ); } - void _tapDown(TapDownDetails details) async { - // _controller.forward(); - // await Future.delayed(Duration(milliseconds: 250)); - // _controller.reverse(); - } + // void _tapDown(TapDownDetails details) async { + // // _controller.forward(); + // // await Future.delayed(Duration(milliseconds: 250)); + // // _controller.reverse(); + // } } diff --git a/lib/ui/widgets/cache_image/image_view.dart b/lib/ui/widgets/cache_image/image_view.dart index 4a0ef55..88e81f3 100644 --- a/lib/ui/widgets/cache_image/image_view.dart +++ b/lib/ui/widgets/cache_image/image_view.dart @@ -10,17 +10,32 @@ class ImagesView extends StatelessWidget { @override Widget build(BuildContext context) { - return Material( - color: Colors.transparent, - child: Hero( - tag: heroTag, - child: Scaffold( + return Scaffold( + backgroundColor: Colors.transparent, + body: Stack( + children: [ + Hero( + tag: heroTag, + child: Scaffold( + backgroundColor: Colors.transparent, + body: PageView.builder( + itemCount: images?.length, + itemBuilder: (BuildContext context, int index) { + return CacheImage(images![index]); + }), + )), + AppBar( backgroundColor: Colors.transparent, - body: PageView.builder( - itemCount: images?.length, - itemBuilder: (BuildContext context, int index) { - return CacheImage(images![index]); - }), - ))); + automaticallyImplyLeading: false, + actions: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Icon(Icons.close)), + ], + ) + ], + )); } } diff --git a/lib/ui/widgets/flarum_html_content.dart b/lib/ui/widgets/flarum_html_content.dart index f97d729..a43d883 100644 --- a/lib/ui/widgets/flarum_html_content.dart +++ b/lib/ui/widgets/flarum_html_content.dart @@ -253,8 +253,10 @@ class HtmlView extends StatelessWidget { case "details": return contentPadding(SizedBox( width: MediaQuery.of(context).size.width, - child: RaisedButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: Theme.of(context).primaryColor, + ), child: Text( "title_show_details", style: TextStyle( @@ -308,7 +310,6 @@ class HtmlView extends StatelessWidget { ), ), ); - break; case "ul": List list = []; element.children.forEach((c) { @@ -376,7 +377,8 @@ class HtmlView extends StatelessWidget { ), ), onTap: () async { - SystemChrome.setEnabledSystemUIOverlays([]); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: []); SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeRight, DeviceOrientation.landscapeRight, @@ -385,8 +387,8 @@ class HtmlView extends StatelessWidget { MaterialPageRoute(builder: (BuildContext context) { return CodeView(element.text); })); - SystemChrome.setEnabledSystemUIOverlays( - [SystemUiOverlay.top, SystemUiOverlay.bottom]); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); @@ -402,25 +404,25 @@ class HtmlView extends StatelessWidget { text: TextSpan( children: getRichTextSpan(context, element.nodes), style: TextStyle(fontSize: textSize, color: Colors.black)))); - // return contentPadding(contentPadding(SizedBox( - // width: MediaQuery.of(context).size.width, - // child: RaisedButton( - // color: Colors.red, - // child: Text( - // "UnimplementedNode", - // style: TextStyle(color: Colors.white), - // ), - // onPressed: () { - // showDialog( - // context: context, - // builder: (BuildContext context) { - // return AlertDialog( - // title: Text("Source"), - // content: Text(element.outerHtml), - // ); - // }); - // }), - // ))); + // return contentPadding(contentPadding(SizedBox( + // width: MediaQuery.of(context).size.width, + // child: RaisedButton( + // color: Colors.red, + // child: Text( + // "UnimplementedNode", + // style: TextStyle(color: Colors.white), + // ), + // onPressed: () { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return AlertDialog( + // title: Text("Source"), + // content: Text(element.outerHtml), + // ); + // }); + // }), + // ))); } } diff --git a/lib/util/color.dart b/lib/util/color.dart index 4a58581..fc3e5e3 100644 --- a/lib/util/color.dart +++ b/lib/util/color.dart @@ -1,4 +1,3 @@ -import 'dart:ui'; import 'package:flutter/material.dart'; diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index f6f23bf..e71a16d 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,10 +6,6 @@ #include "generated_plugin_registrant.h" -#include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); - url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 1fc8ed3..2e1de87 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,7 +3,9 @@ # list(APPEND FLUTTER_PLUGIN_LIST - url_launcher_linux +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST ) set(PLUGIN_BUNDLED_LIBRARIES) @@ -14,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 938dc78..0d56f51 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -2,15 +2,11 @@ // Generated file. Do not edit. // -// clang-format off - import FlutterMacOS import Foundation import path_provider_macos -import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.yaml b/pubspec.yaml index fcdca2e..4cd9618 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,50 +13,34 @@ dependencies: flutter_localizations: sdk: flutter # some ICON - font_awesome_flutter: ^9.2.0 + font_awesome_flutter: ^10.1.0 # http io http: ^0.13.4 # html decoder html: ^0.15.0 # show site start level - flutter_rating_bar: ^4.0.0 + flutter_rating_bar: ^4.0.1 # for save conf - hive: ^2.0.5 + hive: ^2.2.1 hive_flutter: ^1.1.0 # for get App path - path_provider: ^2.0.9 + path_provider: ^2.0.10 # for use some crypto encoder - crypto: ^3.0.1 + crypto: ^3.0.2 # for windows - win32: ^2.4.1 + win32: ^2.6.1 # for desktop waterfall_flow: ^3.0.2 - ffi: ^1.1.2 + ffi: ^1.2.1 dev_dependencies: flutter_test: sdk: flutter - hive_generator: ^1.1.2 - build_runner: ^2.1.7 - msix: ^3.1.3 + hive_generator: ^1.1.3 + build_runner: ^2.1.11 flutter: uses-material-design: true assets: - assets/icon.png flutter_intl: - enabled: true - -msix_config: - display_name: Fluam - publisher_display_name: XkeyC Studio - identity_name: cn.xkeyc.fluam - msix_version: 1.0.0.0 - certificate_path: ./windows/CERTIFICATE.pfx - publisher: 'E=me@xkeyc.cn, CN=xkeyc, OU=xkeyc.cn, O=XkeyC Studio, L=BeiJing, S=BeiJing, C=CN' - logo_path: assets/icon.png - start_menu_icon_path: assets/icon.png - tile_icon_path: assets/icon.png - #vs_generated_images_folder_path: ./assets_windows - icons_background_color: transparent - architecture: x64 - capabilities: 'internetClient,location' \ No newline at end of file + enabled: true \ No newline at end of file diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 4d10c25..b93c4c3 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin)