mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Improve sharing image & saving image
This commit is contained in:
@@ -205,7 +205,8 @@
|
|||||||
"Finished": "已完成",
|
"Finished": "已完成",
|
||||||
"Updating": "更新中",
|
"Updating": "更新中",
|
||||||
"Update Comics Info": "更新漫画信息",
|
"Update Comics Info": "更新漫画信息",
|
||||||
"Create Folder": "新建文件夹"
|
"Create Folder": "新建文件夹",
|
||||||
|
"Select an image on screen": "选择屏幕上的图片"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -413,6 +414,7 @@
|
|||||||
"Finished": "已完成",
|
"Finished": "已完成",
|
||||||
"Updating": "更新中",
|
"Updating": "更新中",
|
||||||
"Update Comics Info": "更新漫畫信息",
|
"Update Comics Info": "更新漫畫信息",
|
||||||
"Create Folder": "新建文件夾"
|
"Create Folder": "新建文件夾",
|
||||||
|
"Select an image on screen": "選擇屏幕上的圖片"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -324,6 +324,8 @@ enum ReaderMode {
|
|||||||
|
|
||||||
bool get isGallery => key.startsWith('gallery');
|
bool get isGallery => key.startsWith('gallery');
|
||||||
|
|
||||||
|
bool get isContinuous => key.startsWith('continuous');
|
||||||
|
|
||||||
const ReaderMode(this.key);
|
const ReaderMode(this.key);
|
||||||
|
|
||||||
static ReaderMode fromKey(String key) {
|
static ReaderMode fromKey(String key) {
|
||||||
|
@@ -426,7 +426,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildStatusInfo() {
|
Widget buildStatusInfo() {
|
||||||
if(appdata.settings['enableClockAndBatteryInfoInReader']) {
|
if (appdata.settings['enableClockAndBatteryInfoInReader']) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
bottom: 13,
|
bottom: 13,
|
||||||
right: 25,
|
right: 25,
|
||||||
@@ -451,8 +451,73 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> _getCurrentImageData() async {
|
Future<Uint8List?> _getCurrentImageData() async {
|
||||||
var imageKey = context.reader.images![context.reader.page - 1];
|
var imageKey = context.reader.images![context.reader.page - 1];
|
||||||
|
var reader = context.reader;
|
||||||
|
if (context.reader.mode.isContinuous) {
|
||||||
|
var continuesState =
|
||||||
|
context.reader._imageViewController as _ContinuousModeState;
|
||||||
|
var imagesOnScreen =
|
||||||
|
continuesState.itemPositionsListener.itemPositions.value;
|
||||||
|
var images = imagesOnScreen
|
||||||
|
.map((e) => context.reader.images![e.index - 1])
|
||||||
|
.toList();
|
||||||
|
String? selected;
|
||||||
|
await showPopUpWidget(
|
||||||
|
context,
|
||||||
|
PopUpWidgetScaffold(
|
||||||
|
title: "Select an image on screen".tl,
|
||||||
|
body: GridView.builder(
|
||||||
|
itemCount: images.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
ImageProvider image;
|
||||||
|
var imageKey = images[index];
|
||||||
|
if (imageKey.startsWith('file://')) {
|
||||||
|
image = FileImage(File(imageKey.replaceFirst("file://", '')));
|
||||||
|
} else {
|
||||||
|
image = ReaderImageProvider(
|
||||||
|
imageKey,
|
||||||
|
reader.type.comicSource!.key,
|
||||||
|
reader.cid,
|
||||||
|
reader.eid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
|
onTap: () {
|
||||||
|
selected = images[index];
|
||||||
|
App.rootContext.pop();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Image(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
image: image,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).padding(const EdgeInsets.all(8));
|
||||||
|
},
|
||||||
|
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
maxCrossAxisExtent: 200,
|
||||||
|
childAspectRatio: 0.7,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (selected == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
imageKey = selected!;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (imageKey.startsWith("file://")) {
|
if (imageKey.startsWith("file://")) {
|
||||||
return await File(imageKey.substring(7)).readAsBytes();
|
return await File(imageKey.substring(7)).readAsBytes();
|
||||||
} else {
|
} else {
|
||||||
@@ -464,6 +529,9 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
|
|
||||||
void saveCurrentImage() async {
|
void saveCurrentImage() async {
|
||||||
var data = await _getCurrentImageData();
|
var data = await _getCurrentImageData();
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var fileType = detectFileType(data);
|
var fileType = detectFileType(data);
|
||||||
var filename = "${context.reader.page}${fileType.ext}";
|
var filename = "${context.reader.page}${fileType.ext}";
|
||||||
saveFile(data: data, filename: filename);
|
saveFile(data: data, filename: filename);
|
||||||
@@ -471,6 +539,9 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
|
|
||||||
void share() async {
|
void share() async {
|
||||||
var data = await _getCurrentImageData();
|
var data = await _getCurrentImageData();
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var fileType = detectFileType(data);
|
var fileType = detectFileType(data);
|
||||||
var filename = "${context.reader.page}${fileType.ext}";
|
var filename = "${context.reader.page}${fileType.ext}";
|
||||||
Share.shareFile(
|
Share.shareFile(
|
||||||
@@ -490,7 +561,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
App.rootContext.pop();
|
App.rootContext.pop();
|
||||||
}
|
}
|
||||||
if (key == "enableTurnPageByVolumeKey") {
|
if (key == "enableTurnPageByVolumeKey") {
|
||||||
if(appdata.settings[key]) {
|
if (appdata.settings[key]) {
|
||||||
context.reader.handleVolumeEvent();
|
context.reader.handleVolumeEvent();
|
||||||
} else {
|
} else {
|
||||||
context.reader.stopVolumeEvent();
|
context.reader.stopVolumeEvent();
|
||||||
@@ -613,13 +684,14 @@ class _BatteryWidgetState extends State<_BatteryWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_hasBattery = true;
|
_hasBattery = true;
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
_battery.batteryLevel.then((level) =>{
|
_battery.batteryLevel.then((level) => {
|
||||||
if(_batteryLevel != level) {
|
if (_batteryLevel != level)
|
||||||
setState(() {
|
{
|
||||||
_batteryLevel = level;
|
setState(() {
|
||||||
})
|
_batteryLevel = level;
|
||||||
}
|
})
|
||||||
});
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -680,9 +752,10 @@ class _BatteryWidgetState extends State<_BatteryWidget> {
|
|||||||
size: 16,
|
size: 16,
|
||||||
color: batteryColor,
|
color: batteryColor,
|
||||||
// Stroke
|
// Stroke
|
||||||
shadows: List.generate(9,
|
shadows: List.generate(
|
||||||
|
9,
|
||||||
(index) {
|
(index) {
|
||||||
if(index == 4) {
|
if (index == 4) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
double offsetX = (index % 3 - 1) * 0.8;
|
double offsetX = (index % 3 - 1) * 0.8;
|
||||||
@@ -729,7 +802,7 @@ class _ClockWidgetState extends State<_ClockWidget> {
|
|||||||
_currentTime = _getCurrentTime();
|
_currentTime = _getCurrentTime();
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
final time = _getCurrentTime();
|
final time = _getCurrentTime();
|
||||||
if(_currentTime != time) {
|
if (_currentTime != time) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentTime = time;
|
_currentTime = time;
|
||||||
});
|
});
|
||||||
@@ -751,19 +824,19 @@ class _ClockWidgetState extends State<_ClockWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
_currentTime,
|
_currentTime,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
foreground: Paint()
|
foreground: Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.4
|
..strokeWidth = 1.4
|
||||||
..color = context.colorScheme.onInverseSurface,
|
..color = context.colorScheme.onInverseSurface,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Text(_currentTime),
|
),
|
||||||
],
|
Text(_currentTime),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user