mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-12 05:41:37 +08:00
@@ -20,7 +20,7 @@ import 'package:PiliPlus/utils/request_utils.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:app_links/app_links.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/services.dart' show HapticFeedback;
|
||||
|
||||
bool enableFeedback = Pref.feedBackEnable;
|
||||
void feedBack() {
|
||||
if (enableFeedback) {
|
||||
HapticFeedback.lightImpact();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,13 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/services.dart' show MethodChannel;
|
||||
|
||||
abstract final class MaxScreenSize {
|
||||
static int? _maxWidth;
|
||||
static int? _maxHeight;
|
||||
|
||||
static Future<void> init() {
|
||||
return Future.wait([_initFoldable(), _initScreenSize()]);
|
||||
}
|
||||
|
||||
static Future<void> _initFoldable() async {
|
||||
final isFoldable = await Utils.channel.invokeMethod('isFoldable');
|
||||
if (isFoldable == true) {
|
||||
const MethodChannel('ScreenChannel').setMethodCallHandler((call) async {
|
||||
if (call.method == 'onConfigChanged') {
|
||||
_handleRes(call.arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
return _initScreenSize();
|
||||
}
|
||||
|
||||
static Future<void> _initScreenSize() async {
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:PiliPlus/utils/extension/extension.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
@@ -209,8 +208,6 @@ abstract final class PageUtils {
|
||||
DynamicItemModel item, {
|
||||
bool isPush = false,
|
||||
}) async {
|
||||
feedBack();
|
||||
|
||||
void push() {
|
||||
if (item.basic?.commentType == 12) {
|
||||
toDupNamed(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/foundation.dart' show VoidCallback;
|
||||
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
|
||||
|
||||
export 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
|
||||
|
||||
@@ -31,7 +31,6 @@ import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
@@ -142,7 +141,6 @@ abstract final class RequestUtils {
|
||||
if (mid == null) {
|
||||
return;
|
||||
}
|
||||
feedBack();
|
||||
if (!isFollow) {
|
||||
final res = await VideoHttp.relationMod(
|
||||
mid: mid,
|
||||
@@ -396,8 +394,6 @@ abstract final class RequestUtils {
|
||||
bool uiStatus,
|
||||
VoidCallback onSuccess,
|
||||
) async {
|
||||
feedBack();
|
||||
|
||||
final like = item.modules.moduleStat?.like;
|
||||
final status = like?.status ?? false;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ abstract final class SettingBoxKey {
|
||||
fullScreenMode = 'fullScreenMode',
|
||||
defaultDecode = 'defaultDecode',
|
||||
secondDecode = 'secondDecode',
|
||||
defaultToastOp = 'defaultToastOp',
|
||||
defaultPicQa = 'defaultPicQa',
|
||||
enableHA = 'enableHA',
|
||||
audioOutput = 'audioOutput',
|
||||
@@ -31,8 +30,6 @@ abstract final class SettingBoxKey {
|
||||
showBatteryLevel = 'showBatteryLevel';
|
||||
|
||||
static const String enableVerticalExpand = 'enableVerticalExpand',
|
||||
feedBackEnable = 'feedBackEnable',
|
||||
enableLongShowControl = 'enableLongShowControl',
|
||||
horizontalScreen = 'horizontalScreen',
|
||||
CDNService = 'CDNService',
|
||||
disableAudioCDN = 'disableAudioCDN',
|
||||
@@ -52,7 +49,6 @@ abstract final class SettingBoxKey {
|
||||
exemptFilterForFollowed = 'exemptFilterForFollowed',
|
||||
banWordForRecommend = 'banWordForRecommend',
|
||||
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
|
||||
autoUpdate = 'autoUpdate',
|
||||
autoClearCache = 'autoClearCache',
|
||||
maxCacheSize = 'maxCacheSize',
|
||||
defaultShowComment = 'defaultShowComment',
|
||||
@@ -62,11 +58,8 @@ abstract final class SettingBoxKey {
|
||||
enableHotKey = 'enableHotKey',
|
||||
enableSearchRcmd = 'enableSearchRcmd',
|
||||
enableQuickFav = 'enableQuickFav',
|
||||
enableWordRe = 'enableWordRe',
|
||||
enableSearchWord = 'enableSearchWord',
|
||||
enableSystemProxy = 'enableSystemProxy',
|
||||
enableAi = 'enableAi',
|
||||
disableLikeMsg = 'disableLikeMsg',
|
||||
defaultHomePage = 'defaultHomePage',
|
||||
previewQuality = 'previewQuality',
|
||||
checkDynamic = 'checkDynamic',
|
||||
@@ -80,7 +73,6 @@ abstract final class SettingBoxKey {
|
||||
expandIntroPanelH = 'exapndIntroPanelH',
|
||||
horizontalSeasonPanel = 'horizontalSeasonPanel',
|
||||
horizontalMemberPage = 'horizontalMemberPage',
|
||||
replyLengthLimit = 'replyLengthLimit',
|
||||
showArgueMsg = 'showArgueMsg',
|
||||
reverseFromFirst = 'reverseFromFirst',
|
||||
badCertificateCallback = 'badCertificateCallback',
|
||||
@@ -98,7 +90,6 @@ abstract final class SettingBoxKey {
|
||||
fallbackNormalization = 'fallbackNormalization',
|
||||
superResolutionType = 'superResolutionType',
|
||||
preInitPlayer = 'preInitPlayer',
|
||||
mainTabBarView = 'mainTabBarView',
|
||||
searchSuggestion = 'searchSuggestion',
|
||||
showDecorate = 'showDynDecorate',
|
||||
showMedal = 'showMedal',
|
||||
@@ -117,7 +108,6 @@ abstract final class SettingBoxKey {
|
||||
enableHttp2 = 'enableHttp2',
|
||||
slideDismissReplyPage = 'slideDismissReplyPage',
|
||||
showFSActionItem = 'showFSActionItem',
|
||||
enableShrinkVideoSize = 'enableShrinkVideoSize',
|
||||
showDynActionBar = 'showDynActionBar',
|
||||
darkVideoPage = 'darkVideoPage',
|
||||
enableSlideVolumeBrightness = 'enableSlideVolumeBrightness',
|
||||
@@ -126,12 +116,10 @@ abstract final class SettingBoxKey {
|
||||
retryDelay = 'retryDelay',
|
||||
liveQuality = 'liveQuality',
|
||||
liveQualityCellular = 'liveQualityCellular',
|
||||
appFontWeight = 'appFontWeight',
|
||||
fastForBackwardDuration = 'fastForBackwardDuration',
|
||||
recordSearchHistory = 'recordSearchHistory',
|
||||
showPgcTimeline = 'showPgcTimeline',
|
||||
pageTransition = 'pageTransition',
|
||||
optTabletNav = 'optTabletNav',
|
||||
banWordForDyn = 'banWordForDyn',
|
||||
enableLog = 'enableLog',
|
||||
memberTab = 'memberTab',
|
||||
@@ -213,14 +201,11 @@ abstract final class SettingBoxKey {
|
||||
defaultTextScale = 'textScale',
|
||||
dynamicColor = 'dynamicColor',
|
||||
customColor = 'customColor',
|
||||
displayMode = 'displayMode',
|
||||
smallCardWidth = 'smallCardWidth',
|
||||
recommendCardWidth = 'recommendCardWidth',
|
||||
dynamicsWaterfallFlow = 'dynamicsWaterfallFlow',
|
||||
upPanelPosition = 'upPanelPosition',
|
||||
dynamicsShowAllFollowedUp = 'dynamicsShowAllFollowedUp',
|
||||
useSideBar = 'useSideBar',
|
||||
enableMYBar = 'enableMYBar',
|
||||
hideTopBar = 'hideSearchBar',
|
||||
hideBottomBar = 'hideTabBar',
|
||||
barHideType = 'barHideType',
|
||||
@@ -230,7 +215,6 @@ abstract final class SettingBoxKey {
|
||||
msgUnReadTypeV2 = 'msgUnReadTypeV2',
|
||||
navBarSort = 'navBarSort',
|
||||
tempPlayerConf = 'tempPlayerConf',
|
||||
reduceLuxColor = 'reduceLuxColor',
|
||||
liveCdnUrl = 'liveCdnUrl',
|
||||
saveReply = 'saveReply';
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:flex_seed_scheme/flex_seed_scheme.dart' show FlexSchemeVariant;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive_ce/hive.dart';
|
||||
@@ -145,9 +144,6 @@ abstract final class Pref {
|
||||
).toList();
|
||||
}
|
||||
|
||||
static bool get feedBackEnable =>
|
||||
_setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
|
||||
|
||||
static int get picQuality =>
|
||||
_setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||
|
||||
@@ -334,7 +330,7 @@ abstract final class Pref {
|
||||
);
|
||||
|
||||
static bool get blockTrack =>
|
||||
_setting.get(SettingBoxKey.blockTrack, defaultValue: !kDebugMode);
|
||||
_setting.get(SettingBoxKey.blockTrack, defaultValue: false);
|
||||
|
||||
static bool get checkDynamic =>
|
||||
_setting.get(SettingBoxKey.checkDynamic, defaultValue: true);
|
||||
@@ -396,14 +392,6 @@ abstract final class Pref {
|
||||
defaultValue: horizontalScreen,
|
||||
);
|
||||
|
||||
static int? get replyLengthLimit {
|
||||
int length = _setting.get(SettingBoxKey.replyLengthLimit, defaultValue: 6);
|
||||
if (length <= 0) {
|
||||
return null;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
static int get defaultPicQa =>
|
||||
_setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||
|
||||
@@ -440,9 +428,6 @@ abstract final class Pref {
|
||||
static bool get cdnSpeedTest =>
|
||||
_setting.get(SettingBoxKey.cdnSpeedTest, defaultValue: true);
|
||||
|
||||
static bool get autoUpdate =>
|
||||
_setting.get(SettingBoxKey.autoUpdate, defaultValue: true);
|
||||
|
||||
static bool get horizontalPreview =>
|
||||
_setting.get(SettingBoxKey.horizontalPreview, defaultValue: false);
|
||||
|
||||
@@ -479,9 +464,6 @@ abstract final class Pref {
|
||||
static bool get preInitPlayer =>
|
||||
_setting.get(SettingBoxKey.preInitPlayer, defaultValue: false);
|
||||
|
||||
static bool get mainTabBarView =>
|
||||
_setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
|
||||
|
||||
static bool get searchSuggestion =>
|
||||
_setting.get(SettingBoxKey.searchSuggestion, defaultValue: true);
|
||||
|
||||
@@ -533,9 +515,6 @@ abstract final class Pref {
|
||||
static bool get showFSActionItem =>
|
||||
_setting.get(SettingBoxKey.showFSActionItem, defaultValue: true);
|
||||
|
||||
static bool get enableShrinkVideoSize =>
|
||||
_setting.get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true);
|
||||
|
||||
static bool get showDynActionBar =>
|
||||
_setting.get(SettingBoxKey.showDynActionBar, defaultValue: true);
|
||||
|
||||
@@ -566,9 +545,6 @@ abstract final class Pref {
|
||||
defaultValue: LiveQuality.superHD.code,
|
||||
);
|
||||
|
||||
static int get appFontWeight =>
|
||||
_setting.get(SettingBoxKey.appFontWeight, defaultValue: -1);
|
||||
|
||||
static bool get enableDragSubtitle =>
|
||||
_setting.get(SettingBoxKey.enableDragSubtitle, defaultValue: false);
|
||||
|
||||
@@ -596,9 +572,6 @@ abstract final class Pref {
|
||||
static num get maxCacheSize =>
|
||||
_setting.get(SettingBoxKey.maxCacheSize) ?? pow(1024, 3);
|
||||
|
||||
static bool get optTabletNav =>
|
||||
_setting.get(SettingBoxKey.optTabletNav, defaultValue: true);
|
||||
|
||||
static bool get horizontalScreen {
|
||||
bool? horizontalScreen = _setting.get(SettingBoxKey.horizontalScreen);
|
||||
if (horizontalScreen == null) {
|
||||
@@ -638,12 +611,6 @@ abstract final class Pref {
|
||||
static bool get enableBackgroundPlay =>
|
||||
_setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true);
|
||||
|
||||
static bool get disableLikeMsg =>
|
||||
_setting.get(SettingBoxKey.disableLikeMsg, defaultValue: false);
|
||||
|
||||
static bool get enableWordRe =>
|
||||
_setting.get(SettingBoxKey.enableWordRe, defaultValue: false);
|
||||
|
||||
static bool get autoExitFullscreen =>
|
||||
_setting.get(SettingBoxKey.enableAutoExit, defaultValue: true);
|
||||
|
||||
@@ -683,12 +650,6 @@ abstract final class Pref {
|
||||
defaultValue: BarHideType.sync.index,
|
||||
)];
|
||||
|
||||
static bool get enableSearchWord =>
|
||||
_setting.get(SettingBoxKey.enableSearchWord, defaultValue: false);
|
||||
|
||||
static bool get useSideBar =>
|
||||
_setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
||||
|
||||
static bool get dynamicsShowAllFollowedUp => _setting.get(
|
||||
SettingBoxKey.dynamicsShowAllFollowedUp,
|
||||
defaultValue: false,
|
||||
@@ -734,9 +695,6 @@ abstract final class Pref {
|
||||
defaultValue: DynamicBadgeMode.number.index,
|
||||
)];
|
||||
|
||||
static bool get enableMYBar =>
|
||||
_setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||
|
||||
static Transition get pageTransition =>
|
||||
Transition.values[_setting.get(
|
||||
SettingBoxKey.pageTransition,
|
||||
@@ -792,9 +750,6 @@ abstract final class Pref {
|
||||
defaultValue: PlatformUtils.isMobile ? 5 : 6,
|
||||
);
|
||||
|
||||
static bool get enableLongShowControl =>
|
||||
_setting.get(SettingBoxKey.enableLongShowControl, defaultValue: false);
|
||||
|
||||
static bool get expandBuffer =>
|
||||
_setting.get(SettingBoxKey.expandBuffer, defaultValue: false);
|
||||
|
||||
@@ -833,9 +788,6 @@ abstract final class Pref {
|
||||
static bool get enableSaveLastData =>
|
||||
_setting.get(SettingBoxKey.enableSaveLastData, defaultValue: true);
|
||||
|
||||
static double get defaultToastOp =>
|
||||
_setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
|
||||
|
||||
static PlayRepeat get playRepeat =>
|
||||
PlayRepeat.values[_video.get(
|
||||
VideoBoxKey.playRepeat,
|
||||
@@ -859,14 +811,6 @@ abstract final class Pref {
|
||||
static bool get tempPlayerConf =>
|
||||
_setting.get(SettingBoxKey.tempPlayerConf, defaultValue: false);
|
||||
|
||||
static Color? get reduceLuxColor {
|
||||
final int? color = _setting.get(SettingBoxKey.reduceLuxColor);
|
||||
if (color != null && color != 0xFFFFFFFF) {
|
||||
return Color(color);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool get showFsScreenshotBtn =>
|
||||
_setting.get(SettingBoxKey.showFsScreenshotBtn, defaultValue: true);
|
||||
|
||||
@@ -914,8 +858,10 @@ abstract final class Pref {
|
||||
static bool get isWindowMaximized =>
|
||||
_setting.get(SettingBoxKey.isWindowMaximized, defaultValue: false);
|
||||
|
||||
static bool get keyboardControl =>
|
||||
_setting.get(SettingBoxKey.keyboardControl, defaultValue: true);
|
||||
static bool get keyboardControl => _setting.get(
|
||||
SettingBoxKey.keyboardControl,
|
||||
defaultValue: PlatformUtils.isDesktop,
|
||||
);
|
||||
|
||||
static bool get pauseOnMinimize =>
|
||||
_setting.get(SettingBoxKey.pauseOnMinimize, defaultValue: false);
|
||||
|
||||
@@ -31,39 +31,9 @@ abstract final class ThemeUtils {
|
||||
required bool isDynamic,
|
||||
bool isDark = false,
|
||||
}) {
|
||||
final appFontWeight = Pref.appFontWeight.clamp(
|
||||
-1,
|
||||
FontWeight.values.length - 1,
|
||||
);
|
||||
final fontWeight = appFontWeight == -1
|
||||
? null
|
||||
: FontWeight.values[appFontWeight];
|
||||
late final textStyle = TextStyle(fontWeight: fontWeight);
|
||||
ThemeData themeData = ThemeData(
|
||||
colorScheme: colorScheme,
|
||||
useMaterial3: true,
|
||||
textTheme: fontWeight == null
|
||||
? null
|
||||
: TextTheme(
|
||||
displayLarge: textStyle,
|
||||
displayMedium: textStyle,
|
||||
displaySmall: textStyle,
|
||||
headlineLarge: textStyle,
|
||||
headlineMedium: textStyle,
|
||||
headlineSmall: textStyle,
|
||||
titleLarge: textStyle,
|
||||
titleMedium: textStyle,
|
||||
titleSmall: textStyle,
|
||||
bodyLarge: textStyle,
|
||||
bodyMedium: textStyle,
|
||||
bodySmall: textStyle,
|
||||
labelLarge: textStyle,
|
||||
labelMedium: textStyle,
|
||||
labelSmall: textStyle,
|
||||
),
|
||||
tabBarTheme: fontWeight == null
|
||||
? null
|
||||
: TabBarThemeData(labelStyle: textStyle),
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
@@ -73,7 +43,6 @@ abstract final class ThemeUtils {
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
color: colorScheme.onSurface,
|
||||
fontWeight: fontWeight,
|
||||
),
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
@@ -108,7 +77,6 @@ abstract final class ThemeUtils {
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 18,
|
||||
color: colorScheme.onSurface,
|
||||
fontWeight: fontWeight,
|
||||
),
|
||||
backgroundColor: colorScheme.surface,
|
||||
constraints: const BoxConstraints(minWidth: 280, maxWidth: 420),
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/build_config.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/browser_ua.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
abstract final class Update {
|
||||
// 检查更新
|
||||
static Future<void> checkUpdate([bool isAuto = true]) async {
|
||||
if (kDebugMode) return;
|
||||
SmartDialog.dismiss();
|
||||
try {
|
||||
final res = await Request().get(
|
||||
Api.latestApp,
|
||||
options: Options(
|
||||
headers: {'user-agent': BrowserUa.mob},
|
||||
extra: {'account': const NoAccount()},
|
||||
),
|
||||
);
|
||||
if (res.data is Map || res.data.isEmpty) {
|
||||
if (!isAuto) {
|
||||
SmartDialog.showToast('检查更新失败,GitHub接口未返回数据,请检查网络');
|
||||
}
|
||||
return;
|
||||
}
|
||||
final data = res.data[0];
|
||||
final int latest =
|
||||
DateTime.parse(data['created_at']).millisecondsSinceEpoch ~/ 1000;
|
||||
if (BuildConfig.buildTime >= latest) {
|
||||
if (!isAuto) {
|
||||
SmartDialog.showToast('已是最新版本');
|
||||
}
|
||||
} else {
|
||||
SmartDialog.show(
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
Widget downloadBtn(String text, {String? ext}) => TextButton(
|
||||
onPressed: () => onDownload(data, ext: ext),
|
||||
child: Text(text),
|
||||
);
|
||||
return AlertDialog(
|
||||
title: const Text('🎉 发现新版本 '),
|
||||
content: SizedBox(
|
||||
height: 280,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${data['tag_name']}',
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text('${data['body']}'),
|
||||
TextButton(
|
||||
onPressed: () => PageUtils.launchURL(
|
||||
'${Constants.sourceCodeUrl}/commits/main',
|
||||
),
|
||||
child: Text(
|
||||
"点此查看完整更新(即commit)内容",
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (isAuto)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
GStorage.setting.put(SettingBoxKey.autoUpdate, false);
|
||||
},
|
||||
child: Text(
|
||||
'不再提醒',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: SmartDialog.dismiss,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (Platform.isWindows) ...[
|
||||
downloadBtn('zip', ext: 'zip'),
|
||||
downloadBtn('exe', ext: 'exe'),
|
||||
] else if (Platform.isLinux) ...[
|
||||
downloadBtn('rpm', ext: 'rpm'),
|
||||
downloadBtn('deb', ext: 'deb'),
|
||||
downloadBtn('targz', ext: 'tar.gz'),
|
||||
] else
|
||||
downloadBtn('Github'),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) debugPrint('failed to check update: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 下载适用于当前系统的安装包
|
||||
static Future<void> onDownload(Map data, {String? ext}) async {
|
||||
SmartDialog.dismiss();
|
||||
try {
|
||||
void download(String plat) {
|
||||
if (data['assets'].isNotEmpty) {
|
||||
for (Map<String, dynamic> i in data['assets']) {
|
||||
final String name = i['name'];
|
||||
if (name.contains(plat) &&
|
||||
(ext == null || ext.isEmpty ? true : name.endsWith(ext))) {
|
||||
PageUtils.launchURL(i['browser_download_url']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw UnsupportedError('platform not found: $plat');
|
||||
}
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
// 获取设备信息
|
||||
AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||
// [arm64-v8a]
|
||||
download(androidInfo.supportedAbis.first);
|
||||
} else {
|
||||
download(Platform.operatingSystem);
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) debugPrint('download error: $e');
|
||||
PageUtils.launchURL('${Constants.sourceCodeUrl}/releases/latest');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user