mirror of
https://github.com/venera-app/venera.git
synced 2025-09-28 08:17:25 +00:00
Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
b8492b3adc | |||
![]() |
0f37feb318 | ||
6e2c5c6e07 | |||
64d8bcba9a | |||
160d0df935 | |||
6a60194ffb | |||
93193bddc0 | |||
aa415f201e | |||
4f4411fcc3 | |||
![]() |
afd690ed07 | ||
![]() |
a3936f64da | ||
![]() |
7bf8cf569f | ||
![]() |
856ec23586 | ||
![]() |
d910b8a35d | ||
![]() |
234bf218a9 | ||
![]() |
0226477256 | ||
![]() |
42ded1221a | ||
a9a22ace14 | |||
99bbea80dc | |||
26fa41f503 | |||
082aa36316 | |||
5a14ea48c1 | |||
5d43f5c556 | |||
e51a58ba4f | |||
5234de434a | |||
22f2ac99ad | |||
b08b5d0abe | |||
![]() |
96c6323c07 | ||
ae80715db1 | |||
3d7f30af00 | |||
f12cb55bbc | |||
![]() |
1cc30c5748 | ||
af371df2a4 | |||
98b9e6e9d9 | |||
96c75300d0 | |||
a6608b6fa2 | |||
b09e2e6f12 | |||
7991f1a385 | |||
afa320e863 | |||
adb6cdd0c1 | |||
b49e528ff4 | |||
07f8f2a4af | |||
0fbe9677b9 | |||
45e7f0dfc2 | |||
![]() |
9e0e318107 | ||
![]() |
03727d114c | ||
![]() |
6cf5c7b27b | ||
![]() |
173689b57e | ||
![]() |
8fb39b1ec8 | ||
![]() |
679462f272 | ||
![]() |
ee944a2869 | ||
![]() |
bbb414757d | ||
![]() |
f2335894a4 | ||
![]() |
77ef0fb404 |
22
.github/workflows/main.yml
vendored
22
.github/workflows/main.yml
vendored
@@ -4,7 +4,7 @@ on:
|
|||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
jobs:
|
jobs:
|
||||||
Build_MacOS:
|
Build_MacOS:
|
||||||
runs-on: macos-13
|
runs-on: macos-15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version-file: pubspec.yaml
|
flutter-version-file: pubspec.yaml
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
- run: sudo xcode-select --switch /Applications/Xcode_16.0.app
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
# Step 1: Decode and install the certificate
|
# Step 1: Decode and install the certificate
|
||||||
- name: Decode and install certificate
|
- name: Decode and install certificate
|
||||||
@@ -27,23 +27,23 @@ jobs:
|
|||||||
- name: Build Flutter macOS App
|
- name: Build Flutter macOS App
|
||||||
run: flutter build macos --release
|
run: flutter build macos --release
|
||||||
|
|
||||||
|
# Step 3: Create the DMG file
|
||||||
# Step 4: Create the DMG file
|
|
||||||
- name: Create DMG
|
- name: Create DMG
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
hdiutil create -volname "venera" -srcfolder build/macos/Build/Products/Release/venera.app -ov -format UDZO "dist/venera.dmg"
|
mkdir -p dist/dmg_contents
|
||||||
|
cp -R build/macos/Build/Products/Release/venera.app dist/dmg_contents/
|
||||||
|
ln -s /Applications dist/dmg_contents/Applications
|
||||||
|
hdiutil create -volname "venera" -srcfolder dist/dmg_contents -ov -format UDZO "dist/venera.dmg"
|
||||||
|
|
||||||
|
# Step 4: Attach and upload artifacts (optional)
|
||||||
|
|
||||||
# Step 8: Attach and upload artifacts (optional)
|
|
||||||
- name: Upload DMG
|
- name: Upload DMG
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: venera.dmg
|
name: venera.dmg
|
||||||
path: dist/venera.dmg
|
path: dist/venera.dmg
|
||||||
Build_IOS:
|
Build_IOS:
|
||||||
runs-on: macos-13
|
runs-on: macos-15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version-file: pubspec.yaml
|
flutter-version-file: pubspec.yaml
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
- run: sudo xcode-select --switch /Applications/Xcode_16.0.app
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter build ios --release --no-codesign
|
- run: flutter build ios --release --no-codesign
|
||||||
- run: |
|
- run: |
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -41,3 +41,5 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
|
||||||
|
add_translation.py
|
@@ -4,6 +4,7 @@
|
|||||||
[](https://github.com/venera-app/venera/blob/master/LICENSE)
|
[](https://github.com/venera-app/venera/blob/master/LICENSE)
|
||||||
[](https://github.com/venera-app/venera/releases)
|
[](https://github.com/venera-app/venera/releases)
|
||||||
[](https://github.com/venera-app/venera/stargazers)
|
[](https://github.com/venera-app/venera/stargazers)
|
||||||
|
[](https://t.me/+Ws-IpmUutzkxMjhl)
|
||||||
|
|
||||||
A comic reader that support reading local and network comics.
|
A comic reader that support reading local and network comics.
|
||||||
|
|
||||||
@@ -17,6 +18,13 @@ A comic reader that support reading local and network comics.
|
|||||||
- View comments, tags, and other information of comics if the source supports
|
- View comments, tags, and other information of comics if the source supports
|
||||||
- Login to comment, rate, and other operations if the source supports
|
- Login to comment, rate, and other operations if the source supports
|
||||||
|
|
||||||
|
## Build from source
|
||||||
|
|
||||||
|
1. Clone the repository
|
||||||
|
2. Install flutter, see [flutter.dev](https://flutter.dev/docs/get-started/install)
|
||||||
|
3. Install rust, see [rustup.rs](https://rustup.rs/)
|
||||||
|
4. Build for your platform: e.g. `flutter build apk`
|
||||||
|
|
||||||
## Create a new comic source
|
## Create a new comic source
|
||||||
|
|
||||||
See [venera-configs](https://github.com/venera-app/venera-configs)
|
See [venera-configs](https://github.com/venera-app/venera-configs)
|
||||||
|
@@ -75,6 +75,9 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
ndk {
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||||
|
}
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
applicationVariants.all { variant ->
|
applicationVariants.all { variant ->
|
||||||
variant.outputs.all { output ->
|
variant.outputs.all { output ->
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<application
|
<application
|
||||||
android:label="venera"
|
android:label="venera"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
|
@@ -3,8 +3,16 @@ package com.github.wgh136.venera
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.ContentResolver
|
import android.content.ContentResolver
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
import android.Manifest
|
||||||
|
import android.os.Environment
|
||||||
|
import android.provider.Settings
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
@@ -23,6 +31,9 @@ class MainActivity : FlutterActivity() {
|
|||||||
|
|
||||||
private lateinit var result: MethodChannel.Result
|
private lateinit var result: MethodChannel.Result
|
||||||
|
|
||||||
|
private val storageRequestCode = 0x10
|
||||||
|
private var storagePermissionRequest: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (requestCode == pickDirectoryCode) {
|
if (requestCode == pickDirectoryCode) {
|
||||||
@@ -43,6 +54,11 @@ class MainActivity : FlutterActivity() {
|
|||||||
result.error("Failed to Copy Files", e.toString(), null)
|
result.error("Failed to Copy Files", e.toString(), null)
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
} else if (requestCode == storageRequestCode) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
storagePermissionRequest?.invoke(Environment.isExternalStorageManager())
|
||||||
|
}
|
||||||
|
storagePermissionRequest = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +105,13 @@ class MainActivity : FlutterActivity() {
|
|||||||
listening = false
|
listening = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
val storageChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "venera/storage")
|
||||||
|
storageChannel.setMethodCallHandler { _, res ->
|
||||||
|
requestStoragePermission {result ->
|
||||||
|
res.success(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getProxy(): String {
|
private fun getProxy(): String {
|
||||||
@@ -145,6 +168,61 @@ class MainActivity : FlutterActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requestStoragePermission(result: (Boolean) -> Unit) {
|
||||||
|
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
val readPermission = ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
|
|
||||||
|
val writePermission = ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
|
|
||||||
|
if (!readPermission || !writePermission) {
|
||||||
|
storagePermissionRequest = result
|
||||||
|
ActivityCompat.requestPermissions(
|
||||||
|
this,
|
||||||
|
arrayOf(
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
),
|
||||||
|
storageRequestCode
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
result(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!Environment.isExternalStorageManager()) {
|
||||||
|
try {
|
||||||
|
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
|
||||||
|
intent.addCategory("android.intent.category.DEFAULT")
|
||||||
|
intent.data = Uri.parse("package:" + context.packageName)
|
||||||
|
startActivityForResult(intent, storageRequestCode)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<out String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
if(requestCode == storageRequestCode) {
|
||||||
|
storagePermissionRequest?.invoke(grantResults.all {
|
||||||
|
it == PackageManager.PERMISSION_GRANTED
|
||||||
|
})
|
||||||
|
storagePermissionRequest = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VolumeListen{
|
class VolumeListen{
|
||||||
|
136
assets/init.js
136
assets/init.js
@@ -224,7 +224,25 @@ let Convert = {
|
|||||||
key: key,
|
key: key,
|
||||||
isEncode: false
|
isEncode: false
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
/** Encode bytes to hex string
|
||||||
|
* @param bytes {ArrayBuffer}
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
hexEncode: (bytes) => {
|
||||||
|
const hexDigits = '0123456789abcdef';
|
||||||
|
const view = new Uint8Array(bytes);
|
||||||
|
let charCodes = new Uint8Array(view.length * 2);
|
||||||
|
let j = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < view.length; i++) {
|
||||||
|
let byte = view[i];
|
||||||
|
charCodes[j++] = hexDigits.charCodeAt((byte >> 4) & 0xF);
|
||||||
|
charCodes[j++] = hexDigits.charCodeAt(byte & 0xF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.fromCharCode(...charCodes);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -999,4 +1017,118 @@ class ComicSource {
|
|||||||
init() { }
|
init() { }
|
||||||
|
|
||||||
static sources = {}
|
static sources = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A reference to dart object.
|
||||||
|
/// The api can only be used in the comic.onImageLoad.modifyImage function
|
||||||
|
class Image {
|
||||||
|
key = 0;
|
||||||
|
|
||||||
|
constructor(key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the specified range of the image
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
* @returns {Image|null}
|
||||||
|
*/
|
||||||
|
copyRange(x, y, width, height) {
|
||||||
|
let key = sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "copyRange",
|
||||||
|
key: this.key,
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
})
|
||||||
|
if(key == null) return null;
|
||||||
|
return new Image(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the image and rotate 90 degrees
|
||||||
|
* @returns {Image|null}
|
||||||
|
*/
|
||||||
|
copyAndRotate90() {
|
||||||
|
let key = sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "copyAndRotate90",
|
||||||
|
key: this.key
|
||||||
|
})
|
||||||
|
if(key == null) return null;
|
||||||
|
return new Image(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill [image] to this image at (x, y)
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param image
|
||||||
|
*/
|
||||||
|
fillImageAt(x, y, image) {
|
||||||
|
sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "fillImageAt",
|
||||||
|
key: this.key,
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
image: image.key
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill [image] with range(srcX, srcY, width, height) to this image at (x, y)
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param image
|
||||||
|
* @param srcX
|
||||||
|
* @param srcY
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
*/
|
||||||
|
fillImageRangeAt(x, y, image, srcX, srcY, width, height) {
|
||||||
|
sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "fillImageRangeAt",
|
||||||
|
key: this.key,
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
image: image.key,
|
||||||
|
srcX: srcX,
|
||||||
|
srcY: srcY,
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get width() {
|
||||||
|
return sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "getWidth",
|
||||||
|
key: this.key
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get height() {
|
||||||
|
return sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "getHeight",
|
||||||
|
key: this.key
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
static empty(width, height) {
|
||||||
|
let key = sendMessage({
|
||||||
|
method: "image",
|
||||||
|
function: "emptyImage",
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
})
|
||||||
|
return new Image(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
"Select": "选择",
|
"Select": "选择",
|
||||||
"Imported @a comics": "已导入 @a 部漫画",
|
"Imported @a comics": "已导入 @a 部漫画",
|
||||||
"Downloading": "下载中",
|
"Downloading": "下载中",
|
||||||
"Back": "返回",
|
"Back": "后退",
|
||||||
"Delete": "删除",
|
"Delete": "删除",
|
||||||
"Full Screen": "全屏",
|
"Full Screen": "全屏",
|
||||||
"Auto Page Turning": "自动翻页",
|
"Auto Page Turning": "自动翻页",
|
||||||
@@ -155,7 +155,41 @@
|
|||||||
"Start": "开始",
|
"Start": "开始",
|
||||||
"Export App Data": "导出应用数据",
|
"Export App Data": "导出应用数据",
|
||||||
"Import App Data": "导入应用数据",
|
"Import App Data": "导入应用数据",
|
||||||
"Export": "导出"
|
"Export": "导出",
|
||||||
|
"Download Threads": "下载线程数",
|
||||||
|
"Update Time": "更新时间",
|
||||||
|
"Copy ID": "复制ID",
|
||||||
|
"Copy URL": "复制URL",
|
||||||
|
"Create": "创建",
|
||||||
|
"Folder Name": "文件夹名称",
|
||||||
|
"Ranking": "排行",
|
||||||
|
"Download Selected": "下载选中",
|
||||||
|
"Download All": "下载全部",
|
||||||
|
"Order": "顺序",
|
||||||
|
"minAppVersion @version is required": "需要最低App版本 @version",
|
||||||
|
"Remove": "移除",
|
||||||
|
"Long press to zoom": "长按缩放",
|
||||||
|
"Updates Available": "更新可用",
|
||||||
|
"Unselected": "未选择",
|
||||||
|
"Long press and drag to reorder.": "长按并拖动以重新排序。",
|
||||||
|
"Limit image width": "限制图片宽度",
|
||||||
|
"When using Continuous(Top to Bottom) mode": "当使用连续(从上到下)模式",
|
||||||
|
"Open link": "打开链接",
|
||||||
|
"Open comic": "打开漫画",
|
||||||
|
"Move To First": "移动到最前",
|
||||||
|
"Cancel": "取消",
|
||||||
|
"Paused": "已暂停",
|
||||||
|
"Pause": "暂停",
|
||||||
|
"Operation": "操作",
|
||||||
|
"Upload": "上传",
|
||||||
|
"Saved": "已保存",
|
||||||
|
"Sync Data": "同步数据",
|
||||||
|
"Syncing Data": "正在同步数据",
|
||||||
|
"Data Sync": "数据同步",
|
||||||
|
"Quick Favorite": "快速收藏",
|
||||||
|
"Long press on the favorite button to quickly add to this folder": "长按收藏按钮快速添加到这个文件夹",
|
||||||
|
"Added": "已添加",
|
||||||
|
"Turn page by volume keys": "使用音量键翻页"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -178,7 +212,7 @@
|
|||||||
"Select": "選擇",
|
"Select": "選擇",
|
||||||
"Imported @a comics": "已匯入 @a 部漫畫",
|
"Imported @a comics": "已匯入 @a 部漫畫",
|
||||||
"Downloading": "下載中",
|
"Downloading": "下載中",
|
||||||
"Back": "返回",
|
"Back": "後退",
|
||||||
"Delete": "刪除",
|
"Delete": "刪除",
|
||||||
"Full Screen": "全螢幕",
|
"Full Screen": "全螢幕",
|
||||||
"Auto Page Turning": "自動翻頁",
|
"Auto Page Turning": "自動翻頁",
|
||||||
@@ -313,6 +347,40 @@
|
|||||||
"Start": "開始",
|
"Start": "開始",
|
||||||
"Export App Data": "匯出應用數據",
|
"Export App Data": "匯出應用數據",
|
||||||
"Import App Data": "匯入應用數據",
|
"Import App Data": "匯入應用數據",
|
||||||
"Export": "匯出"
|
"Export": "匯出",
|
||||||
|
"Download Threads": "下載線程數",
|
||||||
|
"Update Time": "更新時間",
|
||||||
|
"Copy ID": "複製ID",
|
||||||
|
"Copy URL": "複製URL",
|
||||||
|
"Create": "創建",
|
||||||
|
"Folder Name": "文件夾名稱",
|
||||||
|
"Ranking": "排行",
|
||||||
|
"Download Selected": "下載選中",
|
||||||
|
"Download All": "下載全部",
|
||||||
|
"Order": "順序",
|
||||||
|
"minAppVersion @version is required": "需要最低App版本 @version",
|
||||||
|
"Remove": "移除",
|
||||||
|
"Long press to zoom": "長按縮放",
|
||||||
|
"Updates Available": "更新可用",
|
||||||
|
"Unselected": "未選擇",
|
||||||
|
"Long press and drag to reorder.": "長按並拖動以重新排序。",
|
||||||
|
"Limit image width": "限制圖片寬度",
|
||||||
|
"When using Continuous(Top to Bottom) mode": "當使用連續(從上到下)模式",
|
||||||
|
"Open link": "打開鏈接",
|
||||||
|
"Open comic": "打開漫畫",
|
||||||
|
"Move To First": "移動到最前",
|
||||||
|
"Cancel": "取消",
|
||||||
|
"Paused": "已暫停",
|
||||||
|
"Pause": "暫停",
|
||||||
|
"Operation": "操作",
|
||||||
|
"Upload": "上傳",
|
||||||
|
"Saved": "已保存",
|
||||||
|
"Sync Data": "同步數據",
|
||||||
|
"Syncing Data": "正在同步數據",
|
||||||
|
"Data Sync": "數據同步",
|
||||||
|
"Quick Favorite": "快速收藏",
|
||||||
|
"Long press on the favorite button to quickly add to this folder": "長按收藏按鈕快速添加到這個文件夾",
|
||||||
|
"Added": "已添加",
|
||||||
|
"Turn page by volume keys": "使用音量鍵翻頁"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -15,6 +15,7 @@
|
|||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||||
|
C0086D072CDEFE6E004596D9 /* DirectoryPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0086D062CDEFE64004596D9 /* DirectoryPicker.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
C0086D062CDEFE64004596D9 /* DirectoryPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectoryPicker.swift; sourceTree = "<group>"; };
|
||||||
C22B8A9F3177D4A68EB8F66B /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
C22B8A9F3177D4A68EB8F66B /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@
|
|||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
|
C0086D062CDEFE64004596D9 /* DirectoryPicker.swift */,
|
||||||
);
|
);
|
||||||
path = Runner;
|
path = Runner;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -144,7 +147,6 @@
|
|||||||
730F73FE38E23FCF3E461640 /* Pods-Runner.release.xcconfig */,
|
730F73FE38E23FCF3E461640 /* Pods-Runner.release.xcconfig */,
|
||||||
29B89F848F26E839605E1D88 /* Pods-Runner.profile.xcconfig */,
|
29B89F848F26E839605E1D88 /* Pods-Runner.profile.xcconfig */,
|
||||||
);
|
);
|
||||||
name = Pods;
|
|
||||||
path = Pods;
|
path = Pods;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -336,6 +338,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
C0086D072CDEFE6E004596D9 /* DirectoryPicker.swift in Sources */,
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
);
|
);
|
||||||
|
@@ -1,12 +1,16 @@
|
|||||||
import Flutter
|
import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
|
import Foundation // 添加此行
|
||||||
|
|
||||||
@main
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate, UIDocumentPickerDelegate {
|
@objc class AppDelegate: FlutterAppDelegate, UIDocumentPickerDelegate {
|
||||||
var flutterResult: FlutterResult?
|
var flutterResult: FlutterResult?
|
||||||
var directoryPath: URL!
|
var directoryPath: URL!
|
||||||
|
|
||||||
|
// 定义插件通道名称
|
||||||
|
private var directoryPicker: DirectoryPicker?
|
||||||
|
|
||||||
override func application(
|
override func application(
|
||||||
_ application: UIApplication,
|
_ application: UIApplication,
|
||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
@@ -42,6 +46,9 @@ import UniformTypeIdentifiers
|
|||||||
self.directoryPath?.stopAccessingSecurityScopedResource()
|
self.directoryPath?.stopAccessingSecurityScopedResource()
|
||||||
self.directoryPath = nil
|
self.directoryPath = nil
|
||||||
result(nil)
|
result(nil)
|
||||||
|
} else if call.method == "selectDirectory" {
|
||||||
|
self.directoryPicker = DirectoryPicker()
|
||||||
|
self.directoryPicker?.selectDirectory(result: result)
|
||||||
} else {
|
} else {
|
||||||
result(FlutterMethodNotImplemented)
|
result(FlutterMethodNotImplemented)
|
||||||
}
|
}
|
||||||
|
36
ios/Runner/DirectoryPicker.swift
Normal file
36
ios/Runner/DirectoryPicker.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import UIKit
|
||||||
|
import Flutter
|
||||||
|
|
||||||
|
class DirectoryPicker: NSObject, UIDocumentPickerDelegate {
|
||||||
|
private var result: FlutterResult?
|
||||||
|
|
||||||
|
// 初始化选择目录方法
|
||||||
|
func selectDirectory(result: @escaping FlutterResult) {
|
||||||
|
self.result = result
|
||||||
|
|
||||||
|
// 配置 UIDocumentPicker 为目录选择模式
|
||||||
|
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
|
||||||
|
documentPicker.delegate = self
|
||||||
|
documentPicker.allowsMultipleSelection = false
|
||||||
|
|
||||||
|
// 获取根视图控制器并显示选择器
|
||||||
|
if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
|
||||||
|
rootViewController.present(documentPicker, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理选择完成后的结果
|
||||||
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||||
|
// 获取选中的路径
|
||||||
|
if let url = urls.first {
|
||||||
|
result?(url.path)
|
||||||
|
} else {
|
||||||
|
result?(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理取消选择情况
|
||||||
|
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||||
|
result?(nil)
|
||||||
|
}
|
||||||
|
}
|
@@ -46,6 +46,10 @@
|
|||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
<string>Choose images</string>
|
<string>Choose images</string>
|
||||||
|
<key>UIFileSharingEnabled</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@@ -454,7 +454,9 @@ class _ComicDescription extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
).toAlign(Alignment.topCenter);
|
).toAlign(Alignment.topCenter);
|
||||||
}),
|
}),
|
||||||
),
|
)
|
||||||
|
else
|
||||||
|
const Spacer(),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
|
@@ -129,13 +129,14 @@ void showDialogMessage(BuildContext context, String title, String message) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showConfirmDialog({
|
Future<void> showConfirmDialog({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required String title,
|
required String title,
|
||||||
required String content,
|
required String content,
|
||||||
required void Function() onConfirm,
|
required void Function() onConfirm,
|
||||||
|
String confirmText = "Confirm",
|
||||||
}) {
|
}) {
|
||||||
showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => ContentDialog(
|
builder: (context) => ContentDialog(
|
||||||
title: title,
|
title: title,
|
||||||
@@ -146,7 +147,7 @@ void showConfirmDialog({
|
|||||||
context.pop();
|
context.pop();
|
||||||
onConfirm();
|
onConfirm();
|
||||||
},
|
},
|
||||||
child: Text("Confirm".tl),
|
child: Text(confirmText.tl),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@@ -10,7 +10,7 @@ export "widget_utils.dart";
|
|||||||
export "context.dart";
|
export "context.dart";
|
||||||
|
|
||||||
class _App {
|
class _App {
|
||||||
final version = "1.0.1";
|
final version = "1.0.4";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
|
|
||||||
|
@@ -110,6 +110,14 @@ class _Settings with ChangeNotifier {
|
|||||||
'enablePageAnimation': true,
|
'enablePageAnimation': true,
|
||||||
'language': 'system', // system, zh-CN, zh-TW, en-US
|
'language': 'system', // system, zh-CN, zh-TW, en-US
|
||||||
'cacheSize': 2048, // in MB
|
'cacheSize': 2048, // in MB
|
||||||
|
'downloadThreads': 5,
|
||||||
|
'enableLongPressToZoom': true,
|
||||||
|
'checkUpdateOnStart': true,
|
||||||
|
'limitImageWidth': true,
|
||||||
|
'webdav': [], // empty means not configured
|
||||||
|
'dataVersion': 0,
|
||||||
|
'quickFavorite': null,
|
||||||
|
'enableTurnPageByVolumeKey': true,
|
||||||
};
|
};
|
||||||
|
|
||||||
operator [](String key) {
|
operator [](String key) {
|
||||||
|
@@ -12,6 +12,7 @@ import 'package:venera/foundation/history.dart';
|
|||||||
import 'package:venera/foundation/res.dart';
|
import 'package:venera/foundation/res.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
|
import 'package:venera/utils/translations.dart';
|
||||||
|
|
||||||
import '../js_engine.dart';
|
import '../js_engine.dart';
|
||||||
import '../log.dart';
|
import '../log.dart';
|
||||||
|
@@ -106,7 +106,9 @@ class ComicSourceParser {
|
|||||||
if (minAppVersion != null) {
|
if (minAppVersion != null) {
|
||||||
if (compareSemVer(minAppVersion, App.version.split('-').first)) {
|
if (compareSemVer(minAppVersion, App.version.split('-').first)) {
|
||||||
throw ComicSourceParseException(
|
throw ComicSourceParseException(
|
||||||
"minAppVersion $minAppVersion is required");
|
"minAppVersion @version is required"
|
||||||
|
.tlParams({"version": minAppVersion}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var source in ComicSource.all()) {
|
for (var source in ComicSource.all()) {
|
||||||
@@ -728,7 +730,7 @@ class ComicSourceParser {
|
|||||||
|
|
||||||
return retryZone(func);
|
return retryZone(func);
|
||||||
};
|
};
|
||||||
if(_checkExists("favorites.addFolder")) {
|
if (_checkExists("favorites.addFolder")) {
|
||||||
addFolder = (name) async {
|
addFolder = (name) async {
|
||||||
try {
|
try {
|
||||||
await JsEngine().runCode("""
|
await JsEngine().runCode("""
|
||||||
@@ -741,7 +743,7 @@ class ComicSourceParser {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(_checkExists("favorites.deleteFolder")) {
|
if (_checkExists("favorites.deleteFolder")) {
|
||||||
deleteFolder = (key) async {
|
deleteFolder = (key) async {
|
||||||
try {
|
try {
|
||||||
await JsEngine().runCode("""
|
await JsEngine().runCode("""
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:sqlite3/sqlite3.dart';
|
import 'package:sqlite3/sqlite3.dart';
|
||||||
import 'package:venera/foundation/appdata.dart';
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/foundation/image_provider/local_favorite_image.dart';
|
import 'package:venera/foundation/image_provider/local_favorite_image.dart';
|
||||||
@@ -148,7 +149,7 @@ class FavoriteItemWithFolderInfo extends FavoriteItem {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalFavoritesManager {
|
class LocalFavoritesManager with ChangeNotifier {
|
||||||
factory LocalFavoritesManager() =>
|
factory LocalFavoritesManager() =>
|
||||||
cache ?? (cache = LocalFavoritesManager._create());
|
cache ?? (cache = LocalFavoritesManager._create());
|
||||||
|
|
||||||
@@ -233,6 +234,7 @@ class LocalFavoritesManager {
|
|||||||
values (?, ?);
|
values (?, ?);
|
||||||
""", [folder, order[folder]]);
|
""", [folder, order[folder]]);
|
||||||
}
|
}
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
int count(String folderName) {
|
int count(String folderName) {
|
||||||
@@ -272,6 +274,7 @@ class LocalFavoritesManager {
|
|||||||
set tags = '$tag,' || tags
|
set tags = '$tag,' || tags
|
||||||
where id == ?
|
where id == ?
|
||||||
""", [id]);
|
""", [id]);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FavoriteItemWithFolderInfo> allComics() {
|
List<FavoriteItemWithFolderInfo> allComics() {
|
||||||
@@ -324,6 +327,7 @@ class LocalFavoritesManager {
|
|||||||
primary key (id, type)
|
primary key (id, type)
|
||||||
);
|
);
|
||||||
""");
|
""");
|
||||||
|
notifyListeners();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,6 +390,7 @@ class LocalFavoritesManager {
|
|||||||
values (?, ?, ?, ?, ?, ?, ?, ?);
|
values (?, ?, ?, ?, ?, ?, ?, ?);
|
||||||
""", [...params, minValue(folder) - 1]);
|
""", [...params, minValue(folder) - 1]);
|
||||||
}
|
}
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// delete a folder
|
/// delete a folder
|
||||||
@@ -394,6 +399,7 @@ class LocalFavoritesManager {
|
|||||||
_db.execute("""
|
_db.execute("""
|
||||||
drop table "$name";
|
drop table "$name";
|
||||||
""");
|
""");
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteComic(String folder, FavoriteItem comic) {
|
void deleteComic(String folder, FavoriteItem comic) {
|
||||||
@@ -408,6 +414,7 @@ class LocalFavoritesManager {
|
|||||||
delete from "$folder"
|
delete from "$folder"
|
||||||
where id == ? and type == ?;
|
where id == ? and type == ?;
|
||||||
""", [id, type.value]);
|
""", [id, type.value]);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearAll() async {
|
Future<void> clearAll() async {
|
||||||
@@ -425,6 +432,7 @@ class LocalFavoritesManager {
|
|||||||
for (int i = 0; i < newFolder.length; i++) {
|
for (int i = 0; i < newFolder.length; i++) {
|
||||||
addComic(folder, newFolder[i], i);
|
addComic(folder, newFolder[i], i);
|
||||||
}
|
}
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename(String before, String after) {
|
void rename(String before, String after) {
|
||||||
@@ -438,6 +446,7 @@ class LocalFavoritesManager {
|
|||||||
ALTER TABLE "$before"
|
ALTER TABLE "$before"
|
||||||
RENAME TO "$after";
|
RENAME TO "$after";
|
||||||
""");
|
""");
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onReadEnd(String id, ComicType type) async {
|
void onReadEnd(String id, ComicType type) async {
|
||||||
@@ -475,6 +484,7 @@ class LocalFavoritesManager {
|
|||||||
""", [newTime, id]);
|
""", [newTime, id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FavoriteItemWithFolderInfo> search(String keyword) {
|
List<FavoriteItemWithFolderInfo> search(String keyword) {
|
||||||
@@ -521,6 +531,7 @@ class LocalFavoritesManager {
|
|||||||
set tags = ?
|
set tags = ?
|
||||||
where id == ?;
|
where id == ?;
|
||||||
""", [tags.join(","), id]);
|
""", [tags.join(","), id]);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
final _cachedFavoritedIds = <String, bool>{};
|
final _cachedFavoritedIds = <String, bool>{};
|
||||||
@@ -560,6 +571,7 @@ class LocalFavoritesManager {
|
|||||||
comic.id,
|
comic.id,
|
||||||
comic.type.value
|
comic.type.value
|
||||||
]);
|
]);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
String folderToJson(String folder) {
|
String folderToJson(String folder) {
|
||||||
|
@@ -87,17 +87,16 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>
|
|||||||
return await decode(buffer);
|
return await decode(buffer);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await CacheManager().delete(this.key);
|
await CacheManager().delete(this.key);
|
||||||
Object error = e;
|
|
||||||
if (data.length < 2 * 1024) {
|
if (data.length < 2 * 1024) {
|
||||||
// data is too short, it's likely that the data is text, not image
|
// data is too short, it's likely that the data is text, not image
|
||||||
try {
|
try {
|
||||||
var text = const Utf8Codec(allowMalformed: false).decoder.convert(data);
|
var text = const Utf8Codec(allowMalformed: false).decoder.convert(data);
|
||||||
error = Exception("Expected image data, but got text: $text");
|
throw Exception("Expected image data, but got text: $text");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw error;
|
rethrow;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
scheduleMicrotask(() {
|
scheduleMicrotask(() {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:html/parser.dart' as html;
|
import 'package:html/parser.dart' as html;
|
||||||
@@ -238,7 +237,7 @@ mixin class _JSEngineApi {
|
|||||||
Log.warning(
|
Log.warning(
|
||||||
"JS Engine",
|
"JS Engine",
|
||||||
"Too many documents, deleting the oldest: $shouldDelete\n"
|
"Too many documents, deleting the oldest: $shouldDelete\n"
|
||||||
"Current documents: ${_documents.keys}",
|
"Current documents: ${_documents.keys}",
|
||||||
);
|
);
|
||||||
_documents.remove(shouldDelete);
|
_documents.remove(shouldDelete);
|
||||||
}
|
}
|
||||||
@@ -350,9 +349,6 @@ mixin class _JSEngineApi {
|
|||||||
case "utf8":
|
case "utf8":
|
||||||
return isEncode ? utf8.encode(value) : utf8.decode(value);
|
return isEncode ? utf8.encode(value) : utf8.decode(value);
|
||||||
case "base64":
|
case "base64":
|
||||||
if (value is String) {
|
|
||||||
value = utf8.encode(value);
|
|
||||||
}
|
|
||||||
return isEncode ? base64Encode(value) : base64Decode(value);
|
return isEncode ? base64Encode(value) : base64Decode(value);
|
||||||
case "md5":
|
case "md5":
|
||||||
return Uint8List.fromList(md5.convert(value).bytes);
|
return Uint8List.fromList(md5.convert(value).bytes);
|
||||||
@@ -383,8 +379,21 @@ mixin class _JSEngineApi {
|
|||||||
if (!isEncode) {
|
if (!isEncode) {
|
||||||
var key = data["key"];
|
var key = data["key"];
|
||||||
var cipher = ECBBlockCipher(AESEngine());
|
var cipher = ECBBlockCipher(AESEngine());
|
||||||
cipher.init(false, KeyParameter(key));
|
cipher.init(
|
||||||
return cipher.process(value);
|
false,
|
||||||
|
KeyParameter(key),
|
||||||
|
);
|
||||||
|
var offset = 0;
|
||||||
|
var result = Uint8List(value.length);
|
||||||
|
while (offset < value.length) {
|
||||||
|
offset += cipher.processBlock(
|
||||||
|
value,
|
||||||
|
offset,
|
||||||
|
result,
|
||||||
|
offset,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case "aes-cbc":
|
case "aes-cbc":
|
||||||
@@ -393,7 +402,17 @@ mixin class _JSEngineApi {
|
|||||||
var iv = data["iv"];
|
var iv = data["iv"];
|
||||||
var cipher = CBCBlockCipher(AESEngine());
|
var cipher = CBCBlockCipher(AESEngine());
|
||||||
cipher.init(false, ParametersWithIV(KeyParameter(key), iv));
|
cipher.init(false, ParametersWithIV(KeyParameter(key), iv));
|
||||||
return cipher.process(value);
|
var offset = 0;
|
||||||
|
var result = Uint8List(value.length);
|
||||||
|
while (offset < value.length) {
|
||||||
|
offset += cipher.processBlock(
|
||||||
|
value,
|
||||||
|
offset,
|
||||||
|
result,
|
||||||
|
offset,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case "aes-cfb":
|
case "aes-cfb":
|
||||||
@@ -402,7 +421,17 @@ mixin class _JSEngineApi {
|
|||||||
var blockSize = data["blockSize"];
|
var blockSize = data["blockSize"];
|
||||||
var cipher = CFBBlockCipher(AESEngine(), blockSize);
|
var cipher = CFBBlockCipher(AESEngine(), blockSize);
|
||||||
cipher.init(false, KeyParameter(key));
|
cipher.init(false, KeyParameter(key));
|
||||||
return cipher.process(value);
|
var offset = 0;
|
||||||
|
var result = Uint8List(value.length);
|
||||||
|
while (offset < value.length) {
|
||||||
|
offset += cipher.processBlock(
|
||||||
|
value,
|
||||||
|
offset,
|
||||||
|
result,
|
||||||
|
offset,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case "aes-ofb":
|
case "aes-ofb":
|
||||||
@@ -411,7 +440,17 @@ mixin class _JSEngineApi {
|
|||||||
var blockSize = data["blockSize"];
|
var blockSize = data["blockSize"];
|
||||||
var cipher = OFBBlockCipher(AESEngine(), blockSize);
|
var cipher = OFBBlockCipher(AESEngine(), blockSize);
|
||||||
cipher.init(false, KeyParameter(key));
|
cipher.init(false, KeyParameter(key));
|
||||||
return cipher.process(value);
|
var offset = 0;
|
||||||
|
var result = Uint8List(value.length);
|
||||||
|
while (offset < value.length) {
|
||||||
|
offset += cipher.processBlock(
|
||||||
|
value,
|
||||||
|
offset,
|
||||||
|
result,
|
||||||
|
offset,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case "rsa":
|
case "rsa":
|
||||||
@@ -426,8 +465,8 @@ mixin class _JSEngineApi {
|
|||||||
default:
|
default:
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
Log.error("JS Engine", "Failed to convert $type: $e");
|
Log.error("JS Engine", "Failed to convert $type: $e", s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import 'package:path_provider/path_provider.dart';
|
|||||||
import 'package:sqlite3/sqlite3.dart';
|
import 'package:sqlite3/sqlite3.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
import 'package:venera/foundation/comic_type.dart';
|
import 'package:venera/foundation/comic_type.dart';
|
||||||
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/download.dart';
|
import 'package:venera/network/download.dart';
|
||||||
import 'package:venera/pages/reader/reader.dart';
|
import 'package:venera/pages/reader/reader.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
@@ -158,12 +159,13 @@ class LocalManager with ChangeNotifier {
|
|||||||
return "Directory is not empty";
|
return "Directory is not empty";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await copyDirectory(
|
await copyDirectoryIsolate(
|
||||||
Directory(path),
|
Directory(path),
|
||||||
newDir,
|
newDir,
|
||||||
);
|
);
|
||||||
await File(FilePath.join(App.dataPath, 'local_path')).writeAsString(path);
|
await File(FilePath.join(App.dataPath, 'local_path')).writeAsString(newPath);
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
|
Log.error("IO", e, s);
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
await Directory(path).deleteIgnoreError(recursive:true);
|
await Directory(path).deleteIgnoreError(recursive:true);
|
||||||
|
@@ -82,11 +82,12 @@ class Log {
|
|||||||
addLog(LogLevel.warning, title, content);
|
addLog(LogLevel.warning, title, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
static error(String title, String content, [Object? stackTrace]) {
|
static error(String title, Object content, [Object? stackTrace]) {
|
||||||
|
var info = content.toString();
|
||||||
if(stackTrace != null) {
|
if(stackTrace != null) {
|
||||||
content += "\n${stackTrace.toString()}";
|
info += "\n${stackTrace.toString()}";
|
||||||
}
|
}
|
||||||
addLog(LogLevel.error, title, content);
|
addLog(LogLevel.error, title, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear() => _logs.clear();
|
static void clear() => _logs.clear();
|
||||||
|
@@ -3,8 +3,12 @@ import 'package:desktop_webview_window/desktop_webview_window.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:rhttp/rhttp.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
|
import 'package:venera/network/app_dio.dart';
|
||||||
|
import 'package:venera/pages/comic_source_page.dart';
|
||||||
import 'package:venera/pages/main_page.dart';
|
import 'package:venera/pages/main_page.dart';
|
||||||
|
import 'package:venera/pages/settings/settings_page.dart';
|
||||||
import 'package:venera/utils/app_links.dart';
|
import 'package:venera/utils/app_links.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'components/components.dart';
|
import 'components/components.dart';
|
||||||
@@ -18,6 +22,7 @@ void main(List<String> args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runZonedGuarded(() async {
|
runZonedGuarded(() async {
|
||||||
|
await Rhttp.init();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await init();
|
await init();
|
||||||
if (App.isAndroid) {
|
if (App.isAndroid) {
|
||||||
@@ -63,6 +68,7 @@ class MyApp extends StatefulWidget {
|
|||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
checkUpdates();
|
||||||
App.registerForceRebuild(forceRebuild);
|
App.registerForceRebuild(forceRebuild);
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -163,6 +169,22 @@ class _MyAppState extends State<MyApp> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkUpdates() async {
|
||||||
|
if(!appdata.settings['checkUpdateOnStart']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var lastCheck = appdata.implicitData['lastCheckUpdate'] ?? 0;
|
||||||
|
var now = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
if(now - lastCheck < 24 * 60 * 60 * 1000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
appdata.implicitData['lastCheckUpdate'] = now;
|
||||||
|
appdata.writeImplicitData();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
await checkUpdateUi(false);
|
||||||
|
await ComicSourcePage.checkComicSourceUpdate(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SystemUiProvider extends StatelessWidget {
|
class _SystemUiProvider extends StatelessWidget {
|
||||||
|
@@ -2,8 +2,8 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:rhttp/rhttp.dart' as rhttp;
|
||||||
import 'package:venera/foundation/appdata.dart';
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/cache.dart';
|
import 'package:venera/network/cache.dart';
|
||||||
@@ -108,11 +108,11 @@ class AppDio with DioMixin {
|
|||||||
|
|
||||||
AppDio([BaseOptions? options]) {
|
AppDio([BaseOptions? options]) {
|
||||||
this.options = options ?? BaseOptions();
|
this.options = options ?? BaseOptions();
|
||||||
interceptors.add(MyLogInterceptor());
|
httpClientAdapter = RHttpAdapter(const rhttp.ClientSettings());
|
||||||
httpClientAdapter = IOHttpClientAdapter(createHttpClient: createHttpClient);
|
|
||||||
interceptors.add(CookieManagerSql(SingleInstanceCookieJar.instance!));
|
interceptors.add(CookieManagerSql(SingleInstanceCookieJar.instance!));
|
||||||
interceptors.add(NetworkCacheManager());
|
interceptors.add(NetworkCacheManager());
|
||||||
interceptors.add(CloudflareInterceptor());
|
interceptors.add(CloudflareInterceptor());
|
||||||
|
interceptors.add(MyLogInterceptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
static HttpClient createHttpClient() {
|
static HttpClient createHttpClient() {
|
||||||
@@ -136,8 +136,9 @@ class AppDio with DioMixin {
|
|||||||
static String? proxy;
|
static String? proxy;
|
||||||
|
|
||||||
static Future<String?> getProxy() async {
|
static Future<String?> getProxy() async {
|
||||||
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct")
|
if ((appdata.settings['proxy'] as String).removeAllBlank == "direct") {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
if (appdata.settings['proxy'] != "system") return appdata.settings['proxy'];
|
if (appdata.settings['proxy'] != "system") return appdata.settings['proxy'];
|
||||||
|
|
||||||
String res;
|
String res;
|
||||||
@@ -187,17 +188,14 @@ class AppDio with DioMixin {
|
|||||||
}) async {
|
}) async {
|
||||||
proxy = await getProxy();
|
proxy = await getProxy();
|
||||||
if (_proxy != proxy) {
|
if (_proxy != proxy) {
|
||||||
|
Log.info("Network", "Proxy changed to $proxy");
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
(httpClientAdapter as IOHttpClientAdapter).close();
|
httpClientAdapter = RHttpAdapter(rhttp.ClientSettings(
|
||||||
httpClientAdapter =
|
proxySettings: proxy == null
|
||||||
IOHttpClientAdapter(createHttpClient: createHttpClient);
|
? const rhttp.ProxySettings.noProxy()
|
||||||
|
: rhttp.ProxySettings.proxy(proxy!),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Log.info(
|
|
||||||
"Network",
|
|
||||||
"${options?.method ?? 'GET'} $path\n"
|
|
||||||
"Headers: ${options?.headers}\n"
|
|
||||||
"Data: $data\n",
|
|
||||||
);
|
|
||||||
return super.request(
|
return super.request(
|
||||||
path,
|
path,
|
||||||
data: data,
|
data: data,
|
||||||
@@ -209,3 +207,76 @@ class AppDio with DioMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RHttpAdapter implements HttpClientAdapter {
|
||||||
|
rhttp.ClientSettings settings;
|
||||||
|
|
||||||
|
RHttpAdapter([this.settings = const rhttp.ClientSettings()]) {
|
||||||
|
settings = settings.copyWith(
|
||||||
|
redirectSettings: const rhttp.RedirectSettings.limited(5),
|
||||||
|
timeoutSettings: const rhttp.TimeoutSettings(
|
||||||
|
connectTimeout: Duration(seconds: 15),
|
||||||
|
keepAliveTimeout: Duration(seconds: 60),
|
||||||
|
keepAlivePing: Duration(seconds: 30),
|
||||||
|
),
|
||||||
|
throwOnStatusCode: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void close({bool force = false}) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ResponseBody> fetch(
|
||||||
|
RequestOptions options,
|
||||||
|
Stream<Uint8List>? requestStream,
|
||||||
|
Future<void>? cancelFuture,
|
||||||
|
) async {
|
||||||
|
var res = await rhttp.Rhttp.request(
|
||||||
|
method: switch (options.method) {
|
||||||
|
'GET' => rhttp.HttpMethod.get,
|
||||||
|
'POST' => rhttp.HttpMethod.post,
|
||||||
|
'PUT' => rhttp.HttpMethod.put,
|
||||||
|
'PATCH' => rhttp.HttpMethod.patch,
|
||||||
|
'DELETE' => rhttp.HttpMethod.delete,
|
||||||
|
'HEAD' => rhttp.HttpMethod.head,
|
||||||
|
'OPTIONS' => rhttp.HttpMethod.options,
|
||||||
|
'TRACE' => rhttp.HttpMethod.trace,
|
||||||
|
'CONNECT' => rhttp.HttpMethod.connect,
|
||||||
|
_ => throw ArgumentError('Unsupported method: ${options.method}'),
|
||||||
|
},
|
||||||
|
url: options.uri.toString(),
|
||||||
|
settings: settings,
|
||||||
|
expectBody: rhttp.HttpExpectBody.stream,
|
||||||
|
body: requestStream == null ? null : rhttp.HttpBody.stream(requestStream),
|
||||||
|
headers: rhttp.HttpHeaders.rawMap(
|
||||||
|
Map.fromEntries(
|
||||||
|
options.headers.entries.map(
|
||||||
|
(e) => MapEntry(e.key, e.value.toString().trim()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (res is! rhttp.HttpStreamResponse) {
|
||||||
|
throw Exception("Invalid response type: ${res.runtimeType}");
|
||||||
|
}
|
||||||
|
var headers = <String, List<String>>{};
|
||||||
|
for (var entry in res.headers) {
|
||||||
|
var key = entry.$1.toLowerCase();
|
||||||
|
headers[key] ??= [];
|
||||||
|
headers[key]!.add(entry.$2);
|
||||||
|
}
|
||||||
|
var data = res.body;
|
||||||
|
if(headers['content-encoding']?.contains('gzip') ?? false) {
|
||||||
|
// rhttp does not support gzip decoding
|
||||||
|
data = gzip.decoder.bind(data).map((data) => Uint8List.fromList(data));
|
||||||
|
}
|
||||||
|
return ResponseBody(
|
||||||
|
data,
|
||||||
|
res.statusCode,
|
||||||
|
statusMessage: null,
|
||||||
|
isRedirect: false,
|
||||||
|
headers: headers,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart' show ChangeNotifier;
|
import 'package:flutter/widgets.dart' show ChangeNotifier;
|
||||||
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
import 'package:venera/foundation/comic_type.dart';
|
import 'package:venera/foundation/comic_type.dart';
|
||||||
import 'package:venera/foundation/local.dart';
|
import 'package:venera/foundation/local.dart';
|
||||||
@@ -89,7 +90,7 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
|
|||||||
var local = LocalManager().find(id, comicType);
|
var local = LocalManager().find(id, comicType);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
if (local == null) {
|
if (local == null) {
|
||||||
Directory(path!).deleteIgnoreError();
|
Directory(path!).deleteIgnoreError(recursive: true);
|
||||||
} else if (chapters != null) {
|
} else if (chapters != null) {
|
||||||
for (var c in chapters!) {
|
for (var c in chapters!) {
|
||||||
var dir = Directory(FilePath.join(path!, c));
|
var dir = Directory(FilePath.join(path!, c));
|
||||||
@@ -155,7 +156,7 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
|
|||||||
|
|
||||||
var tasks = <int, _ImageDownloadWrapper>{};
|
var tasks = <int, _ImageDownloadWrapper>{};
|
||||||
|
|
||||||
int get _maxConcurrentTasks => 5;
|
int get _maxConcurrentTasks => (appdata.settings["downloadThreads"] as num).toInt();
|
||||||
|
|
||||||
void _scheduleTasks() {
|
void _scheduleTasks() {
|
||||||
var images = _images![_images!.keys.elementAt(_chapter)]!;
|
var images = _images![_images!.keys.elementAt(_chapter)]!;
|
||||||
|
@@ -3,6 +3,7 @@ import 'dart:typed_data';
|
|||||||
import 'package:venera/foundation/cache_manager.dart';
|
import 'package:venera/foundation/cache_manager.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
import 'package:venera/foundation/consts.dart';
|
import 'package:venera/foundation/consts.dart';
|
||||||
|
import 'package:venera/utils/image.dart';
|
||||||
|
|
||||||
import 'app_dio.dart';
|
import 'app_dio.dart';
|
||||||
|
|
||||||
@@ -27,8 +28,8 @@ class ImageDownloader {
|
|||||||
configs = comicSource?.getThumbnailLoadingConfig?.call(url) ?? {};
|
configs = comicSource?.getThumbnailLoadingConfig?.call(url) ?? {};
|
||||||
}
|
}
|
||||||
configs['headers'] ??= {};
|
configs['headers'] ??= {};
|
||||||
if(configs['headers']['user-agent'] == null
|
if (configs['headers']['user-agent'] == null &&
|
||||||
&& configs['headers']['User-Agent'] == null) {
|
configs['headers']['User-Agent'] == null) {
|
||||||
configs['headers']['user-agent'] = webUA;
|
configs['headers']['user-agent'] = webUA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,11 +121,22 @@ class ImageDownloader {
|
|||||||
buffer = configs['onResponse'](buffer);
|
buffer = configs['onResponse'](buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
await CacheManager().writeCache(cacheKey, buffer);
|
var data = Uint8List.fromList(buffer);
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
if (configs['modifyImage'] != null) {
|
||||||
|
var newData = await modifyImageWithScript(
|
||||||
|
data,
|
||||||
|
configs['modifyImage'],
|
||||||
|
);
|
||||||
|
data = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
await CacheManager().writeCache(cacheKey, data);
|
||||||
yield ImageDownloadProgress(
|
yield ImageDownloadProgress(
|
||||||
currentBytes: buffer.length,
|
currentBytes: data.length,
|
||||||
totalBytes: buffer.length,
|
totalBytes: data.length,
|
||||||
imageBytes: Uint8List.fromList(buffer),
|
imageBytes: data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -173,84 +173,88 @@ class _LoginPageState extends State<_LoginPage> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
constraints: const BoxConstraints(maxWidth: 400),
|
constraints: const BoxConstraints(maxWidth: 400),
|
||||||
child: Column(
|
child: AutofillGroup(
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
Text("Login".tl, style: const TextStyle(fontSize: 24)),
|
children: [
|
||||||
const SizedBox(height: 32),
|
Text("Login".tl, style: const TextStyle(fontSize: 24)),
|
||||||
if (widget.config.cookieFields == null)
|
const SizedBox(height: 32),
|
||||||
TextField(
|
if (widget.config.cookieFields == null)
|
||||||
decoration: InputDecoration(
|
TextField(
|
||||||
labelText: "Username".tl,
|
decoration: InputDecoration(
|
||||||
border: const OutlineInputBorder(),
|
labelText: "Username".tl,
|
||||||
),
|
border: const OutlineInputBorder(),
|
||||||
enabled: widget.config.login != null,
|
),
|
||||||
onChanged: (s) {
|
enabled: widget.config.login != null,
|
||||||
username = s;
|
onChanged: (s) {
|
||||||
},
|
username = s;
|
||||||
).paddingBottom(16),
|
},
|
||||||
if (widget.config.cookieFields == null)
|
autofillHints: const [AutofillHints.username],
|
||||||
TextField(
|
).paddingBottom(16),
|
||||||
decoration: InputDecoration(
|
if (widget.config.cookieFields == null)
|
||||||
labelText: "Password".tl,
|
TextField(
|
||||||
border: const OutlineInputBorder(),
|
decoration: InputDecoration(
|
||||||
),
|
labelText: "Password".tl,
|
||||||
obscureText: true,
|
border: const OutlineInputBorder(),
|
||||||
enabled: widget.config.login != null,
|
),
|
||||||
onChanged: (s) {
|
obscureText: true,
|
||||||
password = s;
|
enabled: widget.config.login != null,
|
||||||
},
|
onChanged: (s) {
|
||||||
onSubmitted: (s) => login(),
|
password = s;
|
||||||
).paddingBottom(16),
|
},
|
||||||
for (var field in widget.config.cookieFields ?? <String>[])
|
onSubmitted: (s) => login(),
|
||||||
TextField(
|
autofillHints: const [AutofillHints.password],
|
||||||
decoration: InputDecoration(
|
).paddingBottom(16),
|
||||||
labelText: field,
|
for (var field in widget.config.cookieFields ?? <String>[])
|
||||||
border: const OutlineInputBorder(),
|
TextField(
|
||||||
),
|
decoration: InputDecoration(
|
||||||
obscureText: true,
|
labelText: field,
|
||||||
enabled: widget.config.validateCookies != null,
|
border: const OutlineInputBorder(),
|
||||||
onChanged: (s) {
|
),
|
||||||
_cookies[field] = s;
|
obscureText: true,
|
||||||
},
|
enabled: widget.config.validateCookies != null,
|
||||||
).paddingBottom(16),
|
onChanged: (s) {
|
||||||
if (widget.config.login == null &&
|
_cookies[field] = s;
|
||||||
widget.config.cookieFields == null)
|
},
|
||||||
Row(
|
).paddingBottom(16),
|
||||||
mainAxisSize: MainAxisSize.min,
|
if (widget.config.login == null &&
|
||||||
children: [
|
widget.config.cookieFields == null)
|
||||||
const Icon(Icons.error_outline),
|
Row(
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text("Login with password is disabled".tl),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Button.filled(
|
|
||||||
isLoading: loading,
|
|
||||||
onPressed: login,
|
|
||||||
child: Text("Continue".tl),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
if (widget.config.loginWebsite != null)
|
|
||||||
TextButton(
|
|
||||||
onPressed: loginWithWebview,
|
|
||||||
child: Text("Login with webview".tl),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
if (widget.config.registerWebsite != null)
|
|
||||||
TextButton(
|
|
||||||
onPressed: () =>
|
|
||||||
launchUrlString(widget.config.registerWebsite!),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.link),
|
const Icon(Icons.error_outline),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text("Create Account".tl),
|
Text("Login with password is disabled".tl),
|
||||||
],
|
],
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Button.filled(
|
||||||
|
isLoading: loading,
|
||||||
|
onPressed: login,
|
||||||
|
child: Text("Continue".tl),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 24),
|
||||||
],
|
if (widget.config.loginWebsite != null)
|
||||||
|
TextButton(
|
||||||
|
onPressed: loginWithWebview,
|
||||||
|
child: Text("Login with webview".tl),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (widget.config.registerWebsite != null)
|
||||||
|
TextButton(
|
||||||
|
onPressed: () =>
|
||||||
|
launchUrlString(widget.config.registerWebsite!),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.link),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text("Create Account".tl),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
import 'package:venera/components/components.dart';
|
import 'package:venera/components/components.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
|
import 'package:venera/foundation/appdata.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
import 'package:venera/foundation/comic_type.dart';
|
import 'package:venera/foundation/comic_type.dart';
|
||||||
import 'package:venera/foundation/consts.dart';
|
import 'package:venera/foundation/consts.dart';
|
||||||
@@ -45,7 +46,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
void updateHistory() async {
|
void updateHistory() async {
|
||||||
var newHistory = await HistoryManager()
|
var newHistory = await HistoryManager()
|
||||||
.find(widget.id, ComicType(widget.sourceKey.hashCode));
|
.find(widget.id, ComicType(widget.sourceKey.hashCode));
|
||||||
if(newHistory?.ep != history?.ep || newHistory?.page != history?.page) {
|
if (newHistory?.ep != history?.ep || newHistory?.page != history?.page) {
|
||||||
history = newHistory;
|
history = newHistory;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
onPressed: continueRead,
|
onPressed: continueRead,
|
||||||
iconColor: context.useTextColor(Colors.yellow),
|
iconColor: context.useTextColor(Colors.yellow),
|
||||||
),
|
),
|
||||||
if(!isMobile || hasHistory)
|
if (!isMobile || hasHistory)
|
||||||
_ActionButton(
|
_ActionButton(
|
||||||
icon: const Icon(Icons.play_circle_outline),
|
icon: const Icon(Icons.play_circle_outline),
|
||||||
text: 'Start'.tl,
|
text: 'Start'.tl,
|
||||||
@@ -268,7 +269,9 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
icon: const Icon(Icons.favorite_border),
|
icon: const Icon(Icons.favorite_border),
|
||||||
activeIcon: const Icon(Icons.favorite),
|
activeIcon: const Icon(Icons.favorite),
|
||||||
isActive: isLiked,
|
isActive: isLiked,
|
||||||
text: (data!.likesCount ?? (isLiked ? 'Liked'.tl : 'Like'.tl))
|
text: ((data!.likesCount != null)
|
||||||
|
? (data!.likesCount! + (isLiked ? 1 : 0))
|
||||||
|
: (isLiked ? 'Liked'.tl : 'Like'.tl))
|
||||||
.toString(),
|
.toString(),
|
||||||
isLoading: isLiking,
|
isLoading: isLiking,
|
||||||
onPressed: likeOrUnlike,
|
onPressed: likeOrUnlike,
|
||||||
@@ -280,6 +283,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
isActive: isFavorite || isAddToLocalFav,
|
isActive: isFavorite || isAddToLocalFav,
|
||||||
text: 'Favorite'.tl,
|
text: 'Favorite'.tl,
|
||||||
onPressed: openFavPanel,
|
onPressed: openFavPanel,
|
||||||
|
onLongPressed: quickFavorite,
|
||||||
iconColor: context.useTextColor(Colors.purple),
|
iconColor: context.useTextColor(Colors.purple),
|
||||||
),
|
),
|
||||||
if (comicSource.commentsLoader != null)
|
if (comicSource.commentsLoader != null)
|
||||||
@@ -536,12 +540,22 @@ abstract mixin class _ComicPageActions {
|
|||||||
|
|
||||||
bool isFavorite = false;
|
bool isFavorite = false;
|
||||||
|
|
||||||
void openFavPanel() {
|
FavoriteItem _toFavoriteItem() {
|
||||||
var tags = <String>[];
|
var tags = <String>[];
|
||||||
for (var e in comic.tags.entries) {
|
for (var e in comic.tags.entries) {
|
||||||
tags.addAll(e.value.map((tag) => '${e.key}:$tag'));
|
tags.addAll(e.value.map((tag) => '${e.key}:$tag'));
|
||||||
}
|
}
|
||||||
|
return FavoriteItem(
|
||||||
|
id: comic.id,
|
||||||
|
name: comic.title,
|
||||||
|
coverPath: comic.cover,
|
||||||
|
author: comic.subTitle ?? comic.uploader ?? '',
|
||||||
|
type: comic.comicType,
|
||||||
|
tags: tags,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void openFavPanel() {
|
||||||
showSideBar(
|
showSideBar(
|
||||||
App.rootContext,
|
App.rootContext,
|
||||||
_FavoritePanel(
|
_FavoritePanel(
|
||||||
@@ -553,18 +567,25 @@ abstract mixin class _ComicPageActions {
|
|||||||
isAddToLocalFav = local ?? isAddToLocalFav;
|
isAddToLocalFav = local ?? isAddToLocalFav;
|
||||||
update();
|
update();
|
||||||
},
|
},
|
||||||
favoriteItem: FavoriteItem(
|
favoriteItem: _toFavoriteItem(),
|
||||||
id: comic.id,
|
|
||||||
name: comic.title,
|
|
||||||
coverPath: comic.cover,
|
|
||||||
author: comic.subTitle ?? comic.uploader ?? '',
|
|
||||||
type: comic.comicType,
|
|
||||||
tags: tags,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void quickFavorite() {
|
||||||
|
var folder = appdata.settings['quickFavorite'];
|
||||||
|
if(folder is! String) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LocalFavoritesManager().addComic(
|
||||||
|
folder,
|
||||||
|
_toFavoriteItem(),
|
||||||
|
);
|
||||||
|
isAddToLocalFav = true;
|
||||||
|
update();
|
||||||
|
App.rootContext.showMessage(message: "Added".tl);
|
||||||
|
}
|
||||||
|
|
||||||
void share() {
|
void share() {
|
||||||
var text = comic.title;
|
var text = comic.title;
|
||||||
if (comic.url != null) {
|
if (comic.url != null) {
|
||||||
@@ -798,6 +819,7 @@ class _ActionButton extends StatelessWidget {
|
|||||||
required this.icon,
|
required this.icon,
|
||||||
required this.text,
|
required this.text,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
|
this.onLongPressed,
|
||||||
this.activeIcon,
|
this.activeIcon,
|
||||||
this.isActive,
|
this.isActive,
|
||||||
this.isLoading,
|
this.isLoading,
|
||||||
@@ -818,6 +840,8 @@ class _ActionButton extends StatelessWidget {
|
|||||||
|
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
|
|
||||||
|
final void Function()? onLongPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -835,6 +859,7 @@ class _ActionButton extends StatelessWidget {
|
|||||||
onPressed();
|
onPressed();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLongPress: onLongPressed,
|
||||||
borderRadius: BorderRadius.circular(18),
|
borderRadius: BorderRadius.circular(18),
|
||||||
child: IconTheme.merge(
|
child: IconTheme.merge(
|
||||||
data: IconThemeData(size: 20, color: iconColor),
|
data: IconThemeData(size: 20, color: iconColor),
|
||||||
@@ -1574,7 +1599,7 @@ class _SelectDownloadChapterState extends State<_SelectDownloadChapter> {
|
|||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FilledButton(
|
child: FilledButton(
|
||||||
onPressed: () {
|
onPressed: selected.isEmpty ? null : () {
|
||||||
widget.finishSelect(selected);
|
widget.finishSelect(selected);
|
||||||
context.pop();
|
context.pop();
|
||||||
},
|
},
|
||||||
@@ -1585,7 +1610,7 @@ class _SelectDownloadChapterState extends State<_SelectDownloadChapter> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: MediaQuery.of(context).padding.bottom + 4),
|
SizedBox(height: MediaQuery.of(context).padding.bottom),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@@ -14,11 +14,11 @@ import 'package:venera/utils/translations.dart';
|
|||||||
class ComicSourcePage extends StatefulWidget {
|
class ComicSourcePage extends StatefulWidget {
|
||||||
const ComicSourcePage({super.key});
|
const ComicSourcePage({super.key});
|
||||||
|
|
||||||
static void checkComicSourceUpdate([bool showLoading = false]) async {
|
static Future<void> checkComicSourceUpdate([bool implicit = false]) async {
|
||||||
if (ComicSource.all().isEmpty) {
|
if (ComicSource.all().isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var controller = showLoading ? showLoadingDialog(App.rootContext) : null;
|
var controller = implicit ? null : showLoadingDialog(App.rootContext);
|
||||||
var dio = AppDio();
|
var dio = AppDio();
|
||||||
var res = await dio.get<String>(
|
var res = await dio.get<String>(
|
||||||
"https://raw.githubusercontent.com/venera-app/venera-configs/master/index.json");
|
"https://raw.githubusercontent.com/venera-app/venera-configs/master/index.json");
|
||||||
@@ -40,7 +40,9 @@ class ComicSourcePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
controller?.close();
|
controller?.close();
|
||||||
if (shouldUpdate.isEmpty) {
|
if (shouldUpdate.isEmpty) {
|
||||||
App.rootContext.showMessage(message: "No Update Available".tl);
|
if(!implicit) {
|
||||||
|
App.rootContext.showMessage(message: "No Update Available".tl);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = "";
|
var msg = "";
|
||||||
@@ -48,10 +50,11 @@ class ComicSourcePage extends StatefulWidget {
|
|||||||
msg += "${ComicSource.find(key)?.name}: v${versions[key]}\n";
|
msg += "${ComicSource.find(key)?.name}: v${versions[key]}\n";
|
||||||
}
|
}
|
||||||
msg = msg.trim();
|
msg = msg.trim();
|
||||||
showConfirmDialog(
|
await showConfirmDialog(
|
||||||
context: App.rootContext,
|
context: App.rootContext,
|
||||||
title: "Updates Available".tl,
|
title: "Updates Available".tl,
|
||||||
content: msg,
|
content: msg,
|
||||||
|
confirmText: "Update",
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
for (var key in shouldUpdate) {
|
for (var key in shouldUpdate) {
|
||||||
var source = ComicSource.find(key);
|
var source = ComicSource.find(key);
|
||||||
@@ -104,7 +107,7 @@ class _BodyState extends State<_Body> {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.update_outlined),
|
leading: const Icon(Icons.update_outlined),
|
||||||
title: Text("Check updates".tl),
|
title: Text("Check updates".tl),
|
||||||
onTap: () => ComicSourcePage.checkComicSourceUpdate(true),
|
onTap: () => ComicSourcePage.checkComicSourceUpdate(false),
|
||||||
trailing: const Icon(Icons.arrow_right),
|
trailing: const Icon(Icons.arrow_right),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -161,71 +164,76 @@ class _BodyState extends State<_Body> {
|
|||||||
for (var item in source.settings!.entries) {
|
for (var item in source.settings!.entries) {
|
||||||
var key = item.key;
|
var key = item.key;
|
||||||
String type = item.value['type'];
|
String type = item.value['type'];
|
||||||
if (type == "select") {
|
try {
|
||||||
var current = source.data['settings'][key];
|
if (type == "select") {
|
||||||
if (current == null) {
|
var current = source.data['settings'][key];
|
||||||
var d = item.value['default'];
|
if (current == null) {
|
||||||
for (var option in item.value['options']) {
|
var d = item.value['default'];
|
||||||
if (option['value'] == d) {
|
for (var option in item.value['options']) {
|
||||||
current = option['text'] ?? option['value'];
|
if (option['value'] == d) {
|
||||||
break;
|
current = option['text'] ?? option['value'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
yield ListTile(
|
||||||
|
title: Text((item.value['title'] as String).ts(source.key)),
|
||||||
|
trailing: Select(
|
||||||
|
current: (current as String).ts(source.key),
|
||||||
|
values: (item.value['options'] as List)
|
||||||
|
.map<String>(
|
||||||
|
(e) => ((e['text'] ?? e['value']) as String).ts(source.key))
|
||||||
|
.toList(),
|
||||||
|
onTap: (i) {
|
||||||
|
source.data['settings'][key] = item.value['options'][i]['value'];
|
||||||
|
source.saveData();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (type == "switch") {
|
||||||
|
var current = source.data['settings'][key] ?? item.value['default'];
|
||||||
|
yield ListTile(
|
||||||
|
title: Text((item.value['title'] as String).ts(source.key)),
|
||||||
|
trailing: Switch(
|
||||||
|
value: current,
|
||||||
|
onChanged: (v) {
|
||||||
|
source.data['settings'][key] = v;
|
||||||
|
source.saveData();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (type == "input") {
|
||||||
|
var current =
|
||||||
|
source.data['settings'][key] ?? item.value['default'] ?? '';
|
||||||
|
yield ListTile(
|
||||||
|
title: Text((item.value['title'] as String).ts(source.key)),
|
||||||
|
subtitle: Text(current, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.edit),
|
||||||
|
onPressed: () {
|
||||||
|
showInputDialog(
|
||||||
|
context: context,
|
||||||
|
title: (item.value['title'] as String).ts(source.key),
|
||||||
|
initialValue: current,
|
||||||
|
inputValidator: item.value['validator'] == null
|
||||||
|
? null
|
||||||
|
: RegExp(item.value['validator']),
|
||||||
|
onConfirm: (value) {
|
||||||
|
source.data['settings'][key] = value;
|
||||||
|
source.saveData();
|
||||||
|
setState(() {});
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
yield ListTile(
|
}
|
||||||
title: Text((item.value['title'] as String).ts(source.key)),
|
catch(e, s) {
|
||||||
trailing: Select(
|
Log.error("ComicSourcePage", "Failed to build a setting\n$e\n$s");
|
||||||
current: (current as String).ts(source.key),
|
|
||||||
values: (item.value['options'] as List)
|
|
||||||
.map<String>(
|
|
||||||
(e) => ((e['text'] ?? e['value']) as String).ts(source.key))
|
|
||||||
.toList(),
|
|
||||||
onTap: (i) {
|
|
||||||
source.data['settings'][key] = item.value['options'][i]['value'];
|
|
||||||
source.saveData();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (type == "switch") {
|
|
||||||
var current = source.data['settings'][key] ?? item.value['default'];
|
|
||||||
yield ListTile(
|
|
||||||
title: Text((item.value['title'] as String).ts(source.key)),
|
|
||||||
trailing: Switch(
|
|
||||||
value: current,
|
|
||||||
onChanged: (v) {
|
|
||||||
source.data['settings'][key] = v;
|
|
||||||
source.saveData();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (type == "input") {
|
|
||||||
var current =
|
|
||||||
source.data['settings'][key] ?? item.value['default'] ?? '';
|
|
||||||
yield ListTile(
|
|
||||||
title: Text((item.value['title'] as String).ts(source.key)),
|
|
||||||
subtitle: Text(current, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
||||||
trailing: IconButton(
|
|
||||||
icon: const Icon(Icons.edit),
|
|
||||||
onPressed: () {
|
|
||||||
showInputDialog(
|
|
||||||
context: context,
|
|
||||||
title: (item.value['title'] as String).ts(source.key),
|
|
||||||
initialValue: current,
|
|
||||||
inputValidator: item.value['validator'] == null
|
|
||||||
? null
|
|
||||||
: RegExp(item.value['validator']),
|
|
||||||
onConfirm: (value) {
|
|
||||||
source.data['settings'][key] = value;
|
|
||||||
source.saveData();
|
|
||||||
setState(() {});
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,10 +454,11 @@ class _ComicSourceListState extends State<_ComicSourceList> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var key = json![index]["key"];
|
var key = json![index]["key"];
|
||||||
var action = currentKey.contains(key)
|
var action = currentKey.contains(key)
|
||||||
? const Icon(Icons.check)
|
? const Icon(Icons.check, size: 20).paddingRight(8)
|
||||||
: Tooltip(
|
: Tooltip(
|
||||||
message: "Add",
|
message: "Add",
|
||||||
child: IconButton(
|
child: Button.icon(
|
||||||
|
color: context.colorScheme.primary,
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.onAdd(
|
await widget.onAdd(
|
||||||
|
@@ -145,19 +145,21 @@ class _ExplorePageState extends State<ExplorePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
var current = notifications.metrics.pixels;
|
var current = notifications.metrics.pixels;
|
||||||
|
var overflow = notifications.metrics.outOfRange;
|
||||||
if ((current > location && current != 0) && showFB) {
|
if (current > location && current != 0 && showFB) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showFB = false;
|
showFB = false;
|
||||||
});
|
});
|
||||||
} else if ((current < location || current == 0) &&
|
} else if ((current < location - 50 || current == 0) &&
|
||||||
!showFB) {
|
!showFB) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showFB = true;
|
showFB = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if ((current > location || current < location - 50) &&
|
||||||
location = current;
|
!overflow) {
|
||||||
|
location = current;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: MediaQuery.removePadding(
|
child: MediaQuery.removePadding(
|
||||||
|
@@ -6,7 +6,6 @@ Future<void> newFolder() async {
|
|||||||
context: App.rootContext,
|
context: App.rootContext,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
var controller = TextEditingController();
|
var controller = TextEditingController();
|
||||||
var folders = LocalFavoritesManager().folderNames;
|
|
||||||
String? error;
|
String? error;
|
||||||
|
|
||||||
return StatefulBuilder(builder: (context, setState) {
|
return StatefulBuilder(builder: (context, setState) {
|
||||||
|
@@ -152,7 +152,8 @@ class _FavoritesPageState extends State<FavoritesPage> {
|
|||||||
} else {
|
} else {
|
||||||
var favoriteData = getFavoriteDataOrNull(folder!);
|
var favoriteData = getFavoriteDataOrNull(folder!);
|
||||||
if (favoriteData == null) {
|
if (favoriteData == null) {
|
||||||
return const Center(child: Text("Unknown source"));
|
folder = null;
|
||||||
|
return buildBody();
|
||||||
} else {
|
} else {
|
||||||
return NetworkFavoritePage(favoriteData, key: Key(folder!));
|
return NetworkFavoritePage(favoriteData, key: Key(folder!));
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,8 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
late List<FavoriteItem> comics;
|
late List<FavoriteItem> comics;
|
||||||
|
|
||||||
void updateComics() {
|
void updateComics() {
|
||||||
print(comics.length);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
comics = LocalFavoritesManager().getAllComics(widget.folder);
|
comics = LocalFavoritesManager().getAllComics(widget.folder);
|
||||||
print(comics.length);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +105,9 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
},
|
},
|
||||||
).then(
|
).then(
|
||||||
(value) {
|
(value) {
|
||||||
setState(() {});
|
if(mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -199,6 +199,7 @@ class _ReorderComicsPageState extends State<_ReorderComicsPage> {
|
|||||||
var comicSource = e.type.comicSource;
|
var comicSource = e.type.comicSource;
|
||||||
return ComicTile(
|
return ComicTile(
|
||||||
key: Key(e.hashCode.toString()),
|
key: Key(e.hashCode.toString()),
|
||||||
|
enableLongPressed: false,
|
||||||
comic: Comic(
|
comic: Comic(
|
||||||
e.name,
|
e.name,
|
||||||
e.coverPath,
|
e.coverPath,
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sliver_tools/sliver_tools.dart';
|
||||||
import 'package:venera/components/components.dart';
|
import 'package:venera/components/components.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
@@ -17,6 +18,7 @@ import 'package:venera/pages/downloading_page.dart';
|
|||||||
import 'package:venera/pages/history_page.dart';
|
import 'package:venera/pages/history_page.dart';
|
||||||
import 'package:venera/pages/search_page.dart';
|
import 'package:venera/pages/search_page.dart';
|
||||||
import 'package:venera/utils/cbz.dart';
|
import 'package:venera/utils/cbz.dart';
|
||||||
|
import 'package:venera/utils/data_sync.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
@@ -32,6 +34,7 @@ class HomePage extends StatelessWidget {
|
|||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(padding: EdgeInsets.only(top: context.padding.top)),
|
SliverPadding(padding: EdgeInsets.only(top: context.padding.top)),
|
||||||
const _SearchBar(),
|
const _SearchBar(),
|
||||||
|
const _SyncDataWidget(),
|
||||||
const _History(),
|
const _History(),
|
||||||
const _Local(),
|
const _Local(),
|
||||||
const _ComicSourceWidget(),
|
const _ComicSourceWidget(),
|
||||||
@@ -77,6 +80,97 @@ class _SearchBar extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _SyncDataWidget extends StatefulWidget {
|
||||||
|
const _SyncDataWidget();
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_SyncDataWidget> createState() => _SyncDataWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SyncDataWidgetState extends State<_SyncDataWidget> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
DataSync().addListener(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
if(mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
DataSync().removeListener(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget child;
|
||||||
|
if(!DataSync().isEnabled) {
|
||||||
|
child = const SliverPadding(padding: EdgeInsets.zero);
|
||||||
|
} else if (DataSync().isUploading || DataSync().isDownloading) {
|
||||||
|
child = SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: const Icon(Icons.sync),
|
||||||
|
title: Text('Syncing Data'.tl),
|
||||||
|
trailing: const CircularProgressIndicator(strokeWidth: 2)
|
||||||
|
.fixWidth(18)
|
||||||
|
.fixHeight(18),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
child = SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).colorScheme.outlineVariant,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: const Icon(Icons.sync),
|
||||||
|
title: Text('Sync Data'.tl),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.cloud_upload_outlined),
|
||||||
|
onPressed: () async {
|
||||||
|
DataSync().uploadData();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.cloud_download_outlined),
|
||||||
|
onPressed: () async {
|
||||||
|
DataSync().downloadData();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return SliverAnimatedPaintExtent(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _History extends StatefulWidget {
|
class _History extends StatefulWidget {
|
||||||
const _History();
|
const _History();
|
||||||
|
|
||||||
@@ -529,14 +623,16 @@ class _ImportComicsWidgetState extends State<_ImportComicsWidget> {
|
|||||||
await xFile!.saveTo(cache);
|
await xFile!.saveTo(cache);
|
||||||
var comic = await CBZ.import(File(cache));
|
var comic = await CBZ.import(File(cache));
|
||||||
if (selectedFolder != null) {
|
if (selectedFolder != null) {
|
||||||
LocalFavoritesManager().addComic(selectedFolder!, FavoriteItem(
|
LocalFavoritesManager().addComic(
|
||||||
id: comic.id,
|
selectedFolder!,
|
||||||
name: comic.title,
|
FavoriteItem(
|
||||||
coverPath: comic.cover,
|
id: comic.id,
|
||||||
author: comic.subtitle,
|
name: comic.title,
|
||||||
type: comic.comicType,
|
coverPath: comic.cover,
|
||||||
tags: comic.tags,
|
author: comic.subtitle,
|
||||||
));
|
type: comic.comicType,
|
||||||
|
tags: comic.tags,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
await File(cache).deleteIgnoreError();
|
await File(cache).deleteIgnoreError();
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
@@ -610,14 +706,16 @@ class _ImportComicsWidgetState extends State<_ImportComicsWidget> {
|
|||||||
for (var comic in comics.values) {
|
for (var comic in comics.values) {
|
||||||
LocalManager().add(comic, LocalManager().findValidId(ComicType.local));
|
LocalManager().add(comic, LocalManager().findValidId(ComicType.local));
|
||||||
if (selectedFolder != null) {
|
if (selectedFolder != null) {
|
||||||
LocalFavoritesManager().addComic(selectedFolder!, FavoriteItem(
|
LocalFavoritesManager().addComic(
|
||||||
id: comic.id,
|
selectedFolder!,
|
||||||
name: comic.title,
|
FavoriteItem(
|
||||||
coverPath: comic.cover,
|
id: comic.id,
|
||||||
author: comic.subtitle,
|
name: comic.title,
|
||||||
type: comic.comicType,
|
coverPath: comic.cover,
|
||||||
tags: comic.tags,
|
author: comic.subtitle,
|
||||||
));
|
type: comic.comicType,
|
||||||
|
tags: comic.tags,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.pop();
|
context.pop();
|
||||||
|
@@ -24,8 +24,12 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
|
|
||||||
bool searchMode = false;
|
bool searchMode = false;
|
||||||
|
|
||||||
|
bool multiSelectMode = false;
|
||||||
|
|
||||||
|
Map<LocalComic, bool> selectedComics = {};
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
if(keyword.isEmpty) {
|
if (keyword.isEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
comics = LocalManager().getComics(sortType);
|
comics = LocalManager().getComics(sortType);
|
||||||
});
|
});
|
||||||
@@ -95,8 +99,7 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
actions: [
|
actions: [
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
appdata.implicitData["local_sort"] =
|
appdata.implicitData["local_sort"] =sortType.value;
|
||||||
sortType.value;
|
|
||||||
appdata.writeImplicitData();
|
appdata.writeImplicitData();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
update();
|
update();
|
||||||
@@ -115,7 +118,7 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: SmoothCustomScrollView(
|
body: SmoothCustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
if(!searchMode)
|
if (!searchMode && !multiSelectMode)
|
||||||
SliverAppbar(
|
SliverAppbar(
|
||||||
title: Text("Local".tl),
|
title: Text("Local".tl),
|
||||||
actions: [
|
actions: [
|
||||||
@@ -145,10 +148,38 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
showPopUpWidget(context, const DownloadingPage());
|
showPopUpWidget(context, const DownloadingPage());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
Tooltip(
|
||||||
|
message: multiSelectMode
|
||||||
|
? "Exit Multi-Select".tl
|
||||||
|
: "Multi-Select".tl,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(Icons.checklist),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
multiSelectMode = !multiSelectMode;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
else
|
else if (multiSelectMode)
|
||||||
|
SliverAppbar(
|
||||||
|
title: Text("Selected ${selectedComics.length} comics"),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
multiSelectMode = false;
|
||||||
|
selectedComics.clear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
else if (searchMode)
|
||||||
SliverAppbar(
|
SliverAppbar(
|
||||||
title: TextField(
|
title: TextField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
@@ -176,16 +207,42 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
),
|
),
|
||||||
SliverGridComics(
|
SliverGridComics(
|
||||||
comics: comics,
|
comics: comics,
|
||||||
onTap: (c) {
|
onTap: multiSelectMode
|
||||||
(c as LocalComic).read();
|
? (c) {
|
||||||
},
|
setState(() {
|
||||||
|
if (selectedComics.containsKey(c as LocalComic)) {
|
||||||
|
selectedComics.remove(c as LocalComic);
|
||||||
|
} else {
|
||||||
|
selectedComics[c as LocalComic] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: (c) {
|
||||||
|
(c as LocalComic).read();
|
||||||
|
},
|
||||||
menuBuilder: (c) {
|
menuBuilder: (c) {
|
||||||
return [
|
return [
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
icon: Icons.delete,
|
icon: Icons.delete,
|
||||||
text: "Delete".tl,
|
text: "Delete".tl,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
LocalManager().deleteComic(c as LocalComic);
|
if (multiSelectMode) {
|
||||||
|
showConfirmDialog(
|
||||||
|
context: context,
|
||||||
|
title: "Delete".tl,
|
||||||
|
content: "Delete selected comics?".tl,
|
||||||
|
onConfirm: () {
|
||||||
|
for (var comic in selectedComics.keys) {
|
||||||
|
LocalManager().deleteComic(comic);
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
selectedComics.clear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
LocalManager().deleteComic(c as LocalComic);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
icon: Icons.outbox_outlined,
|
icon: Icons.outbox_outlined,
|
||||||
@@ -196,9 +253,20 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
allowCancel: false,
|
allowCancel: false,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var file = await CBZ.export(c as LocalComic);
|
if (multiSelectMode) {
|
||||||
await saveFile(filename: file.name, file: file);
|
for (var comic in selectedComics.keys) {
|
||||||
await file.delete();
|
var file = await CBZ.export(comic);
|
||||||
|
await saveFile(filename: file.name, file: file);
|
||||||
|
await file.delete();
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
selectedComics.clear();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var file = await CBZ.export(c as LocalComic);
|
||||||
|
await saveFile(filename: file.name, file: file);
|
||||||
|
await file.delete();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
context.showMessage(message: e.toString());
|
context.showMessage(message: e.toString());
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,8 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
|
|
||||||
_DragListener? dragListener;
|
_DragListener? dragListener;
|
||||||
|
|
||||||
|
int fingers = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_tapGestureRecognizer = TapGestureRecognizer()
|
_tapGestureRecognizer = TapGestureRecognizer()
|
||||||
@@ -38,6 +40,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
return Listener(
|
return Listener(
|
||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
onPointerDown: (event) {
|
onPointerDown: (event) {
|
||||||
|
fingers++;
|
||||||
_lastTapPointer = event.pointer;
|
_lastTapPointer = event.pointer;
|
||||||
_lastTapMoveDistance = Offset.zero;
|
_lastTapMoveDistance = Offset.zero;
|
||||||
_tapGestureRecognizer.addPointer(event);
|
_tapGestureRecognizer.addPointer(event);
|
||||||
@@ -46,7 +49,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
_dragInProgress = false;
|
_dragInProgress = false;
|
||||||
}
|
}
|
||||||
Future.delayed(_kLongPressMinTime, () {
|
Future.delayed(_kLongPressMinTime, () {
|
||||||
if (_lastTapPointer == event.pointer) {
|
if (_lastTapPointer == event.pointer && fingers == 1) {
|
||||||
if(_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) {
|
if(_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) {
|
||||||
onLongPressedDown(event.position);
|
onLongPressedDown(event.position);
|
||||||
_longPressInProgress = true;
|
_longPressInProgress = true;
|
||||||
@@ -67,6 +70,19 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerUp: (event) {
|
onPointerUp: (event) {
|
||||||
|
fingers--;
|
||||||
|
if (_longPressInProgress) {
|
||||||
|
onLongPressedUp(event.position);
|
||||||
|
}
|
||||||
|
if(_dragInProgress) {
|
||||||
|
dragListener?.onEnd?.call();
|
||||||
|
_dragInProgress = false;
|
||||||
|
}
|
||||||
|
_lastTapPointer = null;
|
||||||
|
_lastTapMoveDistance = null;
|
||||||
|
},
|
||||||
|
onPointerCancel: (event) {
|
||||||
|
fingers--;
|
||||||
if (_longPressInProgress) {
|
if (_longPressInProgress) {
|
||||||
onLongPressedUp(event.position);
|
onLongPressedUp(event.position);
|
||||||
}
|
}
|
||||||
|
@@ -223,6 +223,9 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleLongPressDown(Offset location) {
|
void handleLongPressDown(Offset location) {
|
||||||
|
if(!appdata.settings['enableLongPressToZoom']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var photoViewController = photoViewControllers[reader.page]!;
|
var photoViewController = photoViewControllers[reader.page]!;
|
||||||
double target = photoViewController.getInitialScale!.call()! * 1.75;
|
double target = photoViewController.getInitialScale!.call()! * 1.75;
|
||||||
var size = MediaQuery.of(context).size;
|
var size = MediaQuery.of(context).size;
|
||||||
@@ -234,6 +237,9 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleLongPressUp(Offset location) {
|
void handleLongPressUp(Offset location) {
|
||||||
|
if(!appdata.settings['enableLongPressToZoom']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var photoViewController = photoViewControllers[reader.page]!;
|
var photoViewController = photoViewControllers[reader.page]!;
|
||||||
double target = photoViewController.getInitialScale!.call()!;
|
double target = photoViewController.getInitialScale!.call()!;
|
||||||
photoViewController.animateScale?.call(target);
|
photoViewController.animateScale?.call(target);
|
||||||
@@ -465,18 +471,24 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
|||||||
},
|
},
|
||||||
child: widget,
|
child: widget,
|
||||||
);
|
);
|
||||||
|
var width = MediaQuery.of(context).size.width;
|
||||||
|
var height = MediaQuery.of(context).size.height;
|
||||||
|
if(appdata.settings['limitImageWidth'] && width / height > 0.7) {
|
||||||
|
width = height * 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
return PhotoView.customChild(
|
return PhotoView.customChild(
|
||||||
backgroundDecoration: BoxDecoration(
|
backgroundDecoration: BoxDecoration(
|
||||||
color: context.colorScheme.surface,
|
color: context.colorScheme.surface,
|
||||||
),
|
),
|
||||||
|
childSize: Size(width, height),
|
||||||
minScale: 1.0,
|
minScale: 1.0,
|
||||||
maxScale: 2.5,
|
maxScale: 2.5,
|
||||||
strictScale: true,
|
strictScale: true,
|
||||||
controller: photoViewController,
|
controller: photoViewController,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: width,
|
||||||
height: MediaQuery.of(context).size.height,
|
height: height,
|
||||||
child: widget,
|
child: widget,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -509,6 +521,9 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleLongPressDown(Offset location) {
|
void handleLongPressDown(Offset location) {
|
||||||
|
if(!appdata.settings['enableLongPressToZoom']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
double target = photoViewController.getInitialScale!.call()! * 1.75;
|
double target = photoViewController.getInitialScale!.call()! * 1.75;
|
||||||
var size = MediaQuery.of(context).size;
|
var size = MediaQuery.of(context).size;
|
||||||
photoViewController.animateScale?.call(
|
photoViewController.animateScale?.call(
|
||||||
@@ -519,6 +534,9 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleLongPressUp(Offset location) {
|
void handleLongPressUp(Offset location) {
|
||||||
|
if(!appdata.settings['enableLongPressToZoom']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
double target = photoViewController.getInitialScale!.call()!;
|
double target = photoViewController.getInitialScale!.call()!;
|
||||||
photoViewController.animateScale?.call(target);
|
photoViewController.animateScale?.call(target);
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import 'package:venera/pages/settings/settings_page.dart';
|
|||||||
import 'package:venera/utils/file_type.dart';
|
import 'package:venera/utils/file_type.dart';
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
|
import 'package:venera/utils/volume.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
part 'scaffold.dart';
|
part 'scaffold.dart';
|
||||||
@@ -97,6 +98,8 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
|
|
||||||
var focusNode = FocusNode();
|
var focusNode = FocusNode();
|
||||||
|
|
||||||
|
VolumeListener? volumeListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
page = widget.initialPage ?? 1;
|
page = widget.initialPage ?? 1;
|
||||||
@@ -107,6 +110,9 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
updateHistory();
|
updateHistory();
|
||||||
});
|
});
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
|
if(appdata.settings['enableTurnPageByVolumeKey']) {
|
||||||
|
handleVolumeEvent();
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +121,7 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
autoPageTurningTimer?.cancel();
|
autoPageTurningTimer?.cancel();
|
||||||
focusNode.dispose();
|
focusNode.dispose();
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
stopVolumeEvent();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +159,31 @@ class _ReaderState extends State<Reader> with _ReaderLocation, _ReaderWindow {
|
|||||||
HistoryManager().addHistory(history!);
|
HistoryManager().addHistory(history!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleVolumeEvent() {
|
||||||
|
if(!App.isAndroid) {
|
||||||
|
// Currently only support Android
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(volumeListener != null) {
|
||||||
|
volumeListener?.cancel();
|
||||||
|
}
|
||||||
|
volumeListener = VolumeListener(
|
||||||
|
onDown: () {
|
||||||
|
toNextPage();
|
||||||
|
},
|
||||||
|
onUp: () {
|
||||||
|
toPrevPage();
|
||||||
|
},
|
||||||
|
)..listen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopVolumeEvent() {
|
||||||
|
if(volumeListener != null) {
|
||||||
|
volumeListener?.cancel();
|
||||||
|
volumeListener = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract mixin class _ReaderLocation {
|
abstract mixin class _ReaderLocation {
|
||||||
|
@@ -107,7 +107,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openOrClose() {
|
void openOrClose() {
|
||||||
if(!_isOpen) {
|
if (!_isOpen) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
} else {
|
} else {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||||
@@ -147,7 +147,9 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
),
|
),
|
||||||
AnimatedPositioned(
|
AnimatedPositioned(
|
||||||
duration: const Duration(milliseconds: 180),
|
duration: const Duration(milliseconds: 180),
|
||||||
bottom: _isOpen ? 0 : -(kBottomBarHeight + MediaQuery.of(context).padding.bottom),
|
bottom: _isOpen
|
||||||
|
? 0
|
||||||
|
: -(kBottomBarHeight + MediaQuery.of(context).padding.bottom),
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: buildBottom(),
|
child: buildBottom(),
|
||||||
@@ -218,7 +220,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
if (!context.reader.toPrevChapter()) {
|
if (!context.reader.toPrevChapter()) {
|
||||||
context.reader.toPage(1);
|
context.reader.toPage(1);
|
||||||
} else {
|
} else {
|
||||||
if(showFloatingButtonValue != 0) {
|
if (showFloatingButtonValue != 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showFloatingButtonValue = 0;
|
showFloatingButtonValue = 0;
|
||||||
});
|
});
|
||||||
@@ -235,7 +237,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
if (!context.reader.toNextChapter()) {
|
if (!context.reader.toNextChapter()) {
|
||||||
context.reader.toPage(context.reader.maxPage);
|
context.reader.toPage(context.reader.maxPage);
|
||||||
} else {
|
} else {
|
||||||
if(showFloatingButtonValue != 0) {
|
if (showFloatingButtonValue != 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showFloatingButtonValue = 0;
|
showFloatingButtonValue = 0;
|
||||||
});
|
});
|
||||||
@@ -260,7 +262,9 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
color: Theme.of(context).colorScheme.tertiaryContainer,
|
color: Theme.of(context).colorScheme.tertiaryContainer,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(text),
|
child: Center(
|
||||||
|
child: Text(text),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
if (App.isWindows)
|
if (App.isWindows)
|
||||||
@@ -389,7 +393,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
|
|
||||||
Widget buildPageInfoText() {
|
Widget buildPageInfoText() {
|
||||||
var epName = context.reader.widget.chapters?.values
|
var epName = context.reader.widget.chapters?.values
|
||||||
.elementAt(context.reader.chapter - 1) ??
|
.elementAtOrNull(context.reader.chapter - 1) ??
|
||||||
"E${context.reader.chapter}";
|
"E${context.reader.chapter}";
|
||||||
if (epName.length > 8) {
|
if (epName.length > 8) {
|
||||||
epName = "${epName.substring(0, 8)}...";
|
epName = "${epName.substring(0, 8)}...";
|
||||||
@@ -466,6 +470,13 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
context.reader.mode = ReaderMode.fromKey(appdata.settings[key]);
|
context.reader.mode = ReaderMode.fromKey(appdata.settings[key]);
|
||||||
App.rootContext.pop();
|
App.rootContext.pop();
|
||||||
}
|
}
|
||||||
|
if (key == "enableTurnPageByVolumeKey") {
|
||||||
|
if(appdata.settings[key]) {
|
||||||
|
context.reader.handleVolumeEvent();
|
||||||
|
} else {
|
||||||
|
context.reader.stopVolumeEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
context.reader.update();
|
context.reader.update();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -539,7 +550,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
height: value.clamp(0, 58*3) / 3,
|
height: value.clamp(0, 58 * 3) / 3,
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
|
@@ -369,6 +369,9 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
),
|
),
|
||||||
trailing: const Icon(Icons.arrow_right),
|
trailing: const Icon(Icons.arrow_right),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
suggestions.clear();
|
||||||
|
});
|
||||||
handleAppLink(Uri.parse(controller.text));
|
handleAppLink(Uri.parse(controller.text));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@@ -42,7 +42,7 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
|
|
||||||
void search([String? text]) {
|
void search([String? text]) {
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
if(suggestionsController.entry != null) {
|
if (suggestionsController.entry != null) {
|
||||||
suggestionsController.remove();
|
suggestionsController.remove();
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -135,20 +135,24 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
action: buildAction(),
|
action: buildAction(),
|
||||||
),
|
),
|
||||||
loadPage: source!.searchPageData!.loadPage == null ? null : (i) {
|
loadPage: source!.searchPageData!.loadPage == null
|
||||||
return source.searchPageData!.loadPage!(
|
? null
|
||||||
text,
|
: (i) {
|
||||||
i,
|
return source.searchPageData!.loadPage!(
|
||||||
options,
|
text,
|
||||||
);
|
i,
|
||||||
},
|
options,
|
||||||
loadNext: source.searchPageData!.loadNext == null ? null : (i) {
|
);
|
||||||
return source.searchPageData!.loadNext!(
|
},
|
||||||
text,
|
loadNext: source.searchPageData!.loadNext == null
|
||||||
i,
|
? null
|
||||||
options,
|
: (i) {
|
||||||
);
|
return source.searchPageData!.loadNext!(
|
||||||
},
|
text,
|
||||||
|
i,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,6 +428,11 @@ class _SearchSettingsDialogState extends State<_SearchSettingsDialog> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
searchTarget = e.key;
|
searchTarget = e.key;
|
||||||
options.clear();
|
options.clear();
|
||||||
|
final searchOptions = ComicSource.find(searchTarget)!
|
||||||
|
.searchPageData!
|
||||||
|
.searchOptions ??
|
||||||
|
<SearchOptions>[];
|
||||||
|
options = searchOptions.map((e) => e.defaultValue).toList();
|
||||||
onChanged();
|
onChanged();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -53,30 +53,7 @@ class _AboutSettingsState extends State<AboutSettings> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isCheckingUpdate = true;
|
isCheckingUpdate = true;
|
||||||
});
|
});
|
||||||
checkUpdate().then((value) {
|
checkUpdateUi().then((value) {
|
||||||
if (value) {
|
|
||||||
showDialog(
|
|
||||||
context: App.rootContext,
|
|
||||||
builder: (context) {
|
|
||||||
return ContentDialog(
|
|
||||||
title: "New version available".tl,
|
|
||||||
content: Text(
|
|
||||||
"A new version is available. Do you want to update now?"
|
|
||||||
.tl),
|
|
||||||
actions: [
|
|
||||||
Button.text(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
launchUrlString(
|
|
||||||
"https://github.com/venera-app/venera/releases");
|
|
||||||
},
|
|
||||||
child: Text("Update".tl),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
context.showMessage(message: "No new version available".tl);
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isCheckingUpdate = false;
|
isCheckingUpdate = false;
|
||||||
});
|
});
|
||||||
@@ -108,6 +85,33 @@ Future<bool> checkUpdate() async {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> checkUpdateUi([bool showMessageIfNoUpdate = true]) async {
|
||||||
|
var value = await checkUpdate();
|
||||||
|
if (value) {
|
||||||
|
showDialog(
|
||||||
|
context: App.rootContext,
|
||||||
|
builder: (context) {
|
||||||
|
return ContentDialog(
|
||||||
|
title: "New version available".tl,
|
||||||
|
content: Text(
|
||||||
|
"A new version is available. Do you want to update now?".tl),
|
||||||
|
actions: [
|
||||||
|
Button.text(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
launchUrlString(
|
||||||
|
"https://github.com/venera-app/venera/releases");
|
||||||
|
},
|
||||||
|
child: Text("Update".tl),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else if (showMessageIfNoUpdate) {
|
||||||
|
App.rootContext.showMessage(message: "No new version available".tl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// return true if version1 > version2
|
/// return true if version1 > version2
|
||||||
bool _compareVersion(String version1, String version2) {
|
bool _compareVersion(String version1, String version2) {
|
||||||
var v1 = version1.split(".");
|
var v1 = version1.split(".");
|
||||||
|
@@ -20,16 +20,44 @@ class _AppSettingsState extends State<AppSettings> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Storage Path for local comics".tl),
|
title: Text("Storage Path for local comics".tl),
|
||||||
subtitle: Text(LocalManager().path, softWrap: false),
|
subtitle: Text(LocalManager().path, softWrap: false),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.copy),
|
||||||
|
onPressed: () {
|
||||||
|
Clipboard.setData(ClipboardData(text: LocalManager().path));
|
||||||
|
context.showMessage(message: "Path copied to clipboard".tl);
|
||||||
|
},
|
||||||
|
),
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
_CallbackSetting(
|
_CallbackSetting(
|
||||||
title: "Set New Storage Path".tl,
|
title: "Set New Storage Path".tl,
|
||||||
actionTitle: "Set".tl,
|
actionTitle: "Set".tl,
|
||||||
callback: () async {
|
callback: () async {
|
||||||
if (App.isMobile) {
|
String? result;
|
||||||
context.showMessage(message: "Not supported".tl);
|
if (App.isAndroid) {
|
||||||
return;
|
var channel = const MethodChannel("venera/storage");
|
||||||
|
var permission = await channel.invokeMethod('');
|
||||||
|
if(permission != true) {
|
||||||
|
context.showMessage(message: "Permission denied".tl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var path = await selectDirectory();
|
||||||
|
if(path != null) {
|
||||||
|
// check if the path is writable
|
||||||
|
var testFile = File(FilePath.join(path, "test"));
|
||||||
|
try {
|
||||||
|
await testFile.writeAsBytes([1]);
|
||||||
|
await testFile.delete();
|
||||||
|
} catch (e) {
|
||||||
|
context.showMessage(message: "Permission denied".tl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = path;
|
||||||
|
}
|
||||||
|
} else if (App.isIOS) {
|
||||||
|
result = await selectDirectoryIOS();
|
||||||
|
} else {
|
||||||
|
result = await selectDirectory();
|
||||||
}
|
}
|
||||||
var result = await selectDirectory();
|
|
||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
var loadingDialog = showLoadingDialog(
|
var loadingDialog = showLoadingDialog(
|
||||||
App.rootContext,
|
App.rootContext,
|
||||||
@@ -78,8 +106,7 @@ class _AppSettingsState extends State<AppSettings> {
|
|||||||
appdata.settings['cacheSize'] = int.parse(value);
|
appdata.settings['cacheSize'] = int.parse(value);
|
||||||
appdata.saveData();
|
appdata.saveData();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
CacheManager()
|
CacheManager().setLimitSize(appdata.settings['cacheSize']);
|
||||||
.setLimitSize(appdata.settings['cacheSize']);
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -101,13 +128,12 @@ class _AppSettingsState extends State<AppSettings> {
|
|||||||
callback: () async {
|
callback: () async {
|
||||||
var controller = showLoadingDialog(context);
|
var controller = showLoadingDialog(context);
|
||||||
var file = await selectFile(ext: ['venera']);
|
var file = await selectFile(ext: ['venera']);
|
||||||
if(file != null) {
|
if (file != null) {
|
||||||
var cacheFile = File(FilePath.join(App.cachePath, "temp.venera"));
|
var cacheFile = File(FilePath.join(App.cachePath, "temp.venera"));
|
||||||
await file.saveTo(cacheFile.path);
|
await file.saveTo(cacheFile.path);
|
||||||
try {
|
try {
|
||||||
await importAppData(cacheFile);
|
await importAppData(cacheFile);
|
||||||
}
|
} catch (e, s) {
|
||||||
catch(e, s) {
|
|
||||||
Log.error("Import data", e.toString(), s);
|
Log.error("Import data", e.toString(), s);
|
||||||
context.showMessage(message: "Failed to import data".tl);
|
context.showMessage(message: "Failed to import data".tl);
|
||||||
}
|
}
|
||||||
@@ -116,6 +142,13 @@ class _AppSettingsState extends State<AppSettings> {
|
|||||||
},
|
},
|
||||||
actionTitle: 'Import'.tl,
|
actionTitle: 'Import'.tl,
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
|
_CallbackSetting(
|
||||||
|
title: "Data Sync".tl,
|
||||||
|
callback: () async {
|
||||||
|
showPopUpWidget(context, const _WebdavSetting());
|
||||||
|
},
|
||||||
|
actionTitle: 'Set'.tl,
|
||||||
|
).toSliver(),
|
||||||
_SettingPartTitle(
|
_SettingPartTitle(
|
||||||
title: "Log".tl,
|
title: "Log".tl,
|
||||||
icon: Icons.error_outline,
|
icon: Icons.error_outline,
|
||||||
@@ -271,3 +304,129 @@ class _LogsPageState extends State<LogsPage> {
|
|||||||
saveFile(data: utf8.encode(log), filename: 'log.txt');
|
saveFile(data: utf8.encode(log), filename: 'log.txt');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _WebdavSetting extends StatefulWidget {
|
||||||
|
const _WebdavSetting();
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_WebdavSetting> createState() => _WebdavSettingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebdavSettingState extends State<_WebdavSetting> {
|
||||||
|
String url = "";
|
||||||
|
String user = "";
|
||||||
|
String pass = "";
|
||||||
|
|
||||||
|
bool isTesting = false;
|
||||||
|
|
||||||
|
bool upload = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (appdata.settings['webdav'] is! List) {
|
||||||
|
appdata.settings['webdav'] = [];
|
||||||
|
}
|
||||||
|
var configs = appdata.settings['webdav'] as List;
|
||||||
|
if (configs.whereType<String>().length != 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
url = configs[0];
|
||||||
|
user = configs[1];
|
||||||
|
pass = configs[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PopUpWidgetScaffold(
|
||||||
|
title: "Webdav",
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: "URL",
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
controller: TextEditingController(text: url),
|
||||||
|
onChanged: (value) => url = value,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: "Username".tl,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
controller: TextEditingController(text: user),
|
||||||
|
onChanged: (value) => user = value,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: "Password".tl,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
controller: TextEditingController(text: pass),
|
||||||
|
onChanged: (value) => pass = value,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text("Operation".tl),
|
||||||
|
Radio<bool>(
|
||||||
|
groupValue: upload,
|
||||||
|
value: true,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
upload = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text("Upload".tl),
|
||||||
|
Radio<bool>(
|
||||||
|
groupValue: upload,
|
||||||
|
value: false,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
upload = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text("Download".tl),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Center(
|
||||||
|
child: Button.filled(
|
||||||
|
isLoading: isTesting,
|
||||||
|
onPressed: () async {
|
||||||
|
var oldConfig = appdata.settings['webdav'];
|
||||||
|
appdata.settings['webdav'] = [url, user, pass];
|
||||||
|
setState(() {
|
||||||
|
isTesting = true;
|
||||||
|
});
|
||||||
|
var testResult = upload
|
||||||
|
? await DataSync().uploadData()
|
||||||
|
: await DataSync().downloadData();
|
||||||
|
if (testResult.error) {
|
||||||
|
setState(() {
|
||||||
|
isTesting = false;
|
||||||
|
});
|
||||||
|
appdata.settings['webdav'] = oldConfig;
|
||||||
|
context.showMessage(message: testResult.errorMessage!);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
appdata.saveData();
|
||||||
|
context.showMessage(message: "Saved".tl);
|
||||||
|
App.rootPop();
|
||||||
|
},
|
||||||
|
child: Text("Continue".tl),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingHorizontal(16),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -24,12 +24,20 @@ class _LocalFavoritesSettingsState extends State<LocalFavoritesSettings> {
|
|||||||
SelectSetting(
|
SelectSetting(
|
||||||
title: "Move favorite after reading".tl,
|
title: "Move favorite after reading".tl,
|
||||||
settingKey: "moveFavoriteAfterRead",
|
settingKey: "moveFavoriteAfterRead",
|
||||||
optionTranslation: {
|
optionTranslation: const {
|
||||||
"none": "None",
|
"none": "None",
|
||||||
"end": "End",
|
"end": "End",
|
||||||
"start": "Start",
|
"start": "Start",
|
||||||
},
|
},
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
|
SelectSetting(
|
||||||
|
title: "Quick Favorite".tl,
|
||||||
|
settingKey: "quickFavorite",
|
||||||
|
help: "Long press on the favorite button to quickly add to this folder".tl,
|
||||||
|
optionTranslation: {
|
||||||
|
for (var e in LocalFavoritesManager().folderNames) e: e
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,13 @@ class _NetworkSettingsState extends State<NetworkSettings> {
|
|||||||
title: "Proxy".tl,
|
title: "Proxy".tl,
|
||||||
builder: () => const _ProxySettingView(),
|
builder: () => const _ProxySettingView(),
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
|
_SliderSetting(
|
||||||
|
title: "Download Threads".tl,
|
||||||
|
settingsIndex: 'downloadThreads',
|
||||||
|
interval: 1,
|
||||||
|
min: 1,
|
||||||
|
max: 16,
|
||||||
|
).toSliver(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -42,50 +49,50 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
|
|
||||||
// USERNAME:PASSWORD@HOST:PORT
|
// USERNAME:PASSWORD@HOST:PORT
|
||||||
String toProxyStr() {
|
String toProxyStr() {
|
||||||
if(type == 'direct') {
|
if (type == 'direct') {
|
||||||
return 'direct';
|
return 'direct';
|
||||||
} else if(type == 'system') {
|
} else if (type == 'system') {
|
||||||
return 'system';
|
return 'system';
|
||||||
}
|
}
|
||||||
var res = '';
|
var res = '';
|
||||||
if(username.isNotEmpty) {
|
if (username.isNotEmpty) {
|
||||||
res += username;
|
res += username;
|
||||||
if(password.isNotEmpty) {
|
if (password.isNotEmpty) {
|
||||||
res += ':$password';
|
res += ':$password';
|
||||||
}
|
}
|
||||||
res += '@';
|
res += '@';
|
||||||
}
|
}
|
||||||
res += host;
|
res += host;
|
||||||
if(port.isNotEmpty) {
|
if (port.isNotEmpty) {
|
||||||
res += ':$port';
|
res += ':$port';
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseProxyString(String proxy) {
|
void parseProxyString(String proxy) {
|
||||||
if(proxy == 'direct') {
|
if (proxy == 'direct') {
|
||||||
type = 'direct';
|
type = 'direct';
|
||||||
return;
|
return;
|
||||||
} else if(proxy == 'system') {
|
} else if (proxy == 'system') {
|
||||||
type = 'system';
|
type = 'system';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
type = 'manual';
|
type = 'manual';
|
||||||
var parts = proxy.split('@');
|
var parts = proxy.split('@');
|
||||||
if(parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
var auth = parts[0].split(':');
|
var auth = parts[0].split(':');
|
||||||
if(auth.length == 2) {
|
if (auth.length == 2) {
|
||||||
username = auth[0];
|
username = auth[0];
|
||||||
password = auth[1];
|
password = auth[1];
|
||||||
}
|
}
|
||||||
parts = parts[1].split(':');
|
parts = parts[1].split(':');
|
||||||
if(parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
host = parts[0];
|
host = parts[0];
|
||||||
port = parts[1];
|
port = parts[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parts = proxy.split(':');
|
parts = proxy.split(':');
|
||||||
if(parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
host = parts[0];
|
host = parts[0];
|
||||||
port = parts[1];
|
port = parts[1];
|
||||||
}
|
}
|
||||||
@@ -140,7 +147,7 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if(type == 'manual') buildManualProxy(),
|
if (type == 'manual') buildManualProxy(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -164,7 +171,7 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
host = v;
|
host = v;
|
||||||
},
|
},
|
||||||
validator: (v) {
|
validator: (v) {
|
||||||
if(v?.isEmpty ?? false) {
|
if (v?.isEmpty ?? false) {
|
||||||
return "Host cannot be empty".tl;
|
return "Host cannot be empty".tl;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -181,10 +188,10 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
port = v;
|
port = v;
|
||||||
},
|
},
|
||||||
validator: (v) {
|
validator: (v) {
|
||||||
if(v?.isEmpty ?? true) {
|
if (v?.isEmpty ?? true) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(int.tryParse(v!) == null) {
|
if (int.tryParse(v!) == null) {
|
||||||
return "Port must be a number".tl;
|
return "Port must be a number".tl;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -201,7 +208,7 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
username = v;
|
username = v;
|
||||||
},
|
},
|
||||||
validator: (v) {
|
validator: (v) {
|
||||||
if((v?.isEmpty ?? false) && password.isNotEmpty) {
|
if ((v?.isEmpty ?? false) && password.isNotEmpty) {
|
||||||
return "Username cannot be empty".tl;
|
return "Username cannot be empty".tl;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -221,7 +228,7 @@ class _ProxySettingViewState extends State<_ProxySettingView> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if(formKey.currentState?.validate() ?? false) {
|
if (formKey.currentState?.validate() ?? false) {
|
||||||
appdata.settings['proxy'] = toProxyStr();
|
appdata.settings['proxy'] = toProxyStr();
|
||||||
appdata.saveData();
|
appdata.saveData();
|
||||||
App.rootContext.pop();
|
App.rootContext.pop();
|
||||||
|
@@ -54,6 +54,29 @@ class _ReaderSettingsState extends State<ReaderSettings> {
|
|||||||
widget.onChanged?.call("autoPageTurningInterval");
|
widget.onChanged?.call("autoPageTurningInterval");
|
||||||
},
|
},
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
|
_SwitchSetting(
|
||||||
|
title: 'Long press to zoom'.tl,
|
||||||
|
settingKey: 'enableLongPressToZoom',
|
||||||
|
onChanged: () {
|
||||||
|
widget.onChanged?.call('enableLongPressToZoom');
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
|
_SwitchSetting(
|
||||||
|
title: 'Limit image width'.tl,
|
||||||
|
subtitle: 'When using Continuous(Top to Bottom) mode'.tl,
|
||||||
|
settingKey: 'limitImageWidth',
|
||||||
|
onChanged: () {
|
||||||
|
widget.onChanged?.call('limitImageWidth');
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
|
if(App.isAndroid)
|
||||||
|
_SwitchSetting(
|
||||||
|
title: 'Turn page by volume key'.tl,
|
||||||
|
settingKey: 'enableTurnPageByVolumeKey',
|
||||||
|
onChanged: () {
|
||||||
|
widget.onChanged?.call('enableTurnPageByVolumeKey');
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ class _SwitchSetting extends StatefulWidget {
|
|||||||
required this.title,
|
required this.title,
|
||||||
required this.settingKey,
|
required this.settingKey,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.subtitle,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
@@ -13,6 +14,8 @@ class _SwitchSetting extends StatefulWidget {
|
|||||||
|
|
||||||
final VoidCallback? onChanged;
|
final VoidCallback? onChanged;
|
||||||
|
|
||||||
|
final String? subtitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_SwitchSetting> createState() => _SwitchSettingState();
|
State<_SwitchSetting> createState() => _SwitchSettingState();
|
||||||
}
|
}
|
||||||
@@ -24,6 +27,7 @@ class _SwitchSettingState extends State<_SwitchSetting> {
|
|||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
|
subtitle: widget.subtitle == null ? null : Text(widget.subtitle!),
|
||||||
trailing: Switch(
|
trailing: Switch(
|
||||||
value: appdata.settings[widget.settingKey],
|
value: appdata.settings[widget.settingKey],
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@@ -45,6 +49,7 @@ class SelectSetting extends StatelessWidget {
|
|||||||
required this.settingKey,
|
required this.settingKey,
|
||||||
required this.optionTranslation,
|
required this.optionTranslation,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.help,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
@@ -55,6 +60,8 @@ class SelectSetting extends StatelessWidget {
|
|||||||
|
|
||||||
final VoidCallback? onChanged;
|
final VoidCallback? onChanged;
|
||||||
|
|
||||||
|
final String? help;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
@@ -67,6 +74,7 @@ class SelectSetting extends StatelessWidget {
|
|||||||
settingKey: settingKey,
|
settingKey: settingKey,
|
||||||
optionTranslation: optionTranslation,
|
optionTranslation: optionTranslation,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
|
help: help,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return _EndSelectorSelectSetting(
|
return _EndSelectorSelectSetting(
|
||||||
@@ -74,6 +82,7 @@ class SelectSetting extends StatelessWidget {
|
|||||||
settingKey: settingKey,
|
settingKey: settingKey,
|
||||||
optionTranslation: optionTranslation,
|
optionTranslation: optionTranslation,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
|
help: help,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -88,6 +97,7 @@ class _DoubleLineSelectSettings extends StatefulWidget {
|
|||||||
required this.settingKey,
|
required this.settingKey,
|
||||||
required this.optionTranslation,
|
required this.optionTranslation,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.help,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
@@ -98,6 +108,8 @@ class _DoubleLineSelectSettings extends StatefulWidget {
|
|||||||
|
|
||||||
final VoidCallback? onChanged;
|
final VoidCallback? onChanged;
|
||||||
|
|
||||||
|
final String? help;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_DoubleLineSelectSettings> createState() =>
|
State<_DoubleLineSelectSettings> createState() =>
|
||||||
_DoubleLineSelectSettingsState();
|
_DoubleLineSelectSettingsState();
|
||||||
@@ -107,9 +119,37 @@ class _DoubleLineSelectSettingsState extends State<_DoubleLineSelectSettings> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(widget.title),
|
title: Row(
|
||||||
subtitle:
|
children: [
|
||||||
Text(widget.optionTranslation[appdata.settings[widget.settingKey]]!),
|
Text(widget.title),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
if (widget.help != null)
|
||||||
|
Button.icon(
|
||||||
|
size: 18,
|
||||||
|
icon: const Icon(Icons.help_outline),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return ContentDialog(
|
||||||
|
title: "Help".tl,
|
||||||
|
content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity),
|
||||||
|
actions: [
|
||||||
|
Button.filled(
|
||||||
|
onPressed: context.pop,
|
||||||
|
child: Text("OK".tl),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
widget.optionTranslation[appdata.settings[widget.settingKey]] ??
|
||||||
|
"None"),
|
||||||
trailing: const Icon(Icons.arrow_drop_down),
|
trailing: const Icon(Icons.arrow_drop_down),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
var renderBox = context.findRenderObject() as RenderBox;
|
var renderBox = context.findRenderObject() as RenderBox;
|
||||||
@@ -152,6 +192,7 @@ class _EndSelectorSelectSetting extends StatefulWidget {
|
|||||||
required this.settingKey,
|
required this.settingKey,
|
||||||
required this.optionTranslation,
|
required this.optionTranslation,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.help,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
@@ -162,6 +203,8 @@ class _EndSelectorSelectSetting extends StatefulWidget {
|
|||||||
|
|
||||||
final VoidCallback? onChanged;
|
final VoidCallback? onChanged;
|
||||||
|
|
||||||
|
final String? help;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_EndSelectorSelectSetting> createState() =>
|
State<_EndSelectorSelectSetting> createState() =>
|
||||||
_EndSelectorSelectSettingState();
|
_EndSelectorSelectSettingState();
|
||||||
@@ -172,10 +215,38 @@ class _EndSelectorSelectSettingState extends State<_EndSelectorSelectSetting> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var options = widget.optionTranslation;
|
var options = widget.optionTranslation;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(widget.title),
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Text(widget.title),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
if (widget.help != null)
|
||||||
|
Button.icon(
|
||||||
|
size: 18,
|
||||||
|
icon: const Icon(Icons.help_outline),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return ContentDialog(
|
||||||
|
title: "Help".tl,
|
||||||
|
content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity),
|
||||||
|
actions: [
|
||||||
|
Button.filled(
|
||||||
|
onPressed: context.pop,
|
||||||
|
child: Text("OK".tl),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
trailing: Select(
|
trailing: Select(
|
||||||
current: options[appdata.settings[widget.settingKey]]!,
|
current: options[appdata.settings[widget.settingKey]],
|
||||||
values: options.values.toList(),
|
values: options.values.toList(),
|
||||||
|
minWidth: 64,
|
||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
appdata.settings[widget.settingKey] = options.keys.elementAt(index);
|
appdata.settings[widget.settingKey] = options.keys.elementAt(index);
|
||||||
|
@@ -11,10 +11,12 @@ import 'package:venera/foundation/appdata.dart';
|
|||||||
import 'package:venera/foundation/cache_manager.dart';
|
import 'package:venera/foundation/cache_manager.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
import 'package:venera/foundation/consts.dart';
|
import 'package:venera/foundation/consts.dart';
|
||||||
|
import 'package:venera/foundation/favorites.dart';
|
||||||
import 'package:venera/foundation/local.dart';
|
import 'package:venera/foundation/local.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/app_dio.dart';
|
import 'package:venera/network/app_dio.dart';
|
||||||
import 'package:venera/utils/data.dart';
|
import 'package:venera/utils/data.dart';
|
||||||
|
import 'package:venera/utils/data_sync.dart';
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
@@ -98,14 +98,14 @@ class _AppWebviewState extends State<AppWebview> {
|
|||||||
0),
|
0),
|
||||||
items: [
|
items: [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text("Open in browser".tl),
|
child: Text("Open in browser".tl),
|
||||||
onTap: () async =>
|
onTap: () async =>
|
||||||
launchUrlString((await controller?.getUrl())!.path),
|
launchUrlString((await controller?.getUrl())!.toString()),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text("Copy link".tl),
|
child: Text("Copy link".tl),
|
||||||
onTap: () async => Clipboard.setData(ClipboardData(
|
onTap: () async => Clipboard.setData(ClipboardData(
|
||||||
text: (await controller?.getUrl())!.path)),
|
text: (await controller?.getUrl())!.toString())),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text("Reload".tl),
|
child: Text("Reload".tl),
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
@@ -35,7 +36,7 @@ Future<File> exportAppData() async {
|
|||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> importAppData(File file) async {
|
Future<void> importAppData(File file, [bool checkVersion = false]) async {
|
||||||
var cacheDirPath = FilePath.join(App.cachePath, 'temp_data');
|
var cacheDirPath = FilePath.join(App.cachePath, 'temp_data');
|
||||||
var cacheDir = Directory(cacheDirPath);
|
var cacheDir = Directory(cacheDirPath);
|
||||||
await Isolate.run(() {
|
await Isolate.run(() {
|
||||||
@@ -44,14 +45,21 @@ Future<void> importAppData(File file) async {
|
|||||||
var historyFile = cacheDir.joinFile("history.db");
|
var historyFile = cacheDir.joinFile("history.db");
|
||||||
var localFavoriteFile = cacheDir.joinFile("local_favorite.db");
|
var localFavoriteFile = cacheDir.joinFile("local_favorite.db");
|
||||||
var appdataFile = cacheDir.joinFile("appdata.json");
|
var appdataFile = cacheDir.joinFile("appdata.json");
|
||||||
|
if(checkVersion && appdataFile.existsSync()) {
|
||||||
|
var data = jsonDecode(await appdataFile.readAsString());
|
||||||
|
var version = data["settings"]["dataVersion"];
|
||||||
|
if(version is int && version <= appdata.settings["dataVersion"]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(await historyFile.exists()) {
|
if(await historyFile.exists()) {
|
||||||
HistoryManager().close();
|
HistoryManager().close();
|
||||||
await historyFile.copy(FilePath.join(App.dataPath, "history.db"));
|
historyFile.copySync(FilePath.join(App.dataPath, "history.db"));
|
||||||
HistoryManager().init();
|
HistoryManager().init();
|
||||||
}
|
}
|
||||||
if(await localFavoriteFile.exists()) {
|
if(await localFavoriteFile.exists()) {
|
||||||
LocalFavoritesManager().close();
|
LocalFavoritesManager().close();
|
||||||
await localFavoriteFile.copy(FilePath.join(App.dataPath, "local_favorite.db"));
|
localFavoriteFile.copySync(FilePath.join(App.dataPath, "local_favorite.db"));
|
||||||
LocalFavoritesManager().init();
|
LocalFavoritesManager().init();
|
||||||
}
|
}
|
||||||
if(await appdataFile.exists()) {
|
if(await appdataFile.exists()) {
|
||||||
|
205
lib/utils/data_sync.dart
Normal file
205
lib/utils/data_sync.dart
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
import 'package:dio/io.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:venera/foundation/app.dart';
|
||||||
|
import 'package:venera/foundation/appdata.dart';
|
||||||
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
|
import 'package:venera/foundation/favorites.dart';
|
||||||
|
import 'package:venera/foundation/history.dart';
|
||||||
|
import 'package:venera/foundation/log.dart';
|
||||||
|
import 'package:venera/foundation/res.dart';
|
||||||
|
import 'package:venera/network/app_dio.dart';
|
||||||
|
import 'package:venera/utils/data.dart';
|
||||||
|
import 'package:venera/utils/ext.dart';
|
||||||
|
import 'package:webdav_client/webdav_client.dart' hide File;
|
||||||
|
|
||||||
|
import 'io.dart';
|
||||||
|
|
||||||
|
class DataSync with ChangeNotifier {
|
||||||
|
DataSync._() {
|
||||||
|
if (isEnabled) {
|
||||||
|
downloadData();
|
||||||
|
}
|
||||||
|
HistoryManager().addListener(onDataChanged);
|
||||||
|
LocalFavoritesManager().addListener(onDataChanged);
|
||||||
|
ComicSource.addListener(onDataChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onDataChanged() {
|
||||||
|
if (isEnabled) {
|
||||||
|
uploadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static DataSync? instance;
|
||||||
|
|
||||||
|
factory DataSync() => instance ?? (instance = DataSync._());
|
||||||
|
|
||||||
|
bool isDownloading = false;
|
||||||
|
|
||||||
|
bool isUploading = false;
|
||||||
|
|
||||||
|
bool haveWaitingTask = false;
|
||||||
|
|
||||||
|
bool get isEnabled {
|
||||||
|
var config = appdata.settings['webdav'];
|
||||||
|
return config is List && config.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String>? _validateConfig() {
|
||||||
|
var config = appdata.settings['webdav'];
|
||||||
|
if (config is! List || (config.isNotEmpty && config.length != 3)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (config.whereType<String>().length != 3) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return List.from(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Res<bool>> uploadData() async {
|
||||||
|
if (haveWaitingTask) return const Res(true);
|
||||||
|
while (isDownloading || isUploading) {
|
||||||
|
haveWaitingTask = true;
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
}
|
||||||
|
haveWaitingTask = false;
|
||||||
|
isUploading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
var config = _validateConfig();
|
||||||
|
if (config == null) {
|
||||||
|
return const Res.error('Invalid WebDAV configuration');
|
||||||
|
}
|
||||||
|
if (config.isEmpty) {
|
||||||
|
return const Res(true);
|
||||||
|
}
|
||||||
|
String url = config[0];
|
||||||
|
String user = config[1];
|
||||||
|
String pass = config[2];
|
||||||
|
|
||||||
|
var proxy = await AppDio.getProxy();
|
||||||
|
|
||||||
|
var client = newClient(
|
||||||
|
url,
|
||||||
|
user: user,
|
||||||
|
password: pass,
|
||||||
|
adapter: IOHttpClientAdapter(
|
||||||
|
createHttpClient: () {
|
||||||
|
return HttpClient()
|
||||||
|
..findProxy = (uri) => proxy == null ? "DIRECT" : "PROXY $proxy";
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await client.ping();
|
||||||
|
} catch (e) {
|
||||||
|
Log.error("Upload Data", 'Failed to connect to WebDAV server');
|
||||||
|
return const Res.error('Failed to connect to WebDAV server');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
appdata.settings['dataVersion']++;
|
||||||
|
await appdata.saveData();
|
||||||
|
var data = await exportAppData();
|
||||||
|
var time =
|
||||||
|
(DateTime.now().millisecondsSinceEpoch ~/ 86400000).toString();
|
||||||
|
var filename = time;
|
||||||
|
filename += '-';
|
||||||
|
filename += appdata.settings['dataVersion'].toString();
|
||||||
|
filename += '.venera';
|
||||||
|
var files = await client.readDir('/');
|
||||||
|
files = files.where((e) => e.name!.endsWith('.venera')).toList();
|
||||||
|
var old = files.firstWhereOrNull( (e) => e.name!.startsWith("$time-"));
|
||||||
|
if (old != null) {
|
||||||
|
await client.remove(old.name!);
|
||||||
|
}
|
||||||
|
if (files.length >= 10) {
|
||||||
|
files.sort((a, b) => a.name!.compareTo(b.name!));
|
||||||
|
await client.remove(files.first.name!);
|
||||||
|
}
|
||||||
|
await client.write(filename, await data.readAsBytes());
|
||||||
|
Log.info("Upload Data", "Data uploaded successfully");
|
||||||
|
return const Res(true);
|
||||||
|
} catch (e, s) {
|
||||||
|
Log.error("Upload Data", e, s);
|
||||||
|
return Res.error(e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
isUploading = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Res<bool>> downloadData() async {
|
||||||
|
if (haveWaitingTask) return const Res(true);
|
||||||
|
while (isDownloading || isUploading) {
|
||||||
|
haveWaitingTask = true;
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
}
|
||||||
|
haveWaitingTask = false;
|
||||||
|
isDownloading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
var config = _validateConfig();
|
||||||
|
if (config == null) {
|
||||||
|
return const Res.error('Invalid WebDAV configuration');
|
||||||
|
}
|
||||||
|
if (config.isEmpty) {
|
||||||
|
return const Res(true);
|
||||||
|
}
|
||||||
|
String url = config[0];
|
||||||
|
String user = config[1];
|
||||||
|
String pass = config[2];
|
||||||
|
|
||||||
|
var proxy = await AppDio.getProxy();
|
||||||
|
|
||||||
|
var client = newClient(
|
||||||
|
url,
|
||||||
|
user: user,
|
||||||
|
password: pass,
|
||||||
|
adapter: IOHttpClientAdapter(
|
||||||
|
createHttpClient: () {
|
||||||
|
return HttpClient()
|
||||||
|
..findProxy = (uri) => proxy == null ? "DIRECT" : "PROXY $proxy";
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await client.ping();
|
||||||
|
} catch (e) {
|
||||||
|
Log.error("Data Sync", 'Failed to connect to WebDAV server');
|
||||||
|
return const Res.error('Failed to connect to WebDAV server');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var files = await client.readDir('/');
|
||||||
|
files.sort((a, b) => b.name!.compareTo(a.name!));
|
||||||
|
var file = files.firstWhereOrNull((e) => e.name!.endsWith('.venera'));
|
||||||
|
var version =
|
||||||
|
file!.name!.split('-').elementAtOrNull(1)?.split('.').first;
|
||||||
|
if (version != null && int.tryParse(version) != null) {
|
||||||
|
var currentVersion = appdata.settings['dataVersion'];
|
||||||
|
if (currentVersion != null && int.parse(version) <= currentVersion) {
|
||||||
|
Log.info("Data Sync", 'No new data to download');
|
||||||
|
return const Res(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.info("Data Sync", "Downloading data from WebDAV server");
|
||||||
|
var localFile = File(FilePath.join(App.cachePath, file.name!));
|
||||||
|
await client.read2File(file.name!, localFile.path);
|
||||||
|
await importAppData(localFile, true);
|
||||||
|
await localFile.delete();
|
||||||
|
Log.info("Data Sync", "Data downloaded successfully");
|
||||||
|
return const Res(true);
|
||||||
|
} catch (e, s) {
|
||||||
|
Log.error("Data Sync", e, s);
|
||||||
|
return Res.error(e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
isDownloading = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
316
lib/utils/image.dart
Normal file
316
lib/utils/image.dart
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
import 'dart:ffi';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_qjs/flutter_qjs.dart';
|
||||||
|
import 'package:lodepng_flutter/lodepng_flutter.dart' as lodepng;
|
||||||
|
|
||||||
|
class Image {
|
||||||
|
final Uint32List _data;
|
||||||
|
|
||||||
|
final int width;
|
||||||
|
|
||||||
|
final int height;
|
||||||
|
|
||||||
|
Image(this._data, this.width, this.height) {
|
||||||
|
if (_data.length != width * height) {
|
||||||
|
throw ArgumentError(
|
||||||
|
'Invalid argument: data length must be equal to width * height.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Image.empty(this.width, this.height) : _data = Uint32List(width * height);
|
||||||
|
|
||||||
|
static Future<Image> decodeImage(Uint8List data) async {
|
||||||
|
var codec = await ui.instantiateImageCodec(data);
|
||||||
|
var frame = await codec.getNextFrame();
|
||||||
|
codec.dispose();
|
||||||
|
var info = await frame.image.toByteData();
|
||||||
|
if (info == null) {
|
||||||
|
throw Exception('Failed to decode image');
|
||||||
|
}
|
||||||
|
var image = Image(
|
||||||
|
info.buffer.asUint32List(),
|
||||||
|
frame.image.width,
|
||||||
|
frame.image.height,
|
||||||
|
);
|
||||||
|
frame.image.dispose();
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image copyRange(int x, int y, int width, int height) {
|
||||||
|
if (width + x > this.width) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: x + width must be less than or equal to the image width.
|
||||||
|
x: $x, width: $width, image width: ${this.width}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
if (height + y > this.height) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: y + height must be less than or equal to the image height.
|
||||||
|
y: $y, height: $height, image height: ${this.height}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
var data = Uint32List(width * height);
|
||||||
|
for (var j = 0; j < height; j++) {
|
||||||
|
for (var i = 0; i < width; i++) {
|
||||||
|
data[j * width + i] = _data[(j + y) * this.width + i + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Image(data, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fillImageAt(int x, int y, Image image) {
|
||||||
|
if (x + image.width > width) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: x + image width must be less than or equal to the image width.
|
||||||
|
x: $x, image width: ${image.width}, image width: $width
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
if (y + image.height > height) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: y + image height must be less than or equal to the image height.
|
||||||
|
y: $y, image height: ${image.height}, image height: $height
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
for (var j = 0; j < image.height && (j + y) < height; j++) {
|
||||||
|
for (var i = 0; i < image.width && (i + x) < width; i++) {
|
||||||
|
_data[(j + y) * width + i + x] = image._data[j * image.width + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fillImageRangeAt(
|
||||||
|
int x, int y, Image image, int srcX, int srcY, int width, int height) {
|
||||||
|
if (x + width > this.width) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: x + width must be less than or equal to the image width.
|
||||||
|
x: $x, width: $width, image width: ${this.width}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
if (y + height > this.height) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: y + height must be less than or equal to the image height.
|
||||||
|
y: $y, height: $height, image height: ${this.height}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
if (srcX + width > image.width) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: srcX + width must be less than or equal to the image width.
|
||||||
|
srcX: $srcX, width: $width, image width: ${image.width}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
if (srcY + height > image.height) {
|
||||||
|
throw ArgumentError('''
|
||||||
|
Invalid argument: srcY + height must be less than or equal to the image height.
|
||||||
|
srcY: $srcY, height: $height, image height: ${image.height}
|
||||||
|
'''
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
for (var j = 0; j < height; j++) {
|
||||||
|
for (var i = 0; i < width; i++) {
|
||||||
|
_data[(j + y) * this.width + i + x] =
|
||||||
|
image._data[(j + srcY) * image.width + i + srcX];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Image copyAndRotate90() {
|
||||||
|
var data = Uint32List(width * height);
|
||||||
|
for (var j = 0; j < height; j++) {
|
||||||
|
for (var i = 0; i < width; i++) {
|
||||||
|
data[i * height + height - j - 1] = _data[j * width + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Image(data, height, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color getPixel(int x, int y) {
|
||||||
|
if (x < 0 || x >= width) {
|
||||||
|
throw ArgumentError(
|
||||||
|
'Invalid argument: x must be in the range of [0, $width).');
|
||||||
|
}
|
||||||
|
if (y < 0 || y >= height) {
|
||||||
|
throw ArgumentError(
|
||||||
|
'Invalid argument: y must be in the range of [0, $height).');
|
||||||
|
}
|
||||||
|
return Color.fromValue(_data[y * width + x]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPixel(int x, int y, Color color) {
|
||||||
|
if (x < 0 || x >= width) {
|
||||||
|
throw ArgumentError(
|
||||||
|
'Invalid argument: x must be in the range of [0, $width).');
|
||||||
|
}
|
||||||
|
if (y < 0 || y >= height) {
|
||||||
|
throw ArgumentError(
|
||||||
|
'Invalid argument: y must be in the range of [0, $height).');
|
||||||
|
}
|
||||||
|
_data[y * width + x] = color.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List encodePng() {
|
||||||
|
var data = lodepng.encodePngToPointer(lodepng.Image(
|
||||||
|
_data.buffer.asUint8List(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
));
|
||||||
|
return Pointer<Uint8>.fromAddress(data.address).asTypedList(data.length,
|
||||||
|
finalizer: lodepng.ByteBuffer.finalizer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Color {
|
||||||
|
final int value;
|
||||||
|
|
||||||
|
Color(int r, int g, int b, [int a = 255])
|
||||||
|
: value = (a << 24) | (r << 16) | (g << 8) | b;
|
||||||
|
|
||||||
|
Color.fromValue(this.value);
|
||||||
|
|
||||||
|
int get r => (value >> 16) & 0xFF;
|
||||||
|
|
||||||
|
int get g => (value >> 8) & 0xFF;
|
||||||
|
|
||||||
|
int get b => value & 0xFF;
|
||||||
|
|
||||||
|
int get a => (value >> 24) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
class JsEngine {
|
||||||
|
static final JsEngine _instance = JsEngine._();
|
||||||
|
|
||||||
|
factory JsEngine() => _instance;
|
||||||
|
|
||||||
|
JsEngine._() {
|
||||||
|
_engine = FlutterQjs();
|
||||||
|
_engine!.dispatch();
|
||||||
|
var setGlobalFunc =
|
||||||
|
_engine!.evaluate("(key, value) => { this[key] = value; }");
|
||||||
|
(setGlobalFunc as JSInvokable)(["sendMessage", _messageReceiver]);
|
||||||
|
setGlobalFunc.free();
|
||||||
|
}
|
||||||
|
|
||||||
|
FlutterQjs? _engine;
|
||||||
|
|
||||||
|
dynamic runCode(String js, [String? name]) {
|
||||||
|
return _engine!.evaluate(js, name: name);
|
||||||
|
}
|
||||||
|
|
||||||
|
var images = <int, Image>{};
|
||||||
|
|
||||||
|
int _key = 0;
|
||||||
|
|
||||||
|
int setImage(Image image) {
|
||||||
|
var key = _key++;
|
||||||
|
images[key] = image;
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object? _messageReceiver(dynamic message) {
|
||||||
|
if (message is! Map) return null;
|
||||||
|
var method = message['method'];
|
||||||
|
if (method == 'image') {
|
||||||
|
switch (message['function']) {
|
||||||
|
case 'copyRange':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
var x = message['x'];
|
||||||
|
var y = message['y'];
|
||||||
|
var width = message['width'];
|
||||||
|
var height = message['height'];
|
||||||
|
var newImage = image.copyRange(x, y, width, height);
|
||||||
|
return setImage(newImage);
|
||||||
|
case 'copyAndRotate90':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
var newImage = image.copyAndRotate90();
|
||||||
|
return setImage(newImage);
|
||||||
|
case 'fillImageAt':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
var x = message['x'];
|
||||||
|
var y = message['y'];
|
||||||
|
var key2 = message['image'];
|
||||||
|
var image2 = images[key2];
|
||||||
|
if (image2 == null) return null;
|
||||||
|
image.fillImageAt(x, y, image2);
|
||||||
|
return null;
|
||||||
|
case 'fillImageRangeAt':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
var x = message['x'];
|
||||||
|
var y = message['y'];
|
||||||
|
var key2 = message['image'];
|
||||||
|
var image2 = images[key2];
|
||||||
|
if (image2 == null) return null;
|
||||||
|
var srcX = message['srcX'];
|
||||||
|
var srcY = message['srcY'];
|
||||||
|
var width = message['width'];
|
||||||
|
var height = message['height'];
|
||||||
|
image.fillImageRangeAt(x, y, image2, srcX, srcY, width, height);
|
||||||
|
return null;
|
||||||
|
case 'getWidth':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
return image.width;
|
||||||
|
case 'getHeight':
|
||||||
|
var key = message['key'];
|
||||||
|
var image = images[key];
|
||||||
|
if (image == null) return null;
|
||||||
|
return image.height;
|
||||||
|
case 'emptyImage':
|
||||||
|
var width = message['width'];
|
||||||
|
var height = message['height'];
|
||||||
|
var newImage = Image.empty(width, height);
|
||||||
|
return setImage(newImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _tasksCount = 0;
|
||||||
|
|
||||||
|
Future<Uint8List> modifyImageWithScript(Uint8List data, String script) async {
|
||||||
|
while (_tasksCount > 3) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
}
|
||||||
|
_tasksCount++;
|
||||||
|
try {
|
||||||
|
var image = await Image.decodeImage(data);
|
||||||
|
var initJs = await rootBundle.loadString('assets/init.js');
|
||||||
|
return await Isolate.run(() {
|
||||||
|
var jsEngine = JsEngine();
|
||||||
|
jsEngine.runCode(initJs, '<init>');
|
||||||
|
jsEngine.runCode(script);
|
||||||
|
var key = jsEngine.setImage(image);
|
||||||
|
var res = jsEngine.runCode('''
|
||||||
|
let func = () => {
|
||||||
|
let image = new Image($key);
|
||||||
|
let result = modifyImage(image);
|
||||||
|
return result.key;
|
||||||
|
}
|
||||||
|
func();
|
||||||
|
''');
|
||||||
|
var newImage = jsEngine.images[res];
|
||||||
|
var data = newImage!.encodePng();
|
||||||
|
return Uint8List.fromList(data);
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
_tasksCount--;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
||||||
@@ -113,6 +114,12 @@ Future<void> copyDirectory(Directory source, Directory destination) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> copyDirectoryIsolate(Directory source, Directory destination) async {
|
||||||
|
await Isolate.run(() {
|
||||||
|
copyDirectory(source, destination);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
String findValidDirectoryName(String path, String directory) {
|
String findValidDirectoryName(String path, String directory) {
|
||||||
var name = sanitizeFileName(directory);
|
var name = sanitizeFileName(directory);
|
||||||
var dir = Directory("$path/$name");
|
var dir = Directory("$path/$name");
|
||||||
@@ -160,6 +167,22 @@ class DirectoryPicker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IOSDirectoryPicker {
|
||||||
|
static const MethodChannel _channel = MethodChannel("venera/method_channel");
|
||||||
|
|
||||||
|
// 调用 iOS 目录选择方法
|
||||||
|
static Future<String?> selectDirectory() async {
|
||||||
|
try {
|
||||||
|
final String? path = await _channel.invokeMethod('selectDirectory');
|
||||||
|
return path;
|
||||||
|
} catch (e) {
|
||||||
|
print("Error selecting directory: $e");
|
||||||
|
// 返回报错信息
|
||||||
|
return e.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<file_selector.XFile?> selectFile({required List<String> ext}) async {
|
Future<file_selector.XFile?> selectFile({required List<String> ext}) async {
|
||||||
file_selector.XTypeGroup typeGroup = file_selector.XTypeGroup(
|
file_selector.XTypeGroup typeGroup = file_selector.XTypeGroup(
|
||||||
label: 'files',
|
label: 'files',
|
||||||
@@ -181,6 +204,11 @@ Future<String?> selectDirectory() async {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// selectDirectoryIOS
|
||||||
|
Future<String?> selectDirectoryIOS() async {
|
||||||
|
return IOSDirectoryPicker.selectDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> saveFile(
|
Future<void> saveFile(
|
||||||
{Uint8List? data, required String filename, File? file}) async {
|
{Uint8List? data, required String filename, File? file}) async {
|
||||||
if (data == null && file == null) {
|
if (data == null && file == null) {
|
||||||
|
31
lib/utils/volume.dart
Normal file
31
lib/utils/volume.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class VolumeListener {
|
||||||
|
static const channel = EventChannel('venera/volume');
|
||||||
|
|
||||||
|
void Function()? onUp;
|
||||||
|
|
||||||
|
void Function()? onDown;
|
||||||
|
|
||||||
|
VolumeListener({this.onUp, this.onDown});
|
||||||
|
|
||||||
|
StreamSubscription? stream;
|
||||||
|
|
||||||
|
void listen() {
|
||||||
|
stream = channel.receiveBroadcastStream().listen(onEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onEvent(event) {
|
||||||
|
if (event == 1) {
|
||||||
|
onUp!();
|
||||||
|
} else if (event == 2) {
|
||||||
|
onDown!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancel() {
|
||||||
|
stream?.cancel();
|
||||||
|
}
|
||||||
|
}
|
@@ -10,7 +10,7 @@
|
|||||||
#include <file_selector_linux/file_selector_plugin.h>
|
#include <file_selector_linux/file_selector_plugin.h>
|
||||||
#include <flutter_qjs/flutter_qjs_plugin.h>
|
#include <flutter_qjs/flutter_qjs_plugin.h>
|
||||||
#include <gtk/gtk_plugin.h>
|
#include <gtk/gtk_plugin.h>
|
||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
#include <window_manager/window_manager_plugin.h>
|
#include <window_manager/window_manager_plugin.h>
|
||||||
@@ -28,9 +28,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
|||||||
g_autoptr(FlPluginRegistrar) gtk_registrar =
|
g_autoptr(FlPluginRegistrar) gtk_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
|
||||||
gtk_plugin_register_with_registrar(gtk_registrar);
|
gtk_plugin_register_with_registrar(gtk_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
|
||||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||||
|
@@ -7,13 +7,15 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
file_selector_linux
|
file_selector_linux
|
||||||
flutter_qjs
|
flutter_qjs
|
||||||
gtk
|
gtk
|
||||||
screen_retriever
|
screen_retriever_linux
|
||||||
sqlite3_flutter_libs
|
sqlite3_flutter_libs
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
window_manager
|
window_manager
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
lodepng_flutter
|
||||||
|
rhttp
|
||||||
zip_flutter
|
zip_flutter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ import desktop_webview_window
|
|||||||
import file_selector_macos
|
import file_selector_macos
|
||||||
import flutter_inappwebview_macos
|
import flutter_inappwebview_macos
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import screen_retriever
|
import screen_retriever_macos
|
||||||
import share_plus
|
import share_plus
|
||||||
import sqlite3_flutter_libs
|
import sqlite3_flutter_libs
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
@@ -22,7 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
|
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
|
168
pubspec.lock
168
pubspec.lock
@@ -57,6 +57,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
build_cli_annotations:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_cli_annotations
|
||||||
|
sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -337,10 +345,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_reorderable_grid_view
|
name: flutter_reorderable_grid_view
|
||||||
sha256: "40abcc5bff228ebff119326502e7357ee6399956b60b80b17385e9770b7458c0"
|
sha256: "93a2b9e279bf40b9333428a67e70e520ca1528554984eb6f6304538400897e64"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.1"
|
version: "5.3.2"
|
||||||
|
flutter_rust_bridge:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_rust_bridge
|
||||||
|
sha256: "5fe868d3cb8cbc4d83091748552e03f00ccfa41b8e44691bc382611f831d5f8b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.1"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -368,6 +384,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
freezed_annotation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: freezed_annotation
|
||||||
|
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.4"
|
||||||
gtk:
|
gtk:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -424,6 +448,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.1"
|
version: "0.7.1"
|
||||||
|
json_annotation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: json_annotation
|
||||||
|
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.9.0"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -456,6 +488,15 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0"
|
version: "3.0.0"
|
||||||
|
lodepng_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "."
|
||||||
|
ref: d1c96cd6503103b3270dfe2f320d4a1c93780f53
|
||||||
|
resolved-ref: d1c96cd6503103b3270dfe2f320d4a1c93780f53
|
||||||
|
url: "https://github.com/venera-app/lodepng_flutter"
|
||||||
|
source: git
|
||||||
|
version: "0.0.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -552,6 +593,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.3.0"
|
||||||
|
permission_handler:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: permission_handler
|
||||||
|
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "11.3.1"
|
||||||
|
permission_handler_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_android
|
||||||
|
sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "12.0.13"
|
||||||
|
permission_handler_apple:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_apple
|
||||||
|
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "9.4.5"
|
||||||
|
permission_handler_html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_html
|
||||||
|
sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.3+2"
|
||||||
|
permission_handler_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_platform_interface
|
||||||
|
sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.2.3"
|
||||||
|
permission_handler_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_windows
|
||||||
|
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.2"
|
||||||
photo_view:
|
photo_view:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -585,14 +682,54 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
version: "3.9.1"
|
||||||
|
rhttp:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: rhttp
|
||||||
|
sha256: "92fb57dea6338370efe1e4e2101e8b521f91f15bc60ef6908469b4392dd9803a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.1"
|
||||||
screen_retriever:
|
screen_retriever:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: screen_retriever
|
name: screen_retriever
|
||||||
sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90"
|
sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.9"
|
version: "0.2.0"
|
||||||
|
screen_retriever_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: screen_retriever_linux
|
||||||
|
sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
|
screen_retriever_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: screen_retriever_macos
|
||||||
|
sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
|
screen_retriever_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: screen_retriever_platform_interface
|
||||||
|
sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
|
screen_retriever_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: screen_retriever_windows
|
||||||
|
sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
scrollable_positioned_list:
|
scrollable_positioned_list:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -807,6 +944,15 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
|
webdav_client:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "."
|
||||||
|
ref: "285f87f15bccd2d5d5ff443761348c6ee47b98d1"
|
||||||
|
resolved-ref: "285f87f15bccd2d5d5ff443761348c6ee47b98d1"
|
||||||
|
url: "https://github.com/wgh136/webdav_client"
|
||||||
|
source: git
|
||||||
|
version: "1.2.2"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -819,10 +965,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: window_manager
|
name: window_manager
|
||||||
sha256: ab8b2a7f97543d3db2b506c9d875e637149d48ee0c6a5cb5f5fd6e0dac463792
|
sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.2"
|
version: "0.4.3"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -831,6 +977,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
|
xml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.0"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -849,5 +1003,5 @@ packages:
|
|||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.5.0 <4.0.0"
|
dart: ">=3.5.4 <4.0.0"
|
||||||
flutter: ">=3.24.4"
|
flutter: ">=3.24.4"
|
||||||
|
15
pubspec.yaml
15
pubspec.yaml
@@ -2,7 +2,7 @@ name: venera
|
|||||||
description: "A comic app."
|
description: "A comic app."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.0.1+101
|
version: 1.0.4+104
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.5.0 <4.0.0'
|
sdk: '>=3.5.0 <4.0.0'
|
||||||
@@ -15,7 +15,7 @@ dependencies:
|
|||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
intl: any
|
intl: any
|
||||||
window_manager: ^0.4.2
|
window_manager: ^0.4.3
|
||||||
sqlite3: any
|
sqlite3: any
|
||||||
sqlite3_flutter_libs: any
|
sqlite3_flutter_libs: any
|
||||||
flutter_qjs:
|
flutter_qjs:
|
||||||
@@ -39,7 +39,7 @@ dependencies:
|
|||||||
url: https://github.com/venera-app/flutter.widgets
|
url: https://github.com/venera-app/flutter.widgets
|
||||||
ref: 09e756b1f1b04e6298318d99ec20a787fb360f59
|
ref: 09e756b1f1b04e6298318d99ec20a787fb360f59
|
||||||
path: packages/scrollable_positioned_list
|
path: packages/scrollable_positioned_list
|
||||||
flutter_reorderable_grid_view: 5.0.1
|
flutter_reorderable_grid_view: 5.3.2
|
||||||
yaml: any
|
yaml: any
|
||||||
uuid: ^4.5.1
|
uuid: ^4.5.1
|
||||||
desktop_webview_window:
|
desktop_webview_window:
|
||||||
@@ -54,6 +54,15 @@ dependencies:
|
|||||||
zip_flutter:
|
zip_flutter:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/wgh136/zip_flutter
|
url: https://github.com/wgh136/zip_flutter
|
||||||
|
lodepng_flutter:
|
||||||
|
git:
|
||||||
|
url: https://github.com/venera-app/lodepng_flutter
|
||||||
|
ref: d1c96cd6503103b3270dfe2f320d4a1c93780f53
|
||||||
|
rhttp: 0.9.1
|
||||||
|
webdav_client:
|
||||||
|
git:
|
||||||
|
url: https://github.com/wgh136/webdav_client
|
||||||
|
ref: 285f87f15bccd2d5d5ff443761348c6ee47b98d1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@@ -52,8 +52,11 @@ Source: "{#RootPath}\build\windows\x64\runner\Release\WebView2Loader.dll"; DestD
|
|||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\share_plus_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "{#RootPath}\build\windows\x64\runner\Release\share_plus_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\url_launcher_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "{#RootPath}\build\windows\x64\runner\Release\url_launcher_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\screen_retriever_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "{#RootPath}\build\windows\x64\runner\Release\screen_retriever_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\screen_retriever_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\window_manager_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "{#RootPath}\build\windows\x64\runner\Release\window_manager_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\zip_flutter.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "{#RootPath}\build\windows\x64\runner\Release\zip_flutter.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\rhttp.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\lodepng_flutter.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "{#RootPath}\build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
Source: "{#RootPath}\build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||||
|
|
||||||
|
@@ -11,7 +11,8 @@
|
|||||||
#include <file_selector_windows/file_selector_windows.h>
|
#include <file_selector_windows/file_selector_windows.h>
|
||||||
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
|
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
|
||||||
#include <flutter_qjs/flutter_qjs_plugin.h>
|
#include <flutter_qjs/flutter_qjs_plugin.h>
|
||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
|
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
@@ -28,8 +29,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
|
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
|
||||||
FlutterQjsPluginRegisterWithRegistrar(
|
FlutterQjsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterQjsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterQjsPlugin"));
|
||||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
|
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||||
|
@@ -8,7 +8,8 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
file_selector_windows
|
file_selector_windows
|
||||||
flutter_inappwebview_windows
|
flutter_inappwebview_windows
|
||||||
flutter_qjs
|
flutter_qjs
|
||||||
screen_retriever
|
permission_handler_windows
|
||||||
|
screen_retriever_windows
|
||||||
share_plus
|
share_plus
|
||||||
sqlite3_flutter_libs
|
sqlite3_flutter_libs
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
@@ -16,6 +17,8 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
lodepng_flutter
|
||||||
|
rhttp
|
||||||
zip_flutter
|
zip_flutter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user