mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-02 09:08:17 +08:00
tweaks (#1444)
* opt: proxy * opt: calcWindowPosition * fix: height depend on svg * bump * fix * ci: cache linux * string systemProxyPort --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
a928e48159
commit
a5715868b3
33
.github/workflows/android.yml
vendored
33
.github/workflows/android.yml
vendored
@@ -17,41 +17,35 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 代码迁出
|
- name: 代码迁出
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: 构建Java环境
|
- name: 构建Java环境
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: "zulu"
|
distribution: "zulu"
|
||||||
java-version: "17"
|
java-version: "17"
|
||||||
|
cache: 'gradle'
|
||||||
- name: 检查缓存
|
cache-dependency-path: |
|
||||||
uses: actions/cache@v4
|
android/*.gradle*
|
||||||
id: cache-flutter
|
android/**/gradle-wrapper.properties
|
||||||
with:
|
|
||||||
path: /root/flutter-sdk # Flutter SDK 的路径
|
|
||||||
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
|
|
||||||
|
|
||||||
- name: 安装Flutter
|
- name: 安装Flutter
|
||||||
if: steps.cache-flutter.outputs.cache-hit != 'true'
|
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
|
id: flutter-action
|
||||||
with:
|
with:
|
||||||
channel: stable
|
channel: stable
|
||||||
flutter-version-file: pubspec.yaml
|
flutter-version-file: pubspec.yaml
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: apply bottom sheet patch
|
- name: apply bottom sheet patch
|
||||||
|
if: steps.flutter-action.outputs.CACHE-HIT != 'true'
|
||||||
working-directory: ${{ env.FLUTTER_ROOT }}
|
working-directory: ${{ env.FLUTTER_ROOT }}
|
||||||
run: |
|
run: git apply $GITHUB_WORKSPACE/lib/scripts/bottom_sheet_patch.diff
|
||||||
git apply $GITHUB_WORKSPACE/lib/scripts/bottom_sheet_patch.diff
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add .
|
|
||||||
git commit -m "bottom sheet patch"
|
|
||||||
|
|
||||||
- name: 下载项目依赖
|
# - name: 下载项目依赖
|
||||||
run: flutter pub get
|
# run: flutter pub get
|
||||||
|
|
||||||
- name: Write key
|
- name: Write key
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@@ -66,9 +60,8 @@ jobs:
|
|||||||
|
|
||||||
- name: flutter build apk
|
- name: flutter build apk
|
||||||
run: |
|
run: |
|
||||||
chmod +x lib/scripts/build.dart
|
|
||||||
dart lib/scripts/build.dart "android"
|
dart lib/scripts/build.dart "android"
|
||||||
flutter build apk --release --split-per-abi
|
flutter build apk --release --split-per-abi --pub
|
||||||
|
|
||||||
- name: 上传
|
- name: 上传
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
9
.github/workflows/linux.yml
vendored
9
.github/workflows/linux.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.inputs.branch }}
|
ref: ${{ github.event.inputs.branch }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -51,10 +51,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
channel: stable
|
channel: stable
|
||||||
flutter-version-file: pubspec.yaml
|
flutter-version-file: pubspec.yaml
|
||||||
|
cache: true
|
||||||
- name: Get Flutter dependencies
|
|
||||||
run: flutter pub get
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Set and Extract version
|
- name: Set and Extract version
|
||||||
run: |
|
run: |
|
||||||
@@ -65,7 +62,7 @@ jobs:
|
|||||||
|
|
||||||
#TODO: deb and rpm packages need to be build
|
#TODO: deb and rpm packages need to be build
|
||||||
- name: Build Linux
|
- name: Build Linux
|
||||||
run: flutter build linux --release -v
|
run: flutter build linux --release -v --pub
|
||||||
|
|
||||||
- name: Package .tar.gz
|
- name: Package .tar.gz
|
||||||
run: tar -zcvf PiliPlus_linux_${{ env.version }}_amd64.tar.gz -C build/linux/x64/release/bundle .
|
run: tar -zcvf PiliPlus_linux_${{ env.version }}_amd64.tar.gz -C build/linux/x64/release/bundle .
|
||||||
|
|||||||
226
lib/common/widgets/cached_network_svg_image.dart
Normal file
226
lib/common/widgets/cached_network_svg_image.dart
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
// code from cached_network_svg_image;
|
||||||
|
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
class CachedNetworkSVGImage extends StatefulWidget {
|
||||||
|
CachedNetworkSVGImage(
|
||||||
|
String url, {
|
||||||
|
Key? key,
|
||||||
|
String? cacheKey,
|
||||||
|
Widget? placeholder,
|
||||||
|
Widget? errorWidget,
|
||||||
|
double? width,
|
||||||
|
double? height,
|
||||||
|
Map<String, String>? headers,
|
||||||
|
BoxFit fit = BoxFit.contain,
|
||||||
|
AlignmentGeometry alignment = Alignment.center,
|
||||||
|
bool matchTextDirection = false,
|
||||||
|
bool allowDrawingOutsideViewBox = false,
|
||||||
|
String? semanticsLabel,
|
||||||
|
bool excludeFromSemantics = false,
|
||||||
|
SvgTheme theme = const SvgTheme(),
|
||||||
|
ColorFilter? colorFilter,
|
||||||
|
WidgetBuilder? placeholderBuilder,
|
||||||
|
BaseCacheManager? cacheManager,
|
||||||
|
}) : _url = url,
|
||||||
|
_cacheKey = cacheKey,
|
||||||
|
_placeholder = placeholder,
|
||||||
|
_errorWidget = errorWidget,
|
||||||
|
_width = width,
|
||||||
|
_height = height,
|
||||||
|
_headers = headers,
|
||||||
|
_fit = fit,
|
||||||
|
_alignment = alignment,
|
||||||
|
_matchTextDirection = matchTextDirection,
|
||||||
|
_allowDrawingOutsideViewBox = allowDrawingOutsideViewBox,
|
||||||
|
_semanticsLabel = semanticsLabel,
|
||||||
|
_excludeFromSemantics = excludeFromSemantics,
|
||||||
|
_theme = theme,
|
||||||
|
_colorFilter = colorFilter,
|
||||||
|
_placeholderBuilder = placeholderBuilder,
|
||||||
|
_cacheManager = cacheManager ?? DefaultCacheManager(),
|
||||||
|
super(key: key ?? ValueKey(cacheKey ?? url));
|
||||||
|
|
||||||
|
final String _url;
|
||||||
|
final String? _cacheKey;
|
||||||
|
final Widget? _placeholder;
|
||||||
|
final Widget? _errorWidget;
|
||||||
|
final double? _width;
|
||||||
|
final double? _height;
|
||||||
|
final Map<String, String>? _headers;
|
||||||
|
final BoxFit _fit;
|
||||||
|
final AlignmentGeometry _alignment;
|
||||||
|
final bool _matchTextDirection;
|
||||||
|
final bool _allowDrawingOutsideViewBox;
|
||||||
|
final String? _semanticsLabel;
|
||||||
|
final bool _excludeFromSemantics;
|
||||||
|
final SvgTheme _theme;
|
||||||
|
final ColorFilter? _colorFilter;
|
||||||
|
final WidgetBuilder? _placeholderBuilder;
|
||||||
|
final BaseCacheManager _cacheManager;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CachedNetworkSVGImage> createState() => _CachedNetworkSVGImageState();
|
||||||
|
|
||||||
|
static Future<void> preCache(
|
||||||
|
String imageUrl, {
|
||||||
|
String? cacheKey,
|
||||||
|
BaseCacheManager? cacheManager,
|
||||||
|
}) {
|
||||||
|
final key = cacheKey ?? _generateKeyFromUrl(imageUrl);
|
||||||
|
cacheManager ??= DefaultCacheManager();
|
||||||
|
return cacheManager.downloadFile(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> clearCacheForUrl(
|
||||||
|
String imageUrl, {
|
||||||
|
String? cacheKey,
|
||||||
|
BaseCacheManager? cacheManager,
|
||||||
|
}) {
|
||||||
|
final key = cacheKey ?? _generateKeyFromUrl(imageUrl);
|
||||||
|
cacheManager ??= DefaultCacheManager();
|
||||||
|
return cacheManager.removeFile(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> clearCache({BaseCacheManager? cacheManager}) {
|
||||||
|
cacheManager ??= DefaultCacheManager();
|
||||||
|
return cacheManager.emptyCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String _generateKeyFromUrl(String url) => url.split('?').first;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CachedNetworkSVGImageState extends State<CachedNetworkSVGImage> {
|
||||||
|
bool _isLoading = false;
|
||||||
|
bool _isError = false;
|
||||||
|
String? _svgString;
|
||||||
|
late final String _cacheKey;
|
||||||
|
double? height;
|
||||||
|
late TextScaler textScaler;
|
||||||
|
|
||||||
|
static final _sizeRegExp = RegExp(
|
||||||
|
r'height="([\d\.]+)([c-x]{2})?"',
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_cacheKey =
|
||||||
|
widget._cacheKey ??
|
||||||
|
CachedNetworkSVGImage._generateKeyFromUrl(widget._url);
|
||||||
|
_loadImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
textScaler = MediaQuery.textScalerOf(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadImage() async {
|
||||||
|
try {
|
||||||
|
var file = (await widget._cacheManager.getFileFromMemory(
|
||||||
|
_cacheKey,
|
||||||
|
))?.file;
|
||||||
|
|
||||||
|
file ??= await widget._cacheManager.getSingleFile(
|
||||||
|
widget._url,
|
||||||
|
key: _cacheKey,
|
||||||
|
headers: widget._headers ?? {},
|
||||||
|
);
|
||||||
|
final svg = await file.readAsString();
|
||||||
|
_svgString = svg;
|
||||||
|
if (widget._width == null && widget._height == null) {
|
||||||
|
final match = _sizeRegExp.firstMatch(svg);
|
||||||
|
if (match != null) {
|
||||||
|
double h = double.parse(match.group(1)!);
|
||||||
|
final suffix = match.group(2);
|
||||||
|
if (suffix != null) {
|
||||||
|
h *= switch (suffix) {
|
||||||
|
'em' => textScaler.scale(widget._theme.fontSize),
|
||||||
|
'ex' => textScaler.scale(widget._theme.xHeight),
|
||||||
|
'pt' => 1.25,
|
||||||
|
'pc' => 15.0,
|
||||||
|
'mm' => 3.543307,
|
||||||
|
'cm' => 35.43307,
|
||||||
|
'in' => 90.0,
|
||||||
|
_ => 1.0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
height = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_isLoading = false;
|
||||||
|
|
||||||
|
_setState();
|
||||||
|
} catch (e) {
|
||||||
|
log('CachedNetworkSVGImage: $e');
|
||||||
|
|
||||||
|
_isError = true;
|
||||||
|
_isLoading = false;
|
||||||
|
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _setState() {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
SchedulerBinding.instance.addPostFrameCallback((_) => setState(() {}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: widget._width,
|
||||||
|
height: widget._height,
|
||||||
|
child: _buildImage(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _buildImage() {
|
||||||
|
if (_isLoading) return _buildPlaceholderWidget();
|
||||||
|
|
||||||
|
if (_isError) return _buildErrorWidget();
|
||||||
|
|
||||||
|
return _buildSVGImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPlaceholderWidget() => Center(child: widget._placeholder);
|
||||||
|
|
||||||
|
Widget _buildErrorWidget() => Center(child: widget._errorWidget);
|
||||||
|
|
||||||
|
Widget? _buildSVGImage() {
|
||||||
|
if (_svgString == null) {
|
||||||
|
return Center(child: widget._placeholderBuilder?.call(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
return SvgPicture.string(
|
||||||
|
_svgString!,
|
||||||
|
fit: widget._fit,
|
||||||
|
width: widget._width,
|
||||||
|
height: widget._height ?? height,
|
||||||
|
alignment: widget._alignment,
|
||||||
|
matchTextDirection: widget._matchTextDirection,
|
||||||
|
allowDrawingOutsideViewBox: widget._allowDrawingOutsideViewBox,
|
||||||
|
semanticsLabel: widget._semanticsLabel,
|
||||||
|
excludeFromSemantics: widget._excludeFromSemantics,
|
||||||
|
colorFilter: widget._colorFilter,
|
||||||
|
placeholderBuilder: widget._placeholderBuilder,
|
||||||
|
theme: widget._theme,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,32 +106,31 @@ class Request {
|
|||||||
persistentConnection: true,
|
persistentConnection: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
bool enableSystemProxy = Pref.enableSystemProxy;
|
final bool enableSystemProxy;
|
||||||
late final String systemProxyHost;
|
late final String systemProxyHost;
|
||||||
late final int? systemProxyPort;
|
late final int? systemProxyPort;
|
||||||
if (enableSystemProxy) {
|
if (Pref.enableSystemProxy) {
|
||||||
systemProxyHost = Pref.systemProxyHost;
|
systemProxyHost = Pref.systemProxyHost;
|
||||||
systemProxyPort = int.tryParse(Pref.systemProxyPort);
|
systemProxyPort = int.tryParse(Pref.systemProxyPort);
|
||||||
enableSystemProxy = systemProxyPort != null && systemProxyHost.isNotEmpty;
|
enableSystemProxy = systemProxyPort != null && systemProxyHost.isNotEmpty;
|
||||||
|
} else {
|
||||||
|
enableSystemProxy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final http11Adapter = IOHttpClientAdapter(
|
final http11Adapter = IOHttpClientAdapter(
|
||||||
createHttpClient: () {
|
createHttpClient: enableSystemProxy
|
||||||
final client = HttpClient()
|
? () => HttpClient()
|
||||||
..idleTimeout = const Duration(seconds: 15)
|
..idleTimeout = const Duration(seconds: 15)
|
||||||
..autoUncompress = false; // Http2Adapter没有自动解压, 统一行为
|
..autoUncompress = false
|
||||||
// 设置代理
|
|
||||||
if (enableSystemProxy) {
|
|
||||||
client
|
|
||||||
..findProxy = ((_) => 'PROXY $systemProxyHost:$systemProxyPort')
|
..findProxy = ((_) => 'PROXY $systemProxyHost:$systemProxyPort')
|
||||||
..badCertificateCallback =
|
..badCertificateCallback =
|
||||||
(X509Certificate cert, String host, int port) => true;
|
(X509Certificate cert, String host, int port) => true
|
||||||
}
|
: () => HttpClient()
|
||||||
return client;
|
..idleTimeout = const Duration(seconds: 15)
|
||||||
},
|
..autoUncompress = false, // Http2Adapter没有自动解压, 统一行为
|
||||||
);
|
);
|
||||||
|
|
||||||
late Uri proxy;
|
late final Uri proxy;
|
||||||
if (enableSystemProxy) {
|
if (enableSystemProxy) {
|
||||||
proxy = Uri(
|
proxy = Uri(
|
||||||
scheme: 'http',
|
scheme: 'http',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/common/widgets/cached_network_svg_image.dart';
|
||||||
import 'package:PiliPlus/common/widgets/image/custom_grid_view.dart';
|
import 'package:PiliPlus/common/widgets/image/custom_grid_view.dart';
|
||||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/http/constants.dart';
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
@@ -15,7 +16,6 @@ import 'package:PiliPlus/utils/extension.dart';
|
|||||||
import 'package:PiliPlus/utils/image_utils.dart';
|
import 'package:PiliPlus/utils/image_utils.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:cached_network_svg_image/cached_network_svg_image.dart';
|
|
||||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -88,7 +88,6 @@ class OpusContent extends StatelessWidget {
|
|||||||
child: CachedNetworkSVGImage(
|
child: CachedNetworkSVGImage(
|
||||||
cacheKey: latex,
|
cacheKey: latex,
|
||||||
semanticsLabel: latex,
|
semanticsLabel: latex,
|
||||||
height: 65,
|
|
||||||
'${HttpString.apiBaseUrl}/x/web-frontend/mathjax/tex?formula=${Uri.encodeComponent(latex)}',
|
'${HttpString.apiBaseUrl}/x/web-frontend/mathjax/tex?formula=${Uri.encodeComponent(latex)}',
|
||||||
colorFilter: ColorFilter.mode(
|
colorFilter: ColorFilter.mode(
|
||||||
colorScheme.onSurfaceVariant,
|
colorScheme.onSurfaceVariant,
|
||||||
@@ -96,6 +95,7 @@ class OpusContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
placeholderBuilder: (_) => Text(latex),
|
placeholderBuilder: (_) => Text(latex),
|
||||||
|
errorWidget: Text(latex),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -984,7 +984,7 @@ List<SettingsModel> get extraSettings => [
|
|||||||
TextField(
|
TextField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
labelText: systemProxyHost != ''
|
labelText: systemProxyHost.isNotEmpty
|
||||||
? systemProxyHost
|
? systemProxyHost
|
||||||
: '请输入Host,使用 . 分割',
|
: '请输入Host,使用 . 分割',
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
@@ -992,16 +992,14 @@ List<SettingsModel> get extraSettings => [
|
|||||||
),
|
),
|
||||||
hintText: systemProxyHost,
|
hintText: systemProxyHost,
|
||||||
),
|
),
|
||||||
onChanged: (e) {
|
onChanged: (e) => systemProxyHost = e,
|
||||||
systemProxyHost = e;
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TextField(
|
TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
labelText: systemProxyPort != ''
|
labelText: systemProxyPort.isNotEmpty
|
||||||
? systemProxyPort
|
? systemProxyPort
|
||||||
: '请输入Port',
|
: '请输入Port',
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
@@ -1009,9 +1007,8 @@ List<SettingsModel> get extraSettings => [
|
|||||||
),
|
),
|
||||||
hintText: systemProxyPort,
|
hintText: systemProxyPort,
|
||||||
),
|
),
|
||||||
onChanged: (e) {
|
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||||
systemProxyPort = e;
|
onChanged: (e) => systemProxyPort = e,
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,34 +1,37 @@
|
|||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:screen_retriever/screen_retriever.dart';
|
import 'package:screen_retriever/screen_retriever.dart';
|
||||||
|
|
||||||
Future<Offset> calcWindowPosition(Size windowSize) async {
|
Future<Offset> calcWindowPosition(Size windowSize) async {
|
||||||
Display primaryDisplay = await screenRetriever.getPrimaryDisplay();
|
final allDisplays = screenRetriever.getAllDisplays();
|
||||||
List<Display> allDisplays = await screenRetriever.getAllDisplays();
|
final cursorScreenPoint = await screenRetriever.getCursorScreenPoint();
|
||||||
Offset cursorScreenPoint = await screenRetriever.getCursorScreenPoint();
|
|
||||||
|
|
||||||
Display currentDisplay = allDisplays.firstWhere(
|
final currentDisplay =
|
||||||
(display) => Rect.fromLTWH(
|
(await allDisplays).firstWhereOrNull(
|
||||||
display.visiblePosition!.dx,
|
(display) => (display.visiblePosition! & display.size).contains(
|
||||||
display.visiblePosition!.dy,
|
cursorScreenPoint,
|
||||||
display.size.width,
|
),
|
||||||
display.size.height,
|
) ??
|
||||||
).contains(cursorScreenPoint),
|
await screenRetriever.getPrimaryDisplay();
|
||||||
orElse: () => primaryDisplay,
|
|
||||||
);
|
|
||||||
|
|
||||||
num visibleWidth = currentDisplay.size.width;
|
final double visibleWidth;
|
||||||
num visibleHeight = currentDisplay.size.height;
|
final double visibleHeight;
|
||||||
num visibleStartX = 0;
|
if (currentDisplay.visibleSize case final size?) {
|
||||||
num visibleStartY = 0;
|
visibleWidth = size.width;
|
||||||
|
visibleHeight = size.height;
|
||||||
if (currentDisplay.visibleSize != null) {
|
} else {
|
||||||
visibleWidth = currentDisplay.visibleSize!.width;
|
visibleWidth = currentDisplay.size.width;
|
||||||
visibleHeight = currentDisplay.visibleSize!.height;
|
visibleHeight = currentDisplay.size.height;
|
||||||
}
|
}
|
||||||
if (currentDisplay.visiblePosition != null) {
|
|
||||||
visibleStartX = currentDisplay.visiblePosition!.dx;
|
final double visibleStartX;
|
||||||
visibleStartY = currentDisplay.visiblePosition!.dy;
|
final double visibleStartY;
|
||||||
|
if (currentDisplay.visiblePosition case final offset?) {
|
||||||
|
visibleStartX = offset.dx;
|
||||||
|
visibleStartY = offset.dy;
|
||||||
|
} else {
|
||||||
|
visibleStartX = visibleStartY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final windowPosition = Pref.windowPosition;
|
final windowPosition = Pref.windowPosition;
|
||||||
|
|||||||
104
pubspec.lock
104
pubspec.lock
@@ -5,26 +5,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
|
sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "67.0.0"
|
version: "85.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
|
sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.4.1"
|
version: "7.7.1"
|
||||||
animations:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: animations
|
|
||||||
sha256: d3d6dcfb218225bbe68e87ccf6378bbb2e32a94900722c5f81611dad089911cb
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.11"
|
|
||||||
ansicolor:
|
ansicolor:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -158,18 +150,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build
|
name: build
|
||||||
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
sha256: "825fed4d63050252a0b6e74f2d75844c4a85b664814be6993bd3493fb5239779"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "4.0.1"
|
||||||
build_config:
|
build_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_config
|
name: build_config
|
||||||
sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33"
|
sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.2"
|
version: "1.2.0"
|
||||||
build_daemon:
|
build_daemon:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -178,30 +170,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.4"
|
version: "4.0.4"
|
||||||
build_resolvers:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: build_resolvers
|
|
||||||
sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.4.2"
|
|
||||||
build_runner:
|
build_runner:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d"
|
sha256: "4e54dbeefdc70691ba80b3bce3976af63b5425c8c07dface348dfee664a0edc1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.13"
|
version: "2.9.0"
|
||||||
build_runner_core:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: build_runner_core
|
|
||||||
sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "7.3.2"
|
|
||||||
built_collection:
|
built_collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -242,14 +218,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
cached_network_svg_image:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: cached_network_svg_image
|
|
||||||
sha256: fe9df0217c12e3903558dad14e1bb938c51296a1d96faa080415c6146bbd7a7d
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.0"
|
|
||||||
canvas_danmaku:
|
canvas_danmaku:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -400,10 +368,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dart_style
|
name: dart_style
|
||||||
sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9"
|
sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.6"
|
version: "3.1.1"
|
||||||
dbus:
|
dbus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -803,14 +771,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.9.0"
|
version: "10.9.0"
|
||||||
frontend_server_client:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: frontend_server_client
|
|
||||||
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.0.0"
|
|
||||||
get:
|
get:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -867,14 +827,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
hive_generator:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description:
|
|
||||||
name: hive_generator
|
|
||||||
sha256: "06cb8f58ace74de61f63500564931f9505368f45f98958bd7a6c35ba24159db4"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.1"
|
|
||||||
html:
|
html:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1187,8 +1139,8 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "libs/universal/media_kit_libs_video"
|
path: "libs/universal/media_kit_libs_video"
|
||||||
ref: "version_1.2.5"
|
ref: "version_1.2.5"
|
||||||
resolved-ref: "4d68e69281b44f2c8e3c444cca3d8d8dc6dcff88"
|
resolved-ref: "43aee19d9b2b0e33e0c9dd922b36ca6ace56de29"
|
||||||
url: "https://github.com/My-Responsitories/media-kit.git"
|
url: "https://github.com/bggRGjQaUbCoE/media-kit.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
media_kit_libs_windows_video:
|
media_kit_libs_windows_video:
|
||||||
@@ -1205,8 +1157,8 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: media_kit_native_event_loop
|
path: media_kit_native_event_loop
|
||||||
ref: "version_1.2.5"
|
ref: "version_1.2.5"
|
||||||
resolved-ref: "4d68e69281b44f2c8e3c444cca3d8d8dc6dcff88"
|
resolved-ref: "43aee19d9b2b0e33e0c9dd922b36ca6ace56de29"
|
||||||
url: "https://github.com/My-Responsitories/media-kit.git"
|
url: "https://github.com/bggRGjQaUbCoE/media-kit.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.9"
|
version: "1.0.9"
|
||||||
media_kit_video:
|
media_kit_video:
|
||||||
@@ -1663,22 +1615,6 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
source_gen:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: source_gen
|
|
||||||
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.5.0"
|
|
||||||
source_helper:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: source_helper
|
|
||||||
sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.5"
|
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1800,14 +1736,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.6"
|
version: "0.7.6"
|
||||||
timing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: timing
|
|
||||||
sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.2"
|
|
||||||
tray_manager:
|
tray_manager:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
17
pubspec.yaml
17
pubspec.yaml
@@ -38,7 +38,7 @@ dependencies:
|
|||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
# 动态取色
|
# 动态取色
|
||||||
dynamic_color: ^1.7.0
|
dynamic_color: ^1.8.1
|
||||||
|
|
||||||
get: ^4.6.6
|
get: ^4.6.6
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ dependencies:
|
|||||||
url: https://github.com/bggRGjQaUbCoE/auto_orientation.git
|
url: https://github.com/bggRGjQaUbCoE/auto_orientation.git
|
||||||
ref: master
|
ref: master
|
||||||
protobuf: ^5.0.0
|
protobuf: ^5.0.0
|
||||||
animations: ^2.0.11
|
# animations: ^2.0.11
|
||||||
|
|
||||||
# 获取appx信息
|
# 获取appx信息
|
||||||
package_info_plus: ^9.0.0
|
package_info_plus: ^9.0.0
|
||||||
@@ -197,7 +197,6 @@ dependencies:
|
|||||||
url: https://github.com/wgh136/webdav_client.git
|
url: https://github.com/wgh136/webdav_client.git
|
||||||
ref: main
|
ref: main
|
||||||
re_highlight: ^0.0.3
|
re_highlight: ^0.0.3
|
||||||
cached_network_svg_image: ^1.2.0
|
|
||||||
flutter_sortable_wrap:
|
flutter_sortable_wrap:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/bggRGjQaUbCoE/flutter_sortable_wrap.git
|
url: https://github.com/bggRGjQaUbCoE/flutter_sortable_wrap.git
|
||||||
@@ -251,12 +250,12 @@ dependency_overrides:
|
|||||||
ref: version_1.2.5
|
ref: version_1.2.5
|
||||||
media_kit_libs_video:
|
media_kit_libs_video:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/My-Responsitories/media-kit.git
|
url: https://github.com/bggRGjQaUbCoE/media-kit.git
|
||||||
path: libs/universal/media_kit_libs_video
|
path: libs/universal/media_kit_libs_video
|
||||||
ref: version_1.2.5
|
ref: version_1.2.5
|
||||||
media_kit_native_event_loop:
|
media_kit_native_event_loop:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/My-Responsitories/media-kit.git
|
url: https://github.com/bggRGjQaUbCoE/media-kit.git
|
||||||
path: media_kit_native_event_loop
|
path: media_kit_native_event_loop
|
||||||
ref: version_1.2.5
|
ref: version_1.2.5
|
||||||
media_kit_libs_android_video:
|
media_kit_libs_android_video:
|
||||||
@@ -281,10 +280,10 @@ dev_dependencies:
|
|||||||
# package. See that file for information about deactivating specific lint
|
# package. See that file for information about deactivating specific lint
|
||||||
# rules and activating additional ones.
|
# rules and activating additional ones.
|
||||||
flutter_lints: ^6.0.0
|
flutter_lints: ^6.0.0
|
||||||
flutter_launcher_icons: ^0.14.1
|
flutter_launcher_icons: ^0.14.4
|
||||||
hive_generator: ^2.0.1
|
# hive_generator: ^2.0.1
|
||||||
build_runner: ^2.4.13
|
build_runner: ^2.9.0
|
||||||
flutter_native_splash: ^2.4.3
|
flutter_native_splash: ^2.4.6
|
||||||
|
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
android: true
|
android: true
|
||||||
|
|||||||
Reference in New Issue
Block a user