Skip to content

Commit

Permalink
Merge pull request #104 from venera-app/dev
Browse files Browse the repository at this point in the history
v1.1.2
  • Loading branch information
wgh136 authored Dec 18, 2024
2 parents 17bce96 + bda215e commit bf634f8
Show file tree
Hide file tree
Showing 32 changed files with 481 additions and 231 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<!-- [flutter 3.27.1] Impeller is still worse than skia, disable it -->
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false"/>
</application>
<!-- Required to query activities that can process text, see:
Expand Down
18 changes: 16 additions & 2 deletions assets/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@
"Aggregated Search": "聚合搜索",
"No search results found": "未找到搜索结果",
"Added @c comics to download queue." : "已添加 @c 本漫画到下载队列",
"Download started": "下载已开始"
"Download started": "下载已开始",
"Click favorite": "点击收藏",
"End": "末尾",
"None": "",
"View Detail": "查看详情",
"Select a directory which contains multiple cbz/zip files." : "选择一个包含多个cbz/zip文件的目录",
"Multiple cbz files" : "多个cbz文件",
"No valid comics found" : "未找到有效的漫画"
},
"zh_TW": {
"Home": "首頁",
Expand Down Expand Up @@ -505,6 +512,13 @@
"Aggregated Search": "聚合搜索",
"No search results found": "未找到搜索結果",
"Added @c comics to download queue." : "已添加 @c 本漫畫到下載隊列",
"Download started": "下載已開始"
"Download started": "下載已開始",
"Click favorite": "點擊收藏",
"End": "末尾",
"None": "",
"View Detail": "查看詳情",
"Select a directory which contains multiple cbz/zip files." : "選擇一個包含多個cbz/zip文件的目錄",
"Multiple cbz files" : "多個cbz文件",
"No valid comics found" : "未找到有效的漫畫"
}
}
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '14.0'
platform :ios, '15.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
2 changes: 1 addition & 1 deletion lib/components/comic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ComicTile extends StatelessWidget {
icon: Icons.stars_outlined,
text: 'Add to favorites'.tl,
onClick: () {
addFavorite(comic);
addFavorite([comic]);
},
),
MenuEntry(
Expand Down
22 changes: 19 additions & 3 deletions lib/components/gesture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,37 @@ class AnimatedTapRegion extends StatefulWidget {
}

class _AnimatedTapRegionState extends State<AnimatedTapRegion> {
bool isScaled = false;

bool isHovered = false;

@override
Widget build(BuildContext context) {
return MouseRegion(
onEnter: (_) => setState(() => isHovered = true),
onExit: (_) => setState(() => isHovered = false),
onEnter: (_) {
isHovered = true;
if (!isScaled) {
Future.delayed(const Duration(milliseconds: 100), () {
if (isHovered) {
setState(() => isScaled = true);
}
});
}
},
onExit: (_) {
isHovered = false;
if(isScaled) {
setState(() => isScaled = false);
}
},
child: GestureDetector(
onTap: widget.onTap,
child: ClipRRect(
borderRadius: BorderRadius.circular(widget.borderRadius),
clipBehavior: Clip.antiAlias,
child: AnimatedScale(
duration: _fastAnimationDuration,
scale: isHovered ? 1.1 : 1,
scale: isScaled ? 1.1 : 1,
child: widget.child,
),
),
Expand Down
17 changes: 12 additions & 5 deletions lib/components/pop_up_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ class PopUpWidget<T> extends PopupRoute<T> {
Widget body = PopupIndicatorWidget(
child: Container(
decoration: showPopUp
? const BoxDecoration(
? BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)),
boxShadow: context.brightness == ui.Brightness.dark ? [
BoxShadow(
color: Colors.white.withAlpha(50),
blurRadius: 10,
offset: Offset(0, 2),
),
] : null,
)
: null,
clipBehavior: showPopUp ? Clip.antiAlias : Clip.none,
Expand Down Expand Up @@ -86,7 +93,8 @@ class PopupIndicatorWidget extends InheritedWidget {
}

Future<T> showPopUpWidget<T>(BuildContext context, Widget widget) async {
return await Navigator.of(context, rootNavigator: true).push(PopUpWidget(widget));
return await Navigator.of(context, rootNavigator: true)
.push(PopUpWidget(widget));
}

class PopUpWidgetScaffold extends StatefulWidget {
Expand Down Expand Up @@ -127,9 +135,8 @@ class _PopUpWidgetScaffoldState extends State<PopUpWidgetScaffold> {
message: "Back".tl,
child: IconButton(
icon: const Icon(Icons.arrow_back_sharp),
onPressed: () => context.canPop()
? context.pop()
: App.pop(),
onPressed: () =>
context.canPop() ? context.pop() : App.pop(),
),
),
const SizedBox(
Expand Down
16 changes: 12 additions & 4 deletions lib/components/side_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ class SideBarRoute<T> extends PopupRoute<T> {

body = Container(
decoration: BoxDecoration(
borderRadius: showSideBar
? const BorderRadius.horizontal(left: Radius.circular(16))
: null,
color: Theme.of(context).colorScheme.surfaceTint),
borderRadius: showSideBar
? const BorderRadius.horizontal(left: Radius.circular(16))
: null,
color: Theme.of(context).colorScheme.surfaceTint,
boxShadow: context.brightness == ui.Brightness.dark ? [
BoxShadow(
color: Colors.white.withAlpha(50),
blurRadius: 10,
offset: Offset(0, 2),
),
] : null,
),
clipBehavior: Clip.antiAlias,
constraints: BoxConstraints(maxWidth: sideBarWidth),
height: MediaQuery.of(context).size.height,
Expand Down
2 changes: 1 addition & 1 deletion lib/foundation/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export "widget_utils.dart";
export "context.dart";

class _App {
final version = "1.1.1";
final version = "1.1.2";

bool get isAndroid => Platform.isAndroid;

Expand Down
1 change: 1 addition & 0 deletions lib/foundation/appdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class _Settings with ChangeNotifier {
'enableClockAndBatteryInfoInReader': true,
'ignoreCertificateErrors': false,
'authorizationRequired': false,
'onClickFavorite': 'viewDetail', // viewDetail, read
};

operator [](String key) {
Expand Down
6 changes: 3 additions & 3 deletions lib/foundation/comic_source/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ComicDetails with HistoryMixin {

final int? likesCount;

final int? commentsCount;
final int? commentCount;

final String? uploader;

Expand Down Expand Up @@ -189,7 +189,7 @@ class ComicDetails with HistoryMixin {
subId = json["subId"],
likesCount = json["likesCount"],
isLiked = json["isLiked"],
commentsCount = json["commentsCount"],
commentCount = json["commentCount"],
uploader = json["uploader"],
uploadTime = json["uploadTime"],
updateTime = json["updateTime"],
Expand All @@ -216,7 +216,7 @@ class ComicDetails with HistoryMixin {
"subId": subId,
"isLiked": isLiked,
"likesCount": likesCount,
"commentsCount": commentsCount,
"commentsCount": commentCount,
"uploader": uploader,
"uploadTime": uploadTime,
"updateTime": updateTime,
Expand Down
8 changes: 8 additions & 0 deletions lib/foundation/comic_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ class ComicType {
}

static const local = ComicType(0);

factory ComicType.fromKey(String key) {
if(key == "local") {
return local;
} else {
return ComicType(key.hashCode);
}
}
}
13 changes: 8 additions & 5 deletions lib/foundation/image_provider/base_image_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>
screen.size.height * _normalComicImageRatio,
);
} else {
_effectiveScreenWidth = max(
_effectiveScreenWidth ?? 0,
screen.size.width
);
_effectiveScreenWidth =
max(_effectiveScreenWidth ?? 0, screen.size.width);
}
}
if (_effectiveScreenWidth! < _minComicImageWidth) {
Expand Down Expand Up @@ -110,7 +108,10 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>

try {
final buffer = await ImmutableBuffer.fromUint8List(data);
return await decode(buffer, getTargetSize: _getTargetSize);
return await decode(
buffer,
getTargetSize: enableResize ? _getTargetSize : null,
);
} catch (e) {
await CacheManager().delete(this.key);
if (data.length < 2 * 1024) {
Expand Down Expand Up @@ -151,6 +152,8 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>
String toString() {
return "$runtimeType($key)";
}

bool get enableResize => false;
}

typedef FileDecoderCallback = Future<ui.Codec> Function(Uint8List);
3 changes: 3 additions & 0 deletions lib/foundation/image_provider/reader_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ class ReaderImageProvider

@override
String get key => "$imageKey@$sourceKey@$cid@$eid";

@override
bool get enableResize => true;
}
16 changes: 9 additions & 7 deletions lib/foundation/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,15 @@ class LocalManager with ChangeNotifier {
var dir = Directory(FilePath.join(path, c.directory));
dir.deleteIgnoreError(recursive: true);
}
//Deleting a local comic means that it's nolonger available, thus both favorite and history should be deleted.
if(HistoryManager().findSync(c.id, c.comicType) != null) {
HistoryManager().remove(c.id, c.comicType);
}
var folders = LocalFavoritesManager().find(c.id, c.comicType);
for (var f in folders) {
LocalFavoritesManager().deleteComicWithId(f, c.id, c.comicType);
// Deleting a local comic means that it's nolonger available, thus both favorite and history should be deleted.
if(c.comicType == ComicType.local) {
if(HistoryManager().findSync(c.id, c.comicType) != null) {
HistoryManager().remove(c.id, c.comicType);
}
var folders = LocalFavoritesManager().find(c.id, c.comicType);
for (var f in folders) {
LocalFavoritesManager().deleteComicWithId(f, c.id, c.comicType);
}
}
remove(c.id, c.comicType);
notifyListeners();
Expand Down
9 changes: 7 additions & 2 deletions lib/network/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {

String? _cover;

/// All images to download, key is chapter name
Map<String, List<String>>? _images;

/// Downloaded image count
int _downloadedCount = 0;

/// Total image count
int _totalCount = 0;

/// Current downloading image index
int _index = 0;

/// Current downloading chapter, index of [_images]
int _chapter = 0;

var tasks = <int, _ImageDownloadWrapper>{};
Expand All @@ -180,10 +185,10 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
if (comic!.chapters != null) {
saveTo = Directory(FilePath.join(
path!,
comic!.chapters!.keys.elementAt(_chapter),
_images!.keys.elementAt(_chapter),
));
if (!saveTo.existsSync()) {
saveTo.createSync();
saveTo.createSync(recursive: true);
}
} else {
saveTo = Directory(path!);
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/comic_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
isLiked = comic.isLiked ?? false;
isFavorite = comic.isFavorite ?? false;
if (comic.chapters == null) {
isDownloaded = await LocalManager().isDownloaded(
isDownloaded = LocalManager().isDownloaded(
comic.id,
comic.comicType,
0,
Expand Down Expand Up @@ -292,7 +292,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
if (comicSource.commentsLoader != null)
_ActionButton(
icon: const Icon(Icons.comment),
text: (comic.commentsCount ?? 'Comments'.tl).toString(),
text: (comic.commentCount ?? 'Comments'.tl).toString(),
onPressed: showComments,
iconColor: context.useTextColor(Colors.green),
),
Expand Down Expand Up @@ -679,7 +679,7 @@ abstract mixin class _ComicPageActions {
return;
}
if (comic.chapters == null &&
await LocalManager().isDownloaded(comic.id, comic.comicType, 0)) {
LocalManager().isDownloaded(comic.id, comic.comicType, 0)) {
App.rootContext.showMessage(message: "The comic is downloaded".tl);
return;
}
Expand Down
30 changes: 16 additions & 14 deletions lib/pages/favorites/favorite_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ String? validateFolderName(String newFolderName) {
return null;
}

void addFavorite(Comic comic) {
void addFavorite(List<Comic> comics) {
var folders = LocalFavoritesManager().folderNames;

showDialog(
Expand Down Expand Up @@ -105,19 +105,21 @@ void addFavorite(Comic comic) {
FilledButton(
onPressed: () {
if (selectedFolder != null) {
LocalFavoritesManager().addComic(
selectedFolder!,
FavoriteItem(
id: comic.id,
name: comic.title,
coverPath: comic.cover,
author: comic.subtitle ?? '',
type: ComicType((comic.sourceKey == 'local'
? 0
: comic.sourceKey.hashCode)),
tags: comic.tags ?? [],
),
);
for (var comic in comics) {
LocalFavoritesManager().addComic(
selectedFolder!,
FavoriteItem(
id: comic.id,
name: comic.title,
coverPath: comic.cover,
author: comic.subtitle ?? '',
type: ComicType((comic.sourceKey == 'local'
? 0
: comic.sourceKey.hashCode)),
tags: comic.tags ?? [],
),
);
}
context.pop();
}
},
Expand Down
1 change: 1 addition & 0 deletions lib/pages/favorites/favorites_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:venera/foundation/local.dart';
import 'package:venera/foundation/res.dart';
import 'package:venera/network/download.dart';
import 'package:venera/pages/comic_page.dart';
import 'package:venera/pages/reader/reader.dart';
import 'package:venera/utils/io.dart';
import 'package:venera/utils/translations.dart';

Expand Down
Loading

0 comments on commit bf634f8

Please sign in to comment.