Merge pull request #218 from ZhuJHua/develop

fix(share): fix capture and share methods
This commit is contained in:
住京华
2025-03-23 04:35:20 +08:00
committed by GitHub
11 changed files with 74 additions and 207 deletions

View File

@@ -8,13 +8,14 @@
<p align="center"><a href="https://answer.moodiary.net" target="_blank">Official forum</a>丨QQ Group: <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=xGr0TNp_X1z3XEn09_iE_iGSLolQwl6Y&jump_from=webapi&authKey=ZmSb2oEd94FSXxBXRBq53hgTjjvcfmgkQrduB3uL12XtRylPmRlO2OdFz6R25tIo">760014526</a>丨Telegram: <a target="_blank" href="https://t.me/openmoodiary">openmoodiary</a></p>
<div align="center">
<img src="https://img.shields.io/badge/Flutter-3.27.3-blue?style=for-the-badge">
<img src="https://img.shields.io/badge/Flutter-3.29.2-blue?style=for-the-badge">
<img src="https://img.shields.io/github/repo-size/ZhuJHua/moodiary?style=for-the-badge&color=ff7070">
<img src="https://img.shields.io/github/stars/ZhuJHua/moodiary?style=for-the-badge&color=965f8a">
<img src="https://img.shields.io/github/v/release/ZhuJHua/moodiary?style=for-the-badge&color=4f5e7f">
<img src="https://img.shields.io/github/license/ZhuJHua/moodiary?style=for-the-badge&color=4ac6b7">
</div>
## ✨ Feature
- **Cross-platform support**: 🌍 Compatible with Android, iOS, Windows, MacOS, Linux\*.
@@ -77,7 +78,7 @@ Some capabilities need to apply for third-party SDKS, and the following service
- [Tencent Hunyuan](https://cloud.tencent.com/document/product/1729/97731)
### Direct mounting
### Direct install
Use it by downloading the compiled installation package in Release, or manually compiling it if you don't have the platform you need.
@@ -87,9 +88,9 @@ Use it by downloading the compiled installation package in Release, or manually
> I always use the latest Flutter version (if possible), using newer versions will bring more features and better performance improvements, never use older versions unless you want your code to become a piece of 💩
- Flutter SDK (>= 3.27.0 Stable) (It is recommended to use FVM to manage the Flutter version)
- Dart (>= 3.6.0)
- Rust Toolchain
- Flutter SDK (>= 3.29.0 Stable) (It is recommended to use FVM to manage the Flutter version)
- Dart (>= 3.7.0)
- Rust Toolchain (Nightly)
- Clang/LLVM
- Compatible IDE (e.g. Android Studio, Visual Studio Code)

View File

@@ -8,7 +8,7 @@
<p align="center"><a href="https://answer.moodiary.net" target="_blank">官方论坛</a>丨QQ群: <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=xGr0TNp_X1z3XEn09_iE_iGSLolQwl6Y&jump_from=webapi&authKey=ZmSb2oEd94FSXxBXRBq53hgTjjvcfmgkQrduB3uL12XtRylPmRlO2OdFz6R25tIo">760014526</a>丨Telegram: <a target="_blank" href="https://t.me/openmoodiary">openmoodiary</a></p>
<div align="center">
<img src="https://img.shields.io/badge/Flutter-3.27.3-blue?style=for-the-badge">
<img src="https://img.shields.io/badge/Flutter-3.29.2-blue?style=for-the-badge">
<img src="https://img.shields.io/github/repo-size/ZhuJHua/moodiary?style=for-the-badge&color=ff7070">
<img src="https://img.shields.io/github/stars/ZhuJHua/moodiary?style=for-the-badge&color=965f8a">
<img src="https://img.shields.io/github/v/release/ZhuJHua/moodiary?style=for-the-badge&color=4f5e7f">
@@ -16,6 +16,7 @@
</div>
## ✨ 功能特性
- **跨平台支持**:🌍 兼容 Android、iOS、Windows、MacOS、Linux\*。
@@ -88,9 +89,9 @@
> 我总是会使用最新的 Flutter 版本(如果可能的话),使用新版本可以带来更多的功能和更好的性能提升,永远不要使用老版本除非你希望代码变成一坨 💩
- Flutter SDK (>= 3.27.0 Stable)(建议使用 fvm 来管理 flutter 版本)
- Dart (>= 3.6.0)
- Rust 工具链
- Flutter SDK (>= 3.29.0 Stable)(建议使用 fvm 来管理 flutter 版本)
- Dart (>= 3.7.0)
- Rust 工具链Nightly
- Clang/LLVM
- 兼容的 IDE如 Android Studio、Visual Studio Code

View File

@@ -1,25 +1,6 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
prefer_const_constructors: true
prefer_const_literals_to_create_immutables: true
@@ -31,5 +12,9 @@ linter:
analyzer:
plugins:
- custom_lint
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "**/*.gr.dart"
- "**/*.mocks.dart"
- "rust_builder/**"

View File

@@ -68,9 +68,8 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig = signingConfigs.config
resValue "string", "app_name", "Moodiary Debug"
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}

