From 9fc511840dc25a357ffabac7ae6a1bc2cec1227b Mon Sep 17 00:00:00 2001 From: Robert-Stackflow Date: Tue, 23 Jul 2024 11:06:58 +0800 Subject: [PATCH] Fix the bug of abnormal version update;Update version to 1.10.0 --- .../Info/favorite_folder_list_screen.dart | 136 +++++++++--------- lib/Screens/Info/history_screen.dart | 73 +--------- lib/Screens/Info/like_screen.dart | 77 +--------- lib/Screens/Info/post_screen.dart | 73 +--------- lib/Screens/Info/share_screen.dart | 72 +--------- lib/Screens/Info/user_detail_screen.dart | 85 ++++++----- .../Setting/general_setting_screen.dart | 4 +- .../Setting/tagshield_setting_screen.dart | 2 +- lib/Screens/Setting/update_log_screen.dart | 6 +- lib/Utils/utils.dart | 23 ++- lib/Widgets/Item/item_builder.dart | 4 + 11 files changed, 150 insertions(+), 405 deletions(-) diff --git a/lib/Screens/Info/favorite_folder_list_screen.dart b/lib/Screens/Info/favorite_folder_list_screen.dart index 81a85c9..52a82d4 100644 --- a/lib/Screens/Info/favorite_folder_list_screen.dart +++ b/lib/Screens/Info/favorite_folder_list_screen.dart @@ -106,87 +106,89 @@ class _FavoriteFolderListScreenState extends State cacheExtent: 9999, padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 16), children: List.generate(_favoriteFolderList.length, (index) { - return GestureDetector( - onTap: () { - RouteUtil.pushCupertinoRoute( - context, - FavoriteFolderDetailScreen( - favoriteFolderId: _favoriteFolderList[index].id ?? 0), - ); - }, - child: _buildFolderItem( - context, - _favoriteFolderList[index], - ), + return _buildFolderItem( + context, + _favoriteFolderList[index], ); }), ); } static Widget _buildFolderItem(BuildContext context, FavoriteFolder item) { - return Container( - color: Colors.transparent, - child: Row( - children: [ - Container( - decoration: BoxDecoration( - border: - Border.all(color: Theme.of(context).dividerColor, width: 0.5), - borderRadius: BorderRadius.circular(10), - color: Colors.transparent, - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: SizedBox( - height: 80, - width: 80, - child: ItemBuilder.buildCachedImage( - context: context, - fit: BoxFit.cover, - showLoading: false, - imageUrl: Utils.removeWatermark(item.coverUrl ?? ""), + return ItemBuilder.buildClickItem( + GestureDetector( + onTap: () { + RouteUtil.pushCupertinoRoute( + context, + FavoriteFolderDetailScreen( + favoriteFolderId: item.id ?? 0), + ); + }, + child: Container( + color: Colors.transparent, + child: Row( + children: [ + Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).dividerColor, width: 0.5), + borderRadius: BorderRadius.circular(10), + color: Colors.transparent, ), - ), - ), - ), - Expanded( - child: Container( - padding: const EdgeInsets.only(left: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - children: [ - ItemBuilder.buildCopyItem( - context, - child: Text( - item.name ?? "", - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: SizedBox( + height: 80, + width: 80, + child: ItemBuilder.buildCachedImage( + context: context, + fit: BoxFit.cover, + showLoading: false, + imageUrl: Utils.removeWatermark(item.coverUrl ?? ""), ), - copyText: item.name ?? "", - toastText: "已复制收藏夹名称", ), - const SizedBox(height: 10), - ItemBuilder.buildCopyItem(context, - child: Text( - "ID: ${item.id}", + ), + ), + Expanded( + child: Container( + padding: const EdgeInsets.only(left: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + ItemBuilder.buildCopyItem( + context, + child: Text( + item.name ?? "", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + copyText: item.name ?? "", + toastText: "已复制收藏夹名称", + ), + const SizedBox(height: 10), + ItemBuilder.buildCopyItem(context, + child: Text( + "ID: ${item.id}", + style: Theme.of(context).textTheme.titleSmall, + ), + copyText: item.id.toString(), + toastText: "已复制收藏夹ID"), + const SizedBox(height: 10), + Text( + "${item.postCount}篇", style: Theme.of(context).textTheme.titleSmall, ), - copyText: item.id.toString(), - toastText: "已复制收藏夹ID"), - const SizedBox(height: 10), - Text( - "${item.postCount}篇", - style: Theme.of(context).textTheme.titleSmall, + ], ), - ], + ), ), - ), + ], ), - ], + ), ), ); } diff --git a/lib/Screens/Info/history_screen.dart b/lib/Screens/Info/history_screen.dart index c992960..afa9fc0 100644 --- a/lib/Screens/Info/history_screen.dart +++ b/lib/Screens/Info/history_screen.dart @@ -7,11 +7,8 @@ import 'package:loftify/Models/history_response.dart'; import 'package:loftify/Resources/theme.dart'; import 'package:loftify/Utils/hive_util.dart'; import 'package:tuple/tuple.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; -import '../../Api/post_api.dart'; import '../../Models/post_detail_response.dart'; -import '../../Utils/enums.dart'; import '../../Utils/itoast.dart'; import '../../Utils/utils.dart'; import '../../Widgets/BottomSheet/bottom_sheet_builder.dart'; @@ -37,7 +34,6 @@ class _HistoryScreenState extends State final List _archiveDataList = []; int _total = 0; int _recordHistory = 0; - HistoryLayoutMode _layoutMode = HistoryLayoutMode.nineGrid; bool _loading = false; final EasyRefreshController _refreshController = EasyRefreshController(); bool _noMore = false; @@ -122,20 +118,11 @@ class _HistoryScreenState extends State onRefresh: _onRefresh, onLoad: _onLoad, triggerAxis: Axis.vertical, - child: _buildBody(), + child: _buildNineGridGroup(), ), ); } - Widget _buildBody() { - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - return _buildWaterflow(); - case HistoryLayoutMode.nineGrid: - return _buildNineGridGroup(); - } - } - Widget _buildNineGridGroup() { List widgets = []; int startIndex = 0; @@ -186,56 +173,7 @@ class _HistoryScreenState extends State ); } - Widget _buildWaterflow() { - return ItemBuilder.buildLoadMoreNotification( - noMore: _noMore, - onLoad: _onLoad, - child: WaterfallFlow.builder( - cacheExtent: 9999, - padding: const EdgeInsets.only(top: 10, left: 8, right: 8), - gridDelegate: const SliverWaterfallFlowDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 6, - crossAxisSpacing: 6, - maxCrossAxisExtent: 300, - ), - itemBuilder: (BuildContext context, int index) { - return CommonInfoItemBuilder.buildWaterfallFlowPostItem( - context, _histories[index], onLikeTap: () async { - var item = _histories[index]; - HapticFeedback.mediumImpact(); - return await PostApi.likeOrUnLike( - isLike: !(item.liked == true), - postId: item.post!.id, - blogId: item.post!.blogId, - ).then((value) { - setState(() { - if (value['meta']['status'] != 200) { - IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']); - } else { - item.liked = !(item.liked == true); - item.post!.postCount?.favoriteCount += - item.liked == true ? 1 : -1; - } - }); - return value['meta']['status']; - }); - }); - }, - itemCount: _histories.length, - ), - ); - } - PreferredSizeWidget _buildAppBar() { - IconData icon = Icons.transform_rounded; - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - icon = Icons.layers_outlined; - break; - case HistoryLayoutMode.nineGrid: - icon = Icons.grid_3x3_rounded; - break; - } return ItemBuilder.buildAppBar( context: context, leading: Icons.arrow_back_rounded, @@ -245,15 +183,6 @@ class _HistoryScreenState extends State }, title: Text("我的足迹", style: Theme.of(context).textTheme.titleLarge), actions: [ - ItemBuilder.buildIconButton( - context: context, - icon: Icon(icon, color: Theme.of(context).iconTheme.color), - onTap: () { - _layoutMode = HistoryLayoutMode.values[ - (_layoutMode.index + 1) % HistoryLayoutMode.values.length]; - setState(() {}); - }), - const SizedBox(width: 5), ItemBuilder.buildIconButton( context: context, icon: Icon(Icons.more_vert_rounded, diff --git a/lib/Screens/Info/like_screen.dart b/lib/Screens/Info/like_screen.dart index ee1240c..baf252a 100644 --- a/lib/Screens/Info/like_screen.dart +++ b/lib/Screens/Info/like_screen.dart @@ -7,9 +7,7 @@ import 'package:loftify/Models/history_response.dart'; import 'package:loftify/Resources/theme.dart'; import 'package:loftify/Utils/hive_util.dart'; import 'package:tuple/tuple.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; -import '../../Api/post_api.dart'; import '../../Models/post_detail_response.dart'; import '../../Utils/enums.dart'; import '../../Utils/itoast.dart'; @@ -51,7 +49,6 @@ class _LikeScreenState extends State final List _likeList = []; List _archiveDataList = []; int _total = 0; - HistoryLayoutMode _layoutMode = HistoryLayoutMode.nineGrid; bool _loading = false; final EasyRefreshController _refreshController = EasyRefreshController(); bool _noMore = false; @@ -161,21 +158,12 @@ class _LikeScreenState extends State onLoad: _onLoad, triggerAxis: Axis.vertical, childBuilder: (context, physics) { - return _buildBody(physics); + return _buildNineGridGroup(physics); }, ), ); } - Widget _buildBody(ScrollPhysics physics) { - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - return _buildWaterflow(physics); - case HistoryLayoutMode.nineGrid: - return _buildNineGridGroup(physics); - } - } - Widget _buildNineGridGroup(ScrollPhysics physics) { List widgets = []; int startIndex = 0; @@ -225,61 +213,7 @@ class _LikeScreenState extends State ); } - Widget _buildWaterflow(ScrollPhysics physics) { - return ItemBuilder.buildLoadMoreNotification( - noMore: _noMore, - onLoad: _onLoad, - child: WaterfallFlow.builder( - physics: physics, - cacheExtent: 9999, - padding: const EdgeInsets.only(top: 10, left: 8, right: 8), - gridDelegate: const SliverWaterfallFlowDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 6, - crossAxisSpacing: 6, - maxCrossAxisExtent: 300, - ), - itemBuilder: (BuildContext context, int index) { - return CommonInfoItemBuilder.buildWaterfallFlowPostItem( - context, _likeList[index], onLikeTap: () async { - var item = _likeList[index]; - HapticFeedback.mediumImpact(); - return await PostApi.likeOrUnLike( - isLike: !(item.liked == true), - postId: item.post!.id, - blogId: item.post!.blogId) - .then((value) { - setState(() { - if (value['meta']['status'] != 200) { - if (Utils.isNotEmpty( - value['meta']['desc'] ?? value['meta']['msg'])) { - IToast.showTop( - value['meta']['desc'] ?? value['meta']['msg']); - } - } else { - item.liked = !(item.liked == true); - item.post!.postCount?.favoriteCount += - item.liked == true ? 1 : -1; - } - }); - return value['meta']['status']; - }); - }); - }, - itemCount: _likeList.length, - ), - ); - } - PreferredSizeWidget _buildAppBar() { - IconData icon = Icons.transform_rounded; - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - icon = Icons.layers_outlined; - break; - case HistoryLayoutMode.nineGrid: - icon = Icons.grid_3x3_rounded; - break; - } return ItemBuilder.buildAppBar( context: context, leading: Icons.arrow_back_rounded, @@ -289,15 +223,6 @@ class _LikeScreenState extends State }, title: Text("我的喜欢", style: Theme.of(context).textTheme.titleLarge), actions: [ - ItemBuilder.buildIconButton( - context: context, - icon: Icon(icon, color: Theme.of(context).iconTheme.color), - onTap: () { - _layoutMode = HistoryLayoutMode.values[ - (_layoutMode.index + 1) % HistoryLayoutMode.values.length]; - setState(() {}); - }), - const SizedBox(width: 5), ItemBuilder.buildIconButton( context: context, icon: Icon(Icons.more_vert_rounded, diff --git a/lib/Screens/Info/post_screen.dart b/lib/Screens/Info/post_screen.dart index 023d073..613456a 100644 --- a/lib/Screens/Info/post_screen.dart +++ b/lib/Screens/Info/post_screen.dart @@ -6,9 +6,7 @@ import 'package:loftify/Api/user_api.dart'; import 'package:loftify/Models/history_response.dart'; import 'package:loftify/Resources/theme.dart'; import 'package:loftify/Utils/hive_util.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; -import '../../Api/post_api.dart'; import '../../Models/post_detail_response.dart'; import '../../Utils/enums.dart'; import '../../Utils/itoast.dart'; @@ -47,7 +45,6 @@ class _PostScreenState extends State PostDetailData? _topPost; final List _postList = []; List _archiveDataList = []; - HistoryLayoutMode _layoutMode = HistoryLayoutMode.nineGrid; bool _loading = false; final EasyRefreshController _refreshController = EasyRefreshController(); bool _noMore = false; @@ -187,21 +184,12 @@ class _PostScreenState extends State onLoad: _onLoad, triggerAxis: Axis.vertical, childBuilder: (context, physics) { - return _buildBody(physics); + return _buildNineGridGroup(physics); }, ), ); } - Widget _buildBody(ScrollPhysics physics) { - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - return _buildWaterflow(physics); - case HistoryLayoutMode.nineGrid: - return _buildNineGridGroup(physics); - } - } - Widget _buildNineGridGroup(ScrollPhysics physics) { List widgets = []; int startIndex = 0; @@ -251,57 +239,7 @@ class _PostScreenState extends State ); } - Widget _buildWaterflow(ScrollPhysics physics) { - return ItemBuilder.buildLoadMoreNotification( - noMore: _noMore, - onLoad: _onLoad, - child: WaterfallFlow.builder( - physics: physics, - cacheExtent: 9999, - padding: const EdgeInsets.only(top: 10, left: 8, right: 8), - gridDelegate: const SliverWaterfallFlowDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 6, - crossAxisSpacing: 6, - maxCrossAxisExtent: 300, - ), - itemBuilder: (BuildContext context, int index) { - return CommonInfoItemBuilder.buildWaterfallFlowPostItem( - context, _postList[index], onLikeTap: () async { - var item = _postList[index]; - HapticFeedback.mediumImpact(); - return await PostApi.likeOrUnLike( - isLike: !(item.liked == true), - postId: item.post!.id, - blogId: item.post!.blogId) - .then((value) { - setState(() { - if (value['meta']['status'] != 200) { - IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']); - } else { - item.liked = !(item.liked == true); - item.post!.postCount?.favoriteCount += - item.liked == true ? 1 : -1; - } - }); - return value['meta']['status']; - }); - }); - }, - itemCount: _postList.length, - ), - ); - } - PreferredSizeWidget _buildAppBar() { - IconData icon = Icons.transform_rounded; - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - icon = Icons.layers_outlined; - break; - case HistoryLayoutMode.nineGrid: - icon = Icons.grid_3x3_rounded; - break; - } return ItemBuilder.buildAppBar( context: context, leading: Icons.arrow_back_rounded, @@ -311,15 +249,6 @@ class _PostScreenState extends State }, title: Text("我的作品", style: Theme.of(context).textTheme.titleLarge), actions: [ - ItemBuilder.buildIconButton( - context: context, - icon: Icon(icon, color: Theme.of(context).iconTheme.color), - onTap: () { - _layoutMode = HistoryLayoutMode.values[ - (_layoutMode.index + 1) % HistoryLayoutMode.values.length]; - setState(() {}); - }), - const SizedBox(width: 5), // ItemBuilder.buildIconButton( // context: context, // icon: Icon(Icons.more_vert_rounded, diff --git a/lib/Screens/Info/share_screen.dart b/lib/Screens/Info/share_screen.dart index 57f5000..1cf2e43 100644 --- a/lib/Screens/Info/share_screen.dart +++ b/lib/Screens/Info/share_screen.dart @@ -7,9 +7,7 @@ import 'package:loftify/Models/history_response.dart'; import 'package:loftify/Resources/theme.dart'; import 'package:loftify/Utils/hive_util.dart'; import 'package:tuple/tuple.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; -import '../../Api/post_api.dart'; import '../../Models/post_detail_response.dart'; import '../../Utils/enums.dart'; import '../../Utils/itoast.dart'; @@ -49,7 +47,6 @@ class _ShareScreenState extends State final List _shareList = []; List _archiveDataList = []; int _total = 0; - HistoryLayoutMode _layoutMode = HistoryLayoutMode.nineGrid; bool _loading = false; final EasyRefreshController _refreshController = EasyRefreshController(); bool _noMore = false; @@ -155,20 +152,11 @@ class _ShareScreenState extends State onRefresh: _onRefresh, onLoad: _onLoad, triggerAxis: Axis.vertical, - child: _buildBody(), + child: _buildNineGridGroup(), ), ); } - Widget _buildBody() { - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - return _buildWaterflow(); - case HistoryLayoutMode.nineGrid: - return _buildNineGridGroup(); - } - } - Widget _buildNineGridGroup() { List widgets = []; int startIndex = 0; @@ -217,56 +205,7 @@ class _ShareScreenState extends State ); } - Widget _buildWaterflow() { - return ItemBuilder.buildLoadMoreNotification( - noMore: _noMore, - onLoad: _onLoad, - child: WaterfallFlow.builder( - cacheExtent: 9999, - padding: const EdgeInsets.only(top: 10, left: 8, right: 8), - gridDelegate: const SliverWaterfallFlowDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 6, - crossAxisSpacing: 6, - maxCrossAxisExtent: 300, - ), - itemBuilder: (BuildContext context, int index) { - return CommonInfoItemBuilder.buildWaterfallFlowPostItem( - context, _shareList[index], onLikeTap: () async { - var item = _shareList[index]; - HapticFeedback.mediumImpact(); - return await PostApi.likeOrUnLike( - isLike: !(item.liked == true), - postId: item.post!.id, - blogId: item.post!.blogId) - .then((value) { - setState(() { - if (value['meta']['status'] != 200) { - IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']); - } else { - item.liked = !(item.liked == true); - item.post!.postCount?.favoriteCount += - item.liked == true ? 1 : -1; - } - }); - return value['meta']['status']; - }); - }); - }, - itemCount: _shareList.length, - ), - ); - } - PreferredSizeWidget _buildAppBar() { - IconData icon = Icons.transform_rounded; - switch (_layoutMode) { - case HistoryLayoutMode.waterFlow: - icon = Icons.layers_outlined; - break; - case HistoryLayoutMode.nineGrid: - icon = Icons.grid_3x3_rounded; - break; - } return ItemBuilder.buildAppBar( context: context, leading: Icons.arrow_back_rounded, @@ -276,15 +215,6 @@ class _ShareScreenState extends State }, title: Text("我的推荐", style: Theme.of(context).textTheme.titleLarge), actions: [ - ItemBuilder.buildIconButton( - context: context, - icon: Icon(icon, color: Theme.of(context).iconTheme.color), - onTap: () { - _layoutMode = HistoryLayoutMode.values[ - (_layoutMode.index + 1) % HistoryLayoutMode.values.length]; - setState(() {}); - }), - const SizedBox(width: 5), ItemBuilder.buildIconButton( context: context, icon: Icon(Icons.more_vert_rounded, diff --git a/lib/Screens/Info/user_detail_screen.dart b/lib/Screens/Info/user_detail_screen.dart index af796b3..3280bc6 100644 --- a/lib/Screens/Info/user_detail_screen.dart +++ b/lib/Screens/Info/user_detail_screen.dart @@ -134,6 +134,7 @@ class UserDetailScreenState extends State ItemBuilder.buildSliverAppBar( context: context, expandedHeight: _expandedHeight, + systemOverlayStyle: SystemUiOverlayStyle.light, collapsedHeight: 56, backgroundWidget: _buildBackground(height: _expandedHeight + 60), actions: _appBarActions(), @@ -298,7 +299,7 @@ class UserDetailScreenState extends State }); }, ), - preferMinWidth: 300, + preferMinWidth: 400, responsive: true, ); } else if (idx == 5) { @@ -437,15 +438,56 @@ class UserDetailScreenState extends State copyText: _fullBlogData!.blogInfo.blogNickName, toastText: "已复制昵称", ), + Text.rich( + TextSpan( + children: [ + WidgetSpan( + child: ItemBuilder.buildCopyItem( + context, + child: Text( + textAlign: TextAlign.center, + 'ID: ${_fullBlogData!.blogInfo.blogName}', + style: Theme.of(context) + .textTheme + .labelMedium + ?.apply(color: Colors.white70), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + copyText: _fullBlogData!.blogInfo.blogName, + toastText: "已复制LofterID", + ), + ), + if (hasRemarkName) + WidgetSpan( + child: ItemBuilder.buildCopyItem( + context, + child: Text( + textAlign: TextAlign.center, + ' | 备注: ${_fullBlogData!.blogInfo.remarkName}', + style: Theme.of(context) + .textTheme + .labelMedium + ?.apply(color: Colors.white70), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + copyText: _fullBlogData!.blogInfo.remarkName, + toastText: "已复制备注", + ), + ), + ], + ), + ), const SizedBox(height: 5), Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, children: [ - ItemBuilder.buildCopyItem( - context, + Flexible( + fit: FlexFit.loose, child: Text( textAlign: TextAlign.center, - 'ID: ${_fullBlogData!.blogInfo.blogName}', + '性别: ${_fullBlogData!.blogInfo.gendar == 1 ? "男" : _fullBlogData!.blogInfo.gendar == 2 ? "女" : "保密"} | IP属地: ${_fullBlogData!.blogInfo.ipLocation}', style: Theme.of(context) .textTheme .labelMedium @@ -453,39 +495,6 @@ class UserDetailScreenState extends State maxLines: 1, overflow: TextOverflow.ellipsis, ), - copyText: _fullBlogData!.blogInfo.blogName, - toastText: "已复制LofterID", - ), - if (hasRemarkName) - ItemBuilder.buildCopyItem( - context, - child: Text( - textAlign: TextAlign.center, - ' | 备注: ${_fullBlogData!.blogInfo.remarkName}', - style: Theme.of(context) - .textTheme - .labelMedium - ?.apply(color: Colors.white70), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - copyText: _fullBlogData!.blogInfo.remarkName, - toastText: "已复制备注", - ), - ], - ), - const SizedBox(height: 5), - Row( - children: [ - Text( - textAlign: TextAlign.center, - '性别: ${_fullBlogData!.blogInfo.gendar == 1 ? "男" : _fullBlogData!.blogInfo.gendar == 2 ? "女" : "保密"} | IP属地: ${_fullBlogData!.blogInfo.ipLocation}', - style: Theme.of(context) - .textTheme - .labelMedium - ?.apply(color: Colors.white70), - maxLines: 1, - overflow: TextOverflow.ellipsis, ), const SizedBox(width: 5), if (Utils.isNotEmpty( diff --git a/lib/Screens/Setting/general_setting_screen.dart b/lib/Screens/Setting/general_setting_screen.dart index 64fbcb8..95218c6 100644 --- a/lib/Screens/Setting/general_setting_screen.dart +++ b/lib/Screens/Setting/general_setting_screen.dart @@ -177,10 +177,10 @@ class _GeneralSettingScreenState extends State context: context, title: S.current.checkUpdates, bottomRadius: true, - description: latestVersion.compareTo(currentVersion) > 0 + description: Utils.compareVersion(latestVersion,currentVersion) > 0 ? "新版本:$latestVersion" : S.current.checkUpdatesAlreadyLatest, - descriptionColor: latestVersion.compareTo(currentVersion) > 0 + descriptionColor: Utils.compareVersion(latestVersion,currentVersion) > 0 ? Colors.redAccent : null, tip: currentVersion, diff --git a/lib/Screens/Setting/tagshield_setting_screen.dart b/lib/Screens/Setting/tagshield_setting_screen.dart index 67a4bcf..ca591f9 100644 --- a/lib/Screens/Setting/tagshield_setting_screen.dart +++ b/lib/Screens/Setting/tagshield_setting_screen.dart @@ -88,7 +88,7 @@ class _TagShieldSettingScreenState extends State }); }, ), - preferMinWidth: 300, + preferMinWidth: 400, responsive: true, ); }, diff --git a/lib/Screens/Setting/update_log_screen.dart b/lib/Screens/Setting/update_log_screen.dart index d28d4f6..5c993c5 100644 --- a/lib/Screens/Setting/update_log_screen.dart +++ b/lib/Screens/Setting/update_log_screen.dart @@ -111,9 +111,9 @@ class _UpdateLogScreenState extends State ?.apply(fontSizeDelta: 1), ), const SizedBox(width: 6), - if (item.tagName - .replaceAll(RegExp(r'[a-zA-Z]'), '') - .compareTo(currentVersion) == + if (Utils.compareVersion( + item.tagName.replaceAll(RegExp(r'[a-zA-Z]'), ''), + currentVersion) == 0) ItemBuilder.buildRoundButton( context, diff --git a/lib/Utils/utils.dart b/lib/Utils/utils.dart index f360d20..d3ea9c3 100644 --- a/lib/Utils/utils.dart +++ b/lib/Utils/utils.dart @@ -455,6 +455,23 @@ class Utils { } } + static compareVersion(String a, String b) { + try { + List aList = a.split("."); + List bList = b.split("."); + for (int i = 0; i < aList.length; i++) { + if (int.parse(aList[i]) > int.parse(bList[i])) { + return 1; + } else if (int.parse(aList[i]) < int.parse(bList[i])) { + return -1; + } + } + return 0; + } catch (e) { + return a.compareTo(b); + } + } + static getReleases({ required BuildContext context, Function(String)? onGetCurrentVersion, @@ -470,7 +487,7 @@ class Utils { } String currentVersion = (await PackageInfo.fromPlatform()).version; onGetCurrentVersion?.call(currentVersion); - String latestVersion = currentVersion; + String latestVersion = "0.0.0"; await GithubApi.getReleases("Robert-Stackflow", "Loftify") .then((releases) async { onGetReleases?.call(releases); @@ -478,7 +495,7 @@ class Utils { for (var release in releases) { String tagName = release.tagName; tagName = tagName.replaceAll(RegExp(r'[a-zA-Z]'), ''); - if (latestVersion.compareTo(tagName) <= 0) { + if (compareVersion(latestVersion, tagName) <= 0) { latestVersion = tagName; latestReleaseItem = release; } @@ -487,7 +504,7 @@ class Utils { if (showLoading) { CustomLoadingDialog.dismissLoading(); } - if (latestVersion.compareTo(currentVersion) > 0) { + if (compareVersion(latestVersion, currentVersion) > 0) { onUpdate?.call(latestVersion, latestReleaseItem!); if (showUpdateDialog && latestReleaseItem != null) { if (ResponsiveUtil.isMobile()) { diff --git a/lib/Widgets/Item/item_builder.dart b/lib/Widgets/Item/item_builder.dart index 7142da3..57d3a27 100644 --- a/lib/Widgets/Item/item_builder.dart +++ b/lib/Widgets/Item/item_builder.dart @@ -152,10 +152,12 @@ class ItemBuilder { bool center = false, double expandedHeight = 320, double? collapsedHeight, + SystemUiOverlayStyle? systemOverlayStyle, }) { bool showLeading = !ResponsiveUtil.isLandscape(); center = ResponsiveUtil.isLandscape() ? false : center; return MySliverAppBar( + systemOverlayStyle: systemOverlayStyle, expandedHeight: expandedHeight, collapsedHeight: collapsedHeight ?? max(100, kToolbarHeight + MediaQuery.of(context).padding.top), @@ -2613,6 +2615,8 @@ class ItemBuilder { child: Text( str, style: Theme.of(context).textTheme.titleSmall, + maxLines: 1, + overflow: TextOverflow.ellipsis, ), ), ),