Skip to content

Commit

Permalink
default reading mode
Browse files Browse the repository at this point in the history
add default reading mode ,prbuild
  • Loading branch information
appdevelpo committed Dec 2, 2023
1 parent f673f83 commit b6610ed
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
path: "build/windows/runner/Miru-App"
path: "build/windows/x64/runner/Miru-App"
name: Miru-pr-${{ github.event.pull_request.number }}-windows.zip
1 change: 1 addition & 0 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"extension-log-subtitle": "Used for debugging extensions",
"skip-interval": "Skip Interval",
"skip-interval-subtitle": "Skipping interval for builtin video player",
"default-reader-mode": "Default reader mode",
"about": "About",
"official-site": "Official Website",
"official-site-training": "Visit",
Expand Down
23 changes: 16 additions & 7 deletions lib/controllers/watch/comic_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:miru_app/data/services/database_service.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'dart:async';
import 'package:extended_image/extended_image.dart';
import 'package:miru_app/utils/miru_storage.dart';

class ComicController extends ReaderController<ExtensionMangaWatch> {
ComicController({
Expand All @@ -17,8 +18,15 @@ class ComicController extends ReaderController<ExtensionMangaWatch> {
required super.runtime,
required super.cover,
});

Map<String, MangaReadMode> readmode = {
'standard': MangaReadMode.standard,
'rightToLeft': MangaReadMode.rightToLeft,
'webTonn': MangaReadMode.webTonn,
};
final String setting = MiruStorage.getSetting(SettingKey.readingMode);
final readType = MangaReadMode.standard.obs;

// MangaReadMode
// 当前页码
final currentPage = 0.obs;
bool timerCancel = false;
Expand Down Expand Up @@ -100,13 +108,15 @@ class ComicController extends ReaderController<ExtensionMangaWatch> {
}

_initSetting() async {
readType.value = await DatabaseService.getMnagaReaderType(super.detailUrl);
readType.value = readmode[setting] ?? MangaReadMode.standard;
readType.value = await DatabaseService.getMnagaReaderType(
super.detailUrl, readType.value);
}

double mapValue(double value) {
double mappedValue = ((value - 0) * (1 - (-1))) / (2.5 - 0) + (-1);
return mappedValue;
}
// double mapValue(double value) {
// double mappedValue = ((value - 0) * (1 - (-1))) / (2.5 - 0) + (-1);
// return mappedValue;
// }

_jumpPage(int page) {
if (readType.value == MangaReadMode.webTonn) {
Expand Down Expand Up @@ -186,7 +196,6 @@ class ComicController extends ReaderController<ExtensionMangaWatch> {
);
}
pageController.value.dispose();

timerCancel = true;
super.onClose();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/data/services/database_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ class DatabaseService {
}

// 获取漫画阅读模式
static Future<MangaReadMode> getMnagaReaderType(String url) {
static Future<MangaReadMode> getMnagaReaderType(
String url, MangaReadMode defaultMode) {
return db.mangaSettings.filter().urlEqualTo(url).findFirst().then(
(value) => value?.readMode ?? MangaReadMode.standard,
(value) => value?.readMode ?? defaultMode,
);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/utils/miru_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MiruStorage {
await _initSetting(SettingKey.keyJ, -10.0);
await _initSetting(SettingKey.arrowLeft, -2.0);
await _initSetting(SettingKey.arrowRight, 2.0);
await _initSetting(SettingKey.readingMode, "standard");
}

static _initSetting(String key, dynamic value) async {
Expand Down Expand Up @@ -149,6 +150,7 @@ class SettingKey {
static String skipInterval = 'SkipInterval';
static String keyI = 'KeyI';
static String keyJ = 'KeyJ';
static String arrowLeft = 'arrowleft';
static String arrowRight = 'arrowright';
static String arrowLeft = 'Arrowleft';
static String arrowRight = 'Arrowright';
static String readingMode = 'ReadingMode';
}
27 changes: 26 additions & 1 deletion lib/views/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ class _SettingsPageState extends State<SettingsPage> {
},
),
const SizedBox(height: 8),
SettingsRadiosTile(
icon: const PlatformWidget(
androidWidget: Icon(Icons.chrome_reader_mode),
desktopWidget:
Icon(fluent.FluentIcons.reading_mode_solid, size: 24),
),
title: 'settings.default-reader-mode'.i18n,
itemNameValue: () {
final map = {
'comic-settings.standard'.i18n: 'standard',
'comic-settings.right-to-left'.i18n: 'rightToLeft',
'comic-settings.web-tonn'.i18n: 'webTonn',
};
return map;
}(),
buildSubtitle: () =>
'${MiruStorage.getSetting(SettingKey.readingMode)}'.i18n,
applyValue: (value) {
MiruStorage.setSetting(SettingKey.readingMode, value);
},
buildGroupValue: () {
return MiruStorage.getSetting(SettingKey.readingMode);
},
),
const SizedBox(height: 8),
SettingsRadiosTile(
icon: const PlatformWidget(
androidWidget: Icon(Icons.play_arrow),
Expand Down Expand Up @@ -301,7 +326,7 @@ class _SettingsPageState extends State<SettingsPage> {
fluent.Expander(
header: Row(
children: [
Icon(fluent.FluentIcons.keyboard_classic, size: 24),
const Icon(fluent.FluentIcons.keyboard_classic, size: 24),
const SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down

0 comments on commit b6610ed

Please sign in to comment.