View File

@@ -74,6 +74,7 @@ commit_parsers = [
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore\\(readme\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },

View File

@@ -20,18 +20,20 @@ class ShareLogic extends GetxController {
super.onInit();
}
Future<Uint8List> captureWidget() async {
Future<Uint8List> _captureWidget(BuildContext context) async {
final boundary =
state.key.currentContext?.findRenderObject() as RenderRepaintBoundary;
final pixelRatio = MediaQuery.devicePixelRatioOf(Get.context!);
final pixelRatio = MediaQuery.devicePixelRatioOf(context);
final image = await boundary.toImage(pixelRatio: pixelRatio);
final data = await image.toByteData(format: ImageByteFormat.png);
return data!.buffer.asUint8List();
}
Future<void> share() async {
Future<void> share(BuildContext context) async {
final name = 'screenshot-${const Uuid().v7()}.png';
File(FileUtil.getCachePath(name)).writeAsBytes(await captureWidget());
await File(
FileUtil.getCachePath(name),
).writeAsBytes(await _captureWidget(context));
await Share.shareXFiles([XFile(FileUtil.getCachePath(name))]);
}
}

View File

@@ -134,7 +134,7 @@ class SharePage extends StatelessWidget {
),
floatingActionButton: FloatingActionButton(
onPressed: () {
logic.share();
logic.share(context);
},
child: const Icon(Icons.share),
),

View File

@@ -22,14 +22,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
adaptive_number:
dependency: transitive
description:
name: adaptive_number
sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
analyzer:
dependency: transitive
description:
@@ -130,10 +122,10 @@ packages:
dependency: transitive
description:
name: asn1lib
sha256: "068190d6c99c436287936ba5855af2e1fa78d8083ae65b4db6a281780da727ae"
sha256: ed64c586b5e0476050ff719ea28a94b2831f8857ba2a90f8f05dc276a88456fa
url: "https://pub.dev"
source: hosted
version: "1.6.0"
version: "1.6.1"
async:
dependency: transitive
description:
@@ -370,10 +362,10 @@ packages:
dependency: "direct main"
description:
name: calendar_date_picker2
sha256: "7b5f20f2a02768df70b3d1fb181c217ab9f8992f39fd6c3fc2ff95b0885820a2"
sha256: "293020a283210ccefff669499178c127acbb5e77ae13864f992c8a3e68a8aca1"
url: "https://pub.dev"
source: hosted
version: "1.1.9"
version: "2.0.0"
characters:
dependency: transitive
description:
@@ -494,14 +486,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.2"
coverage:
dependency: transitive
description:
name: coverage
sha256: e3493833ea012784c740e341952298f1cc77f1f01b1bbc3eb4eecf6984fb7f43
url: "https://pub.dev"
source: hosted
version: "1.11.1"
cross_file:
dependency: "direct main"
description:
@@ -686,14 +670,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.7.0"
ed25519_edwards:
dependency: transitive
description:
name: ed25519_edwards
sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
encrypt:
dependency: "direct main"
description:
@@ -750,14 +726,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
ffigen:
dependency: transitive
description:
name: ffigen
sha256: "2119b4fe3aad0db94dc9531b90283c4640a6231070e613c400b426a4da08c704"
url: "https://pub.dev"
source: hosted
version: "16.1.0"
file:
dependency: transitive
description:
@@ -863,10 +831,10 @@ packages:
dependency: "direct main"
description:
name: flutter_drawing_board
sha256: cc0a7bc665320628f2927632e2cdeee935ebbb48e0e6400ed504663ae704e713
sha256: b7eef8c506a12485853e8b4cdc110d1d307993279b588f3a35902a7d7082dbd4
url: "https://pub.dev"
source: hosted
version: "0.9.5"
version: "0.9.8"
flutter_gen:
dependency: "direct dev"
description:
@@ -1132,10 +1100,10 @@ packages:
dependency: "direct main"
description:
name: flutter_quill
sha256: "30a85c53ef19dba5403d0f4b8030c0f22fd2d3614f115ff07004bdecbda2b8f6"
sha256: cdc3802700bf6718b8286ec6c999094f45abb885b5b3b65380f25d1b4369032d
url: "https://pub.dev"
source: hosted
version: "11.1.0"
version: "11.1.1"
flutter_quill_delta_from_html:
dependency: transitive
description:
@@ -1302,18 +1270,18 @@ packages:
dependency: transitive
description:
name: geolocator_apple
sha256: "419e50f754281d3606750af07b198ecfe938e8648d3e30a898d3ac342ab717e6"
sha256: dbdd8789d5aaf14cf69f74d4925ad1336b4433a6efdf2fce91e8955dc921bf22
url: "https://pub.dev"
source: hosted
version: "2.3.12"
version: "2.3.13"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
sha256: "722db30c0a2caa82a59d6655f04ef0a492da003036b880342cc67e6f1abc188f"
sha256: "30cb64f0b9adcc0fb36f628b4ebf4f731a2961a0ebd849f4b56200205056fe67"
url: "https://pub.dev"
source: hosted
version: "4.2.5"
version: "4.2.6"
geolocator_web:
dependency: transitive
description:
@@ -1338,14 +1306,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.7.0"
github:
dependency: transitive
description:
name: github
sha256: "57f6ad78591f9638e903409977443093f862d25062a6b582a3c89e4ae44e4814"
url: "https://pub.dev"
source: hosted
version: "9.24.0"
glob:
dependency: transitive
description:
@@ -1394,14 +1354,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
hex:
dependency: transitive
description:
name: hex
sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
highlight:
dependency: transitive
description:
@@ -1573,10 +1525,11 @@ packages:
isar_flutter_libs:
dependency: "direct main"
description:
name: isar_flutter_libs
sha256: "04a3f4035e213ddb6e78d0132a7c80296a085c2088c2a761b4a42ee5add36983"
url: "https://pub.dev"
source: hosted
path: "packages/isar_flutter_libs"
ref: HEAD
resolved-ref: fc323a5660b9987fd4d137f71b0d3dbad0915e4f
url: "https://github.com/ZhuJHua/isar"
source: git
version: "4.0.0-dev.14"
js:
dependency: transitive
@@ -1734,10 +1687,10 @@ packages:
dependency: transitive
description:
name: macos_window_utils
sha256: "3534f2af024f2f24112ca28789a44e6750083f8c0065414546c6593ee48a5009"
sha256: "10036bd91202d3542b75d40b5b3f4001ca5a232081477ca71690d7c4ea91f7cb"
url: "https://pub.dev"
source: hosted
version: "1.6.1"
version: "1.7.0"
macros:
dependency: transitive
description:
@@ -1850,6 +1803,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0"
moodiary_rust:
dependency: "direct main"
description:
path: rust_builder
relative: true
source: path
version: "0.0.1"
msix:
dependency: "direct dev"
description:
@@ -1890,14 +1850,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
octo_image:
dependency: transitive
description:
@@ -2158,10 +2110,10 @@ packages:
dependency: transitive
description:
name: quill_native_bridge
sha256: bda0f0ad9bc160dcdd4bd2b378a7ae8bdb55c3d4b7301bf739d5e3b065ee5e82
sha256: "00752aca7d67cbd3254709a47558be78427750cb81aa42cfbed354d4a079bcfa"
url: "https://pub.dev"
source: hosted
version: "11.0.0"
version: "11.0.1"
quill_native_bridge_android:
dependency: transitive
description:
@@ -2198,18 +2150,18 @@ packages:
dependency: transitive
description:
name: quill_native_bridge_platform_interface
sha256: ea48bd12bf426741747ec8a575b122350971f338a75049099b349c63447582a2
sha256: "8264a2bdb8a294c31377a27b46c0f8717fa9f968cf113f7dc52d332ed9c84526"
url: "https://pub.dev"
source: hosted
version: "0.0.1+1"
version: "0.0.2+1"
quill_native_bridge_web:
dependency: transitive
description:
name: quill_native_bridge_web
sha256: e7e55047d68f1a88574c26dbe3f12988f49d07740590d8fc6280028bbde5b908
sha256: "7c723f6824b0250d7f33e8b6c23f2f8eb0103fe48ee7ebf47ab6786b64d5c05d"
url: "https://pub.dev"
source: hosted
version: "0.0.1"
version: "0.0.2"
quill_native_bridge_windows:
dependency: transitive
description:
@@ -2522,22 +2474,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
url: "https://pub.dev"
source: hosted
version: "1.1.3"
shelf_web_socket:
dependency: transitive
description:
@@ -2583,22 +2519,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.5"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
url: "https://pub.dev"
source: hosted
version: "2.1.2"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812"
url: "https://pub.dev"
source: hosted
version: "0.10.13"
source_span:
dependency: transitive
description:
@@ -2751,14 +2671,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.2"
test:
dependency: transitive
description:
name: test
sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e"
url: "https://pub.dev"
source: hosted
version: "1.25.15"
test_api:
dependency: transitive
description:
@@ -2767,14 +2679,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.4"
test_core:
dependency: transitive
description:
name: test_core
sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa"
url: "https://pub.dev"
source: hosted
version: "0.6.8"
tflite_flutter:
dependency: "direct main"
description:
@@ -2799,14 +2703,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.2"
toml:
dependency: transitive
description:
name: toml
sha256: d968d149c8bd06dc14e09ea3a140f90a3f2ba71949e7a91df4a46f3107400e71
url: "https://pub.dev"
source: hosted
version: "0.16.0"
tutorial_coach_mark:
dependency: "direct main"
description:
@@ -2959,14 +2855,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version:
dependency: transitive
description:
name: version
sha256: "3d4140128e6ea10d83da32fef2fa4003fccbf6852217bb854845802f04191f94"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
video_player:
dependency: "direct main"
description:
@@ -3103,14 +2991,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.2"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
win32:
dependency: transitive
description:
@@ -3159,14 +3039,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.3"
yaml_edit:
dependency: transitive
description:
name: yaml_edit
sha256: fb38626579fb345ad00e674e2af3a5c9b0cc4b9bfb8fd7f7ff322c7c9e62aef5
url: "https://pub.dev"
source: hosted
version: "2.2.2"
yet_another_json_isolate:
dependency: transitive
description:

View File

@@ -7,10 +7,6 @@ environment:
sdk: '>=3.7.0'
flutter: '>=3.29.0'
workspace:
- rust_builder
- rust_builder/cargokit/build_tool
dependencies:
flutter:
sdk: flutter
@@ -19,9 +15,9 @@ dependencies:
dio: 5.8.0+1
path: 1.9.1
path_provider: 2.1.5
calendar_date_picker2: 1.1.9
calendar_date_picker2: 2.0.0
logger: 2.5.0
flutter_drawing_board: 0.9.5
flutter_drawing_board: 0.9.8
flutter_displaymode: 0.6.0
fl_chart: 0.70.2
file_picker: 9.2.1
@@ -32,7 +28,7 @@ dependencies:
device_info_plus: 11.3.3
package_info_plus: 8.3.0
uuid: 4.5.1
flutter_quill: 11.1.0
flutter_quill: 11.1.1
share_plus: 10.1.4
url_launcher: 6.3.1
archive: 4.0.4
@@ -42,7 +38,10 @@ dependencies:
geolocator: 13.0.3
shared_preferences: 2.5.2
isar: 4.0.0-dev.14
isar_flutter_libs: 4.0.0-dev.14
isar_flutter_libs:
git:
url: https://github.com/ZhuJHua/isar
path: packages/isar_flutter_libs
fluttertoast: 8.2.12
cached_network_image: 3.4.1
audioplayers: 6.4.0
@@ -122,7 +121,6 @@ dependencies:
json_annotation: 4.9.0
audioplayers_android_exo: 0.1.2
dev_dependencies:
flutter_test:
sdk: flutter

View File

@@ -18,3 +18,9 @@ walkdir = "2.5.0"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }
[profile.release]
lto = true
codegen-units = 1
panic = "abort"
strip = "symbols"

View File

@@ -2,7 +2,9 @@ name: moodiary_rust
description: "Utility to build Rust code"
version: 0.0.1
publish_to: none
resolution: workspace
workspace:
- cargokit/build_tool
environment:
sdk: '>=3.7.0